Browse Source

Small refactoring

* lisp/org.el (org-fill-paragraph): Avoid calling
  `fill-region-as-paragraph' if BEG is equal to END.
Nicolas Goaziou 10 years ago
parent
commit
381ad4b33a
1 changed files with 8 additions and 9 deletions
  1. 8 9
      lisp/org.el

+ 8 - 9
lisp/org.el

@@ -22853,17 +22853,16 @@ a footnote definition, try to fill the first paragraph within."
 	       ;; Fill paragraph, taking line breaks into account.
 	       (save-excursion
 		 (goto-char beg)
-		 (let ((starters (list beg)))
-		   (while (re-search-forward "\\\\\\\\[ \t]*\\(\n\\)" end t)
+		 (let ((cuts (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))))
+				(save-excursion (backward-char)
+						(org-element-context))))
+		       (push (point) cuts)))
+		   (dolist (c (delq end cuts))
+		     (fill-region-as-paragraph c end justify)
+		     (setq end c))))
 	       t)))
 	  ;; Contents of `comment-block' type elements should be
 	  ;; filled as plain text, but only if point is within block