From d649b792c03b6c92bf68f382f63ba530cce6acfa Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sat, 2 Aug 2014 23:16:05 +0200 Subject: [PATCH] Small refactoring * lisp/org.el (org-fill-paragraph): Small refactoring. --- lisp/org.el | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 974bc14f0..dd4feb68d 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -22851,17 +22851,19 @@ a footnote definition, try to fill the first paragraph within." (concat "^" message-cite-prefix-regexp) end t)) (setq end (match-beginning 0)))) ;; Fill paragraph, taking line breaks into account. - ;; For that, insert hard newline characters after line - ;; breaks and activate `use-hard-newlines'. (save-excursion (goto-char beg) - (while (re-search-forward "\\\\\\\\[ \t]*\\(\n\\)" end t) - (when (eq 'line-break - (org-element-type - (progn (backward-char) - (save-match-data (org-element-context))))) - (replace-match hard-newline nil nil nil 1))) - (let ((use-hard-newlines t)) (fill-region beg end justify))) + (let ((starters (list beg))) + (while (re-search-forward "\\\\\\\\[ \t]*\\(\n\\)" end t) + (when (eq 'line-break + (org-element-type + (progn + (backward-char) + (save-match-data (org-element-context))))) + (push (point) starters))) + (dolist (s starters) + (fill-region-as-paragraph s end justify) + (setq end s)))) t))) ;; Contents of `comment-block' type elements should be ;; filled as plain text, but only if point is within block -- 2.11.4.GIT