浏览代码

Small refactoring

* lisp/org.el (org-fill-paragraph): Small refactoring.
Nicolas Goaziou 10 年之前
父节点
当前提交
d649b792c0
共有 1 个文件被更改,包括 11 次插入9 次删除
  1. 11 9
      lisp/org.el

+ 11 - 9
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