summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorGlenn Morris <rgm@gnu.org>2008-02-22 03:52:44 +0000
committerGlenn Morris <rgm@gnu.org>2008-02-22 03:52:44 +0000
commitce12d620cfbfae7943bb048ffb7d5123590c8888 (patch)
tree909a7e54520d72d1a91ea92a7988d2f8a7edf73e /lisp
parentae34ef746f879c78e00d6f6caec111ccb43b49be (diff)
downloademacs-ce12d620cfbfae7943bb048ffb7d5123590c8888.tar.gz
emacs-ce12d620cfbfae7943bb048ffb7d5123590c8888.tar.bz2
emacs-ce12d620cfbfae7943bb048ffb7d5123590c8888.zip
(copyright-update-year): Fix subexpression numbering for the case when
years are split over lines, and for the replace case.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/emacs-lisp/copyright.el10
1 files changed, 7 insertions, 3 deletions
diff --git a/lisp/emacs-lisp/copyright.el b/lisp/emacs-lisp/copyright.el
index 55acb423e7b..b3e0307a519 100644
--- a/lisp/emacs-lisp/copyright.el
+++ b/lisp/emacs-lisp/copyright.el
@@ -94,6 +94,8 @@ When this is `function', only ask when called non-interactively."
(defun copyright-update-year (replace noquery)
(when
(condition-case err
+ ;; (1) Need the extra \\( \\) around copyright-regexp because we
+ ;; goto (match-end 1) below. See note (2) below.
(re-search-forward (concat "\\(" copyright-regexp
"\\)\\([ \t]*\n\\)?.*\\(?:"
copyright-names-regexp "\\)")
@@ -104,7 +106,7 @@ When this is `function', only ask when called non-interactively."
;; such an error is very inconvenient for the user.
(error (message "Can't update copyright: %s" err) nil))
(goto-char (match-end 1))
- ;; If the years are continued onto multiple lined
+ ;; If the years are continued onto multiple lines
;; that are marked as comments, skip to the end of the years anyway.
(while (save-excursion
(and (eq (following-char) ?,)
@@ -119,7 +121,9 @@ When this is `function', only ask when called non-interactively."
(looking-at copyright-years-regexp))))
(forward-line 1)
(re-search-forward comment-start-skip)
- (re-search-forward copyright-years-regexp))
+ ;; (2) Need the extra \\( \\) so that the years are subexp 3, as
+ ;; they are at note (1) above.
+ (re-search-forward (format "\\(%s\\)" copyright-years-regexp)))
;; Note that `current-time-string' isn't locale-sensitive.
(setq copyright-current-year (substring (current-time-string) -4))
@@ -132,7 +136,7 @@ When this is `function', only ask when called non-interactively."
(concat "Add " copyright-current-year
" to copyright? "))))
(if replace
- (replace-match copyright-current-year t t nil 2)
+ (replace-match copyright-current-year t t nil 3)
(let ((size (save-excursion (skip-chars-backward "0-9"))))
(if (and (eq (% (- (string-to-number copyright-current-year)
(string-to-number (buffer-substring