emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 5ade22c: Fix an unlikely `copyright-find-copyright' problem


From: Lars Ingebrigtsen
Subject: master 5ade22c: Fix an unlikely `copyright-find-copyright' problem
Date: Sun, 18 Jul 2021 08:31:18 -0400 (EDT)

branch: master
commit 5ade22c2f89f85883232875c63fda70bb0a75c0d
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Fix an unlikely `copyright-find-copyright' problem
    
    * lisp/emacs-lisp/copyright.el (copyright-find-copyright): Make
    the copyright matcher more robust (bug#7179).
---
 lisp/emacs-lisp/copyright.el | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/lisp/emacs-lisp/copyright.el b/lisp/emacs-lisp/copyright.el
index 6ba2e78..d2e4891 100644
--- a/lisp/emacs-lisp/copyright.el
+++ b/lisp/emacs-lisp/copyright.el
@@ -144,11 +144,16 @@ This function sets the match-data that 
`copyright-update-year' uses."
   (with-demoted-errors "Can't update copyright: %s"
     ;; (1) Need the extra \\( \\) around copyright-regexp because we
     ;; goto (match-end 1) below. See note (2) below.
-    (copyright-re-search (concat "\\(" copyright-regexp
-                                "\\)\\([ \t]*\n\\)?.*\\(?:"
-                                copyright-names-regexp "\\)")
-                        (copyright-limit)
-                        t)))
+    (let ((regexp (concat "\\(" copyright-regexp
+                         "\\)\\([ \t]*\n\\)?.*\\(?:"
+                         copyright-names-regexp "\\)")))
+      (when (copyright-re-search regexp (copyright-limit) t)
+        ;; We may accidentally have landed in the middle of a
+        ;; copyright line, so re-perform the search without the
+        ;; search.  (Otherwise we may be inserting the new year in the
+        ;; middle of the list of years.)
+        (goto-char (match-beginning 0))
+        (copyright-re-search regexp nil t)))))
 
 (defun copyright-find-end ()
   "Possibly adjust the search performed by `copyright-find-copyright'.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]