Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove hyphens during fill-paragraph?

When I manually use fill-paragraph I would like to have emacs remove all previously inserted hyphenations (by others?). That means automatically replacing all "-\n" with "".

How can I do that?

like image 286
towi Avatar asked Dec 19 '25 22:12

towi


1 Answers

I can imagine that not working out well in some cases, however...

(defadvice fill-delete-newlines (before my-before-fill-delete-newlines)
  "Replace -\\n with an empty string when calling `fill-paragraph'."
  (when (eq this-command 'fill-paragraph)
    (goto-char (ad-get-arg 0))
    (while (search-forward "-\n" (ad-get-arg 1) t)
      (replace-match "")
      (ad-set-arg 1 (- (ad-get-arg 1) 2)))))

(ad-activate 'fill-delete-newlines)
like image 141
phils Avatar answered Dec 22 '25 11:12

phils



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!