towi
towi

Reputation: 22267

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?

Upvotes: 3

Views: 205

Answers (1)

phils
phils

Reputation: 73274

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)

Upvotes: 4

Related Questions