aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2007-05-25 16:58:18 +0000
committerStefan Monnier2007-05-25 16:58:18 +0000
commitb649d2e482f5120b532c27ba5aca85b560d4a514 (patch)
tree045441a08e2765e2a9db95bdec0312d28dda329d
parent6db93fd915892fe3da1b8910a33120378b094240 (diff)
downloademacs-b649d2e482f5120b532c27ba5aca85b560d4a514.tar.gz
emacs-b649d2e482f5120b532c27ba5aca85b560d4a514.zip
(copyright-names-regexp): New var.
(copyright-update-year): Use it.
-rw-r--r--etc/NEWS4
-rw-r--r--lisp/ChangeLog3
-rw-r--r--lisp/emacs-lisp/copyright.el33
3 files changed, 32 insertions, 8 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 9d32a7034a9..780dea787f9 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -34,6 +34,10 @@ with a prefix argument or by typing C-u C-h C-n.
34 34
35* Changes in Specialized Modes and Packages in Emacs 23.1 35* Changes in Specialized Modes and Packages in Emacs 23.1
36 36
37** In the `copyright' package, you can specify your copyright holders's names.
38Only copyright lines with holders matching copyright-names-regexp will be
39considered for update.
40
37 41
38* Changes in Emacs 23.1 on non-free operating systems 42* Changes in Emacs 23.1 on non-free operating systems
39 43
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 22b03a99290..6b55cb97ab2 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,8 @@
12007-05-25 Stefan Monnier <monnier@iro.umontreal.ca> 12007-05-25 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * emacs-lisp/copyright.el (copyright-names-regexp): New var.
4 (copyright-update-year): Use it.
5
3 * edmacro.el (edmacro-format-keys): Use current-active-maps. 6 * edmacro.el (edmacro-format-keys): Use current-active-maps.
4 7
5 * ediff-init.el (ediff-defvar-local, ediff-with-current-buffer): 8 * ediff-init.el (ediff-defvar-local, ediff-with-current-buffer):
diff --git a/lisp/emacs-lisp/copyright.el b/lisp/emacs-lisp/copyright.el
index 5f5aecea97a..ac61c5a9ada 100644
--- a/lisp/emacs-lisp/copyright.el
+++ b/lisp/emacs-lisp/copyright.el
@@ -37,7 +37,7 @@
37 :group 'tools) 37 :group 'tools)
38 38
39(defcustom copyright-limit 2000 39(defcustom copyright-limit 2000
40 "*Don't try to update copyright beyond this position unless interactive. 40 "Don't try to update copyright beyond this position unless interactive.
41A value of nil means to search whole buffer." 41A value of nil means to search whole buffer."
42 :group 'copyright 42 :group 'copyright
43 :type '(choice (integer :tag "Limit") 43 :type '(choice (integer :tag "Limit")
@@ -49,21 +49,28 @@ A value of nil means to search whole buffer."
49 "\\([]\\|@copyright{}\\|[Cc]opyright\\s *:?\\s *\\(?:(C)\\)?\ 49 "\\([]\\|@copyright{}\\|[Cc]opyright\\s *:?\\s *\\(?:(C)\\)?\
50\\|[Cc]opyright\\s *:?\\s *[]\\)\ 50\\|[Cc]opyright\\s *:?\\s *[]\\)\
51\\s *\\([1-9]\\([-0-9, ';/*%#\n\t]\\|\\s<\\|\\s>\\)*[0-9]+\\)" 51\\s *\\([1-9]\\([-0-9, ';/*%#\n\t]\\|\\s<\\|\\s>\\)*[0-9]+\\)"
52 "*What your copyright notice looks like. 52 "What your copyright notice looks like.
53The second \\( \\) construct must match the years." 53The second \\( \\) construct must match the years."
54 :group 'copyright 54 :group 'copyright
55 :type 'regexp) 55 :type 'regexp)
56 56
57(defcustom copyright-names-regexp ""
58 "Regexp matching the names which correspond to the user.
59Only copyright lines where the name matches this regexp will be updated.
60This allows you to avoid adding yars to a copyright notice belonging to
61someone else or to a group for which you do not work."
62 :type 'regexp)
63
57(defcustom copyright-years-regexp 64(defcustom copyright-years-regexp
58 "\\(\\s *\\)\\([1-9]\\([-0-9, ';/*%#\n\t]\\|\\s<\\|\\s>\\)*[0-9]+\\)" 65 "\\(\\s *\\)\\([1-9]\\([-0-9, ';/*%#\n\t]\\|\\s<\\|\\s>\\)*[0-9]+\\)"
59 "*Match additional copyright notice years. 66 "Match additional copyright notice years.
60The second \\( \\) construct must match the years." 67The second \\( \\) construct must match the years."
61 :group 'copyright 68 :group 'copyright
62 :type 'regexp) 69 :type 'regexp)
63 70
64 71
65(defcustom copyright-query 'function 72(defcustom copyright-query 'function
66 "*If non-nil, ask user before changing copyright. 73 "If non-nil, ask user before changing copyright.
67When this is `function', only ask when called non-interactively." 74When this is `function', only ask when called non-interactively."
68 :group 'copyright 75 :group 'copyright
69 :type '(choice (const :tag "Do not ask") 76 :type '(choice (const :tag "Do not ask")
@@ -83,7 +90,17 @@ When this is `function', only ask when called non-interactively."
83 "String representing the current year.") 90 "String representing the current year.")
84 91
85(defun copyright-update-year (replace noquery) 92(defun copyright-update-year (replace noquery)
86 (when (re-search-forward copyright-regexp (+ (point) copyright-limit) t) 93 (when
94 (condition-case err
95 (re-search-forward (concat "\\(" copyright-regexp
96 "\\)\\([ \t]*\n\\)?.*\\(?:"
97 copyright-names-regexp "\\)")
98 (+ (point) copyright-limit) t)
99 ;; In case the regexp is rejected. This is useful because
100 ;; copyright-update is typically called from before-save-hook where
101 ;; such an error is very inconvenient for the user.
102 (error (message "Can't update copyright: %s" err) nil))
103 (goto-char (match-end 1))
87 ;; If the years are continued onto multiple lined 104 ;; If the years are continued onto multiple lined
88 ;; that are marked as comments, skip to the end of the years anyway. 105 ;; that are marked as comments, skip to the end of the years anyway.
89 (while (save-excursion 106 (while (save-excursion
@@ -94,7 +111,7 @@ When this is `function', only ask when called non-interactively."
94 (save-match-data 111 (save-match-data
95 (forward-line 1) 112 (forward-line 1)
96 (and (looking-at comment-start-skip) 113 (and (looking-at comment-start-skip)
97 (goto-char (match-end 0)))) 114 (goto-char (match-end 1))))
98 (save-match-data 115 (save-match-data
99 (looking-at copyright-years-regexp)))) 116 (looking-at copyright-years-regexp))))
100 (forward-line 1) 117 (forward-line 1)
@@ -103,7 +120,7 @@ When this is `function', only ask when called non-interactively."
103 120
104 ;; Note that `current-time-string' isn't locale-sensitive. 121 ;; Note that `current-time-string' isn't locale-sensitive.
105 (setq copyright-current-year (substring (current-time-string) -4)) 122 (setq copyright-current-year (substring (current-time-string) -4))
106 (unless (string= (buffer-substring (- (match-end 2) 2) (match-end 2)) 123 (unless (string= (buffer-substring (- (match-end 3) 2) (match-end 3))
107 (substring copyright-current-year -2)) 124 (substring copyright-current-year -2))
108 (if (or noquery 125 (if (or noquery
109 (y-or-n-p (if replace 126 (y-or-n-p (if replace
@@ -235,5 +252,5 @@ Uses heuristic: year >= 50 means 19xx, < 50 means 20xx."
235;; coding: emacs-mule 252;; coding: emacs-mule
236;; End: 253;; End:
237 254
238;;; arch-tag: b4991afb-b6b1-4590-bebe-e076d9d4aee8 255;; arch-tag: b4991afb-b6b1-4590-bebe-e076d9d4aee8
239;;; copyright.el ends here 256;;; copyright.el ends here