(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.
This commit is contained in:
Stefan Monnier 2009-09-25 17:57:09 +00:00
parent 4ff670a8b8
commit 8390fb808b
2 changed files with 36 additions and 24 deletions

View file

@ -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>

View file

@ -560,23 +560,21 @@ A \"page\" in a ChangeLog file is the area between two dates."
(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 we are between sub-paragraphs, return the previous subparagraph."
(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 @@ where LOGBUFFER is the name of the ChangeLog buffer, and each
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))))))))