[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-28 c5b0019e10 2/2: Fix copyright-find-copyright when searching fro
From: |
Lars Ingebrigtsen |
Subject: |
emacs-28 c5b0019e10 2/2: Fix copyright-find-copyright when searching from the end |
Date: |
Wed, 26 Jan 2022 09:04:26 -0500 (EST) |
branch: emacs-28
commit c5b0019e1047d3b770611bb7dea3d2a705e56082
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Fix copyright-find-copyright when searching from the end
* 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 | 4 +++-
test/lisp/emacs-lisp/copyright-tests.el | 11 +++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/lisp/emacs-lisp/copyright.el b/lisp/emacs-lisp/copyright.el
index 23b90808d9..6b60097782 100644
--- a/lisp/emacs-lisp/copyright.el
+++ b/lisp/emacs-lisp/copyright.el
@@ -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 ()
diff --git a/test/lisp/emacs-lisp/copyright-tests.el
b/test/lisp/emacs-lisp/copyright-tests.el
index 120cd5a6b5..abb0913a0d 100644
--- a/test/lisp/emacs-lisp/copyright-tests.el
+++ b/test/lisp/emacs-lisp/copyright-tests.el
@@ -61,5 +61,16 @@
(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