changeset 105201:cdc275504289

(log-edit-changelog-entries): Avoid inf-loops. Try and avoid copying twice the same paragraph. (log-edit-changelog-paragraph, log-edit-changelog-subparagraph): Remove save-excursion. (log-edit-changelog-entry): Do it here instead.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Fri, 25 Sep 2009 17:57:09 +0000
parents f9c0c73cfc74
children 8dadc895b795
files lisp/ChangeLog lisp/log-edit.el
diffstat 2 files changed, 36 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Fri Sep 25 17:40:53 2009 +0000
+++ b/lisp/ChangeLog	Fri Sep 25 17:57:09 2009 +0000
@@ -1,3 +1,11 @@
+2009-09-25  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* log-edit.el (log-edit-changelog-entries): Avoid inf-loops.
+	Try and avoid copying twice the same paragraph.
+	(log-edit-changelog-paragraph, log-edit-changelog-subparagraph):
+	Remove save-excursion.
+	(log-edit-changelog-entry): Do it here instead.
+
 2009-09-25  Juanma Barranquero  <lekktu@gmail.com>
 
 	* bs.el (bs--get-file-name): Use `list-buffers-directory'
@@ -16,8 +24,8 @@
 
 2009-09-25  Devon Sean McCullough  <emacs-hacker@Jovi.Net>
 
-	* comint.el (comint-exec, comint-run, make-comint): Doc
-	fixes (Bug#4542).
+	* comint.el (comint-exec, comint-run, make-comint):
+	Doc fixes (Bug#4542).
 
 2009-09-25  Glenn Morris  <rgm@gnu.org>
 
@@ -58,8 +66,7 @@
 	* textmodes/sgml-mode.el: Remove xml-mode alias.
 
 	* files.el (auto-mode-alist, conf-mode-maybe)
-	(magic-fallback-mode-alist): Revert 2009-09-18 and 2009-09-21
-	changes.
+	(magic-fallback-mode-alist): Revert 2009-09-18 and 2009-09-21 changes.
 
 2009-09-24  Alan Mackenzie  <acm@muc.de>
 
--- a/lisp/log-edit.el	Fri Sep 25 17:40:53 2009 +0000
+++ b/lisp/log-edit.el	Fri Sep 25 17:57:09 2009 +0000
@@ -560,23 +560,21 @@
 (defun log-edit-changelog-paragraph ()
   "Return the bounds of the ChangeLog paragraph containing point.
 If we are between paragraphs, return the previous paragraph."
-  (save-excursion
-    (beginning-of-line)
-    (if (looking-at "^[ \t]*$")
-        (skip-chars-backward " \t\n" (point-min)))
-    (list (progn
-            (if (re-search-backward "^[ \t]*\n" nil 'or-to-limit)
-                (goto-char (match-end 0)))
-            (point))
-          (if (re-search-forward "^[ \t\n]*$" nil t)
-              (match-beginning 0)
-            (point-max)))))
+  (beginning-of-line)
+  (if (looking-at "^[ \t]*$")
+      (skip-chars-backward " \t\n" (point-min)))
+  (list (progn
+          (if (re-search-backward "^[ \t]*\n" nil 'or-to-limit)
+              (goto-char (match-end 0)))
+          (point))
+        (if (re-search-forward "^[ \t\n]*$" nil t)
+            (match-beginning 0)
+          (point-max))))
 
 (defun log-edit-changelog-subparagraph ()
   "Return the bounds of the ChangeLog subparagraph containing point.
 A subparagraph is a block of non-blank lines beginning with an asterisk.
 If we are between sub-paragraphs, return the previous subparagraph."
-  (save-excursion
     (end-of-line)
     (if (search-backward "*" nil t)
         (list (progn (beginning-of-line) (point))
@@ -585,16 +583,17 @@
                 (if (re-search-forward "^[ \t]*[\n*]" nil t)
                     (match-beginning 0)
                   (point-max))))
-      (list (point) (point)))))
+    (list (point) (point))))
 
 (defun log-edit-changelog-entry ()
   "Return the bounds of the ChangeLog entry containing point.
 The variable `log-edit-changelog-full-paragraphs' decides whether an
 \"entry\" is a paragraph or a subparagraph; see its documentation string
 for more details."
-  (if log-edit-changelog-full-paragraphs
-      (log-edit-changelog-paragraph)
-    (log-edit-changelog-subparagraph)))
+  (save-excursion
+    (if log-edit-changelog-full-paragraphs
+        (log-edit-changelog-paragraph)
+      (log-edit-changelog-subparagraph))))
 
 (defvar user-full-name)
 (defvar user-mail-address)
@@ -663,11 +662,17 @@
                                   pattern
                                   "\\($\\|[^[:alnum:]]\\)"))
 
-	    (let (texts)
-	      (while (re-search-forward pattern nil t)
+	    (let (texts
+                  (pos (point)))
+	      (while (and (not (eobp)) (re-search-forward pattern nil t))
 		(let ((entry (log-edit-changelog-entry)))
-		  (push entry texts)
-		  (goto-char (elt entry 1))))
+                  (if (< (elt entry 1) (max (1+ pos) (point)))
+                      ;; This is not relevant, actually.
+                      nil
+                    (push entry texts))
+                  ;; Make sure we make progress.
+                  (setq pos (max (1+ pos) (elt entry 1)))
+		  (goto-char pos)))
 
 	      (cons (current-buffer) texts))))))))