Mercurial > emacs
comparison lisp/emacs-lisp/copyright.el @ 82447:7206375cd8a6
(copyright-limit): New defsubst.
(copyright-update-year, copyright-update)
(copyright-fix-years): Use it.
author | Thien-Thi Nguyen <ttn@gnuvola.org> |
---|---|
date | Fri, 17 Aug 2007 22:05:52 +0000 |
parents | 8bed2c8a10f1 |
children | 786b4b5a733e |
comparison
equal
deleted
inserted
replaced
82446:643ae46953f2 | 82447:7206375cd8a6 |
---|---|
88 ;; This is a defvar rather than a defconst, because the year can | 88 ;; This is a defvar rather than a defconst, because the year can |
89 ;; change during the Emacs session. | 89 ;; change during the Emacs session. |
90 (defvar copyright-current-year (substring (current-time-string) -4) | 90 (defvar copyright-current-year (substring (current-time-string) -4) |
91 "String representing the current year.") | 91 "String representing the current year.") |
92 | 92 |
93 (defsubst copyright-limit () ; re-search-forward BOUND | |
94 (or (not copyright-limit) | |
95 (+ (point) copyright-limit))) | |
96 | |
93 (defun copyright-update-year (replace noquery) | 97 (defun copyright-update-year (replace noquery) |
94 (when | 98 (when |
95 (condition-case err | 99 (condition-case err |
96 (re-search-forward (concat "\\(" copyright-regexp | 100 (re-search-forward (concat "\\(" copyright-regexp |
97 "\\)\\([ \t]*\n\\)?.*\\(?:" | 101 "\\)\\([ \t]*\n\\)?.*\\(?:" |
98 copyright-names-regexp "\\)") | 102 copyright-names-regexp "\\)") |
99 (if copyright-limit | 103 (copyright-limit) |
100 (+ (point) copyright-limit) | |
101 t) | |
102 t) | 104 t) |
103 ;; In case the regexp is rejected. This is useful because | 105 ;; In case the regexp is rejected. This is useful because |
104 ;; copyright-update is typically called from before-save-hook where | 106 ;; copyright-update is typically called from before-save-hook where |
105 ;; such an error is very inconvenient for the user. | 107 ;; such an error is very inconvenient for the user. |
106 (error (message "Can't update copyright: %s" err) nil)) | 108 (error (message "Can't update copyright: %s" err) nil)) |
182 ;; bilingual Esperanto one in two-column, and in texinfo.tex | 184 ;; bilingual Esperanto one in two-column, and in texinfo.tex |
183 (re-search-forward | 185 (re-search-forward |
184 "\\(the Free Software Foundation;\ | 186 "\\(the Free Software Foundation;\ |
185 either \\|; a\\^u eldono \\([0-9]+\\)a, ? a\\^u (la\\^u via \\)\ | 187 either \\|; a\\^u eldono \\([0-9]+\\)a, ? a\\^u (la\\^u via \\)\ |
186 version \\([0-9]+\\), or (at" | 188 version \\([0-9]+\\), or (at" |
187 (if copyright-limit (+ (point) copyright-limit)) t) | 189 (copyright-limit) t) |
188 (not (string= (match-string 3) copyright-current-gpl-version)) | 190 (not (string= (match-string 3) copyright-current-gpl-version)) |
189 (or noquery | 191 (or noquery |
190 (y-or-n-p (concat "Replace GPL version by " | 192 (y-or-n-p (concat "Replace GPL version by " |
191 copyright-current-gpl-version "? "))) | 193 copyright-current-gpl-version "? "))) |
192 (progn | 194 (progn |
204 "Convert 2 digit years to 4 digit years. | 206 "Convert 2 digit years to 4 digit years. |
205 Uses heuristic: year >= 50 means 19xx, < 50 means 20xx." | 207 Uses heuristic: year >= 50 means 19xx, < 50 means 20xx." |
206 (interactive) | 208 (interactive) |
207 (widen) | 209 (widen) |
208 (goto-char (point-min)) | 210 (goto-char (point-min)) |
209 (if (re-search-forward copyright-regexp | 211 (if (re-search-forward copyright-regexp (copyright-limit) t) |
210 (if copyright-limit (+ (point) copyright-limit)) t) | |
211 (let ((s (match-beginning 2)) | 212 (let ((s (match-beginning 2)) |
212 (e (copy-marker (1+ (match-end 2)))) | 213 (e (copy-marker (1+ (match-end 2)))) |
213 (p (make-marker)) | 214 (p (make-marker)) |
214 last) | 215 last) |
215 (goto-char s) | 216 (goto-char s) |