]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix copyright-find-copyright when searching from the end
authorLars Ingebrigtsen <larsi@gnus.org>
Wed, 26 Jan 2022 14:02:00 +0000 (15:02 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Wed, 26 Jan 2022 14:03:56 +0000 (15:03 +0100)
* lisp/emacs-lisp/copyright.el (copyright-find-copyright): Make
the double check also work when searching from the end (bug#7179).

Do not merge to master.

lisp/emacs-lisp/copyright.el
test/lisp/emacs-lisp/copyright-tests.el

index 23b90808d9098d05a181f5dfb5d05e2ea9ac72ac..6b600977823b95b84e9d0d2aa36a2713de57bca3 100644 (file)
@@ -152,7 +152,9 @@ This function sets the match data that `copyright-update-year' uses."
         ;; copyright line, so re-perform the search without the
         ;; limit.  (Otherwise we may be inserting the new year in the
         ;; middle of the list of years.)
-        (goto-char (match-beginning 0))
+        (if copyright-at-end-flag
+            (goto-char (match-end 0))
+          (goto-char (match-beginning 0)))
         (copyright-re-search regexp nil t)))))
 
 (defun copyright-find-end ()
index 120cd5a6b5e20005db8d9a876b9f4a014cec9242..abb0913a0d79cf644f79a8932fc06cf7b48ab664 100644 (file)
         (buffer-substring (- (point-max) 42) (point-max))))
     "Copyright 2006, 2007, 2008, 2022 Foo Bar\n\n")))
 
+(ert-deftest test-correct-notice ()
+  (should (equal
+           (with-temp-buffer
+             (dotimes (_ 2)
+               (insert "Copyright 2021 FSF\n"))
+             (let ((copyright-at-end-flag t)
+                   (copyright-query nil))
+               (copyright-update))
+             (buffer-string))
+           "Copyright 2021 FSF\nCopyright 2021, 2022 FSF\n")))
+
 (provide 'copyright-tests)
 ;;; copyright-tests.el ends here