3

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?

towi
  • 21,587
  • 28
  • 106
  • 187

1 Answers1

4

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)
phils
  • 71,335
  • 11
  • 153
  • 198
  • Cool. I had no idea that you can magically hook yourself into an existing function like that. Works fine so far. – towi Mar 04 '17 at 13:53