Mercurial > emacs
annotate lisp/emacs-lisp/authors.el @ 32654:ff2336f92cd0
*** empty log message ***
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Thu, 19 Oct 2000 10:46:51 +0000 |
parents | efaa4e4c5fef |
children | 1ce7dce8710b |
rev | line source |
---|---|
30790 | 1 ;;; authors.el --- utility for maintaining Emacs' AUTHORS file |
2 | |
3 ;; Copyright (C) 2000 Free Software Foundation, Inc. | |
4 | |
5 ;; This file is part of GNU Emacs. | |
6 | |
7 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
8 ;; it under the terms of the GNU General Public License as published by | |
9 ;; the Free Software Foundation; either version 2, or (at your option) | |
10 ;; any later version. | |
11 | |
12 ;; GNU Emacs is distributed in the hope that it will be useful, | |
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 ;; GNU General Public License for more details. | |
16 | |
17 ;; You should have received a copy of the GNU General Public License | |
18 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
19 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
20 ;; Boston, MA 02111-1307, USA. | |
21 | |
22 ;;; Commentary: | |
23 | |
24 ;; Use M-x authors RET to create an *Authors* buffer that can used as | |
25 ;; or merged with Emacs' AUTHORS file. | |
26 | |
27 ;;; Code: | |
28 | |
29 (defconst authors-many-files 20 | |
30 "Maximum number of files for which to print individual information. | |
31 If an author has modified more files, only a single entry is | |
32 printed telling how many files he changed, instead of listing each | |
33 file individually.") | |
34 | |
35 (defconst authors-aliases | |
36 '(("eliz" . "Eli Zaretskii") | |
37 ("Richard Stallman" . "Richard M. Stallman") | |
38 ("Richard M. Stallman,,," . "Richard M. Stallman") | |
39 ("Richard Stallmao" . "Richard M. Stallman") | |
40 ("rms@gnu.org" . "Richard M. Stallman") | |
41 ("NIIBE Yutaka" . "Yutaka NIIBE") | |
42 ("(saw@cebaf.gov)" . "Stephen A. Wood") | |
43 ("(pmr@legacy.pajato.com)" . "Paul Reilly") | |
44 ("(Eric Youngdale at youngdale@v6550c.nrl.navy.mil)" . "Eric Youngdale") | |
45 ("<Daniel.Pfeiffer@Informatik.START.db.de>" . "Daniel Pfeiffer") | |
46 ("<Daniel.Pfeiffer@Informatik.START.dbp.de>" . "Daniel Pfeiffer") | |
47 ("(afs@hplb.hpl.hp.com)" . "ignore") | |
48 ("<Use-Author-Address-Header@\\[127.1\\]>" . "ignore") | |
49 ("Code Extracted" . "ignore") | |
50 ("Fsf" . "ignore") | |
51 ("David M. Koppelman, Koppel@Ee.Lsu.Edu" . "David M. Koppelman") | |
52 ("jka@ece.cmu.edu" . "Jay K. Adams") | |
53 ("Per Abhiddenware; you can redistribute it and/or modify" . "Per Abrahamsen") | |
54 ("Andrw Innes" . "Andrew Innes") | |
55 ("Barry Warsaw" . "Barry A. Warsaw") | |
56 ("Barry A. Warsaw, Century Computing, Inc." . "Barry A. Warsaw") | |
57 ("Barry A. Warsaw, ITB" . "Barry A. Warsaw") | |
58 ("Ken'ichi Handa" . "Kenichi Handa") | |
59 ("Bob Chassell" . "Robert J. Chassell") | |
60 ("SL Baur" . "Steven L. Baur") | |
61 ("Steven L Baur" . "Steven L. Baur") | |
62 ("eggert" . "Paul Eggert") | |
63 ("voelker" . "Geoff Voelker") | |
64 ("rms" . "Richard M. Stallman") | |
65 ("Edward M Reingold" . "Edward M. Reingold") | |
66 ("Eric Ludlam" . "Eric M. Ludlam") | |
67 ("Eric Raymond" . "Eric S. Raymond") | |
68 ("Francois Pinard" . "François Pinard") | |
69 ("Fred Pierresteguy" . "Frederic Pierresteguy") | |
70 ("Hallvard B Furuseth" . "Hallvard B. Furuseth") | |
71 ("ISO-2022-JP" . "ignore") | |
72 ("Jens-Ulrik Petersen" . "Jens-Ulrik Holger Petersen") | |
73 ("Christoph.Wedler@sap.com" . "Christoph Wedler") | |
74 ("Jonathan Kamens" . "Jonathan I. Kamens") | |
75 ("Kim Storm" . "Kim F. Storm") | |
76 ("Marcus Daniels" . "Marcus G. Daniels") | |
77 ("Michael I Bushnell" . "Michael I. Bushnell") | |
78 ("Michael I. Bushnell, P/Bsg" . "Michael I. Bushnell") | |
79 ("Reingold Edward M" . "Edward M. Reingold") | |
80 ("Roland B Roberts" . "Roland B. Roberts") | |
81 ("Sam Shteingold" . "Sam Steingold") | |
82 ("Kenichi HANDA" . "Kenichi Handa")) | |
83 "Alist of author aliases. | |
84 | |
85 Each entry is of the form (REGEXP . ALIAS). If an author's name | |
86 matches REGEXP, use ALIAS instead. The special alias \"ignore\" means | |
87 ignore that author.") | |
88 | |
89 | |
32028
1bb0e9c9c64d
(authors-obsolete-file-p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
32005
diff
changeset
|
90 (defvar authors-obsolete-files-regexps |
1bb0e9c9c64d
(authors-obsolete-file-p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
32005
diff
changeset
|
91 '("vc-\\*\\.el$" |
1bb0e9c9c64d
(authors-obsolete-file-p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
32005
diff
changeset
|
92 "spec.txt$" |
1bb0e9c9c64d
(authors-obsolete-file-p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
32005
diff
changeset
|
93 "vc-\\(rcs\\|cvs\\|sccs\\)-hooks\\.el$") |
1bb0e9c9c64d
(authors-obsolete-file-p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
32005
diff
changeset
|
94 "List of regexps matching obsolete files. |
1bb0e9c9c64d
(authors-obsolete-file-p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
32005
diff
changeset
|
95 Changes to files matching one of the regexps in this list are not |
1bb0e9c9c64d
(authors-obsolete-file-p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
32005
diff
changeset
|
96 listed.") |
1bb0e9c9c64d
(authors-obsolete-file-p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
32005
diff
changeset
|
97 |
1bb0e9c9c64d
(authors-obsolete-file-p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
32005
diff
changeset
|
98 |
1bb0e9c9c64d
(authors-obsolete-file-p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
32005
diff
changeset
|
99 (defun authors-obsolete-file-p (file) |
1bb0e9c9c64d
(authors-obsolete-file-p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
32005
diff
changeset
|
100 "Return non-nil if FILE is obsolete. |
1bb0e9c9c64d
(authors-obsolete-file-p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
32005
diff
changeset
|
101 FILE is considered obsolete if it matches on of the regular expressions |
1bb0e9c9c64d
(authors-obsolete-file-p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
32005
diff
changeset
|
102 from `authors-obsolete-files-regexps'." |
1bb0e9c9c64d
(authors-obsolete-file-p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
32005
diff
changeset
|
103 (let (obsolete-p |
1bb0e9c9c64d
(authors-obsolete-file-p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
32005
diff
changeset
|
104 (regexps authors-obsolete-files-regexps)) |
1bb0e9c9c64d
(authors-obsolete-file-p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
32005
diff
changeset
|
105 (while (and regexps (not obsolete-p)) |
1bb0e9c9c64d
(authors-obsolete-file-p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
32005
diff
changeset
|
106 (setq obsolete-p (string-match (car regexps) file) |
1bb0e9c9c64d
(authors-obsolete-file-p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
32005
diff
changeset
|
107 regexps (cdr regexps))) |
1bb0e9c9c64d
(authors-obsolete-file-p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
32005
diff
changeset
|
108 obsolete-p)) |
1bb0e9c9c64d
(authors-obsolete-file-p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
32005
diff
changeset
|
109 |
1bb0e9c9c64d
(authors-obsolete-file-p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
32005
diff
changeset
|
110 |
30790 | 111 (defun authors-add (author file action table) |
112 "Record that AUTHOR worked on FILE. | |
113 ACTION is a keyword symbol describing what he did. Record file, | |
114 author and what he did in hash table TABLE. See the description of | |
115 `authors-scan-change-log' for the structure of the hash table." | |
32529
efaa4e4c5fef
(authors-add): Don't add an entry if
Gerd Moellmann <gerd@gnu.org>
parents:
32028
diff
changeset
|
116 (unless (or (authors-obsolete-file-p file) |
efaa4e4c5fef
(authors-add): Don't add an entry if
Gerd Moellmann <gerd@gnu.org>
parents:
32028
diff
changeset
|
117 (equal author "")) |
32028
1bb0e9c9c64d
(authors-obsolete-file-p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
32005
diff
changeset
|
118 (let* ((value (gethash author table)) |
1bb0e9c9c64d
(authors-obsolete-file-p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
32005
diff
changeset
|
119 (entry (assoc file value))) |
1bb0e9c9c64d
(authors-obsolete-file-p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
32005
diff
changeset
|
120 (if (null entry) |
1bb0e9c9c64d
(authors-obsolete-file-p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
32005
diff
changeset
|
121 (puthash author (cons (list file action) value) table) |
1bb0e9c9c64d
(authors-obsolete-file-p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
32005
diff
changeset
|
122 (unless (memq action entry) |
1bb0e9c9c64d
(authors-obsolete-file-p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
32005
diff
changeset
|
123 (nconc entry (list action))))))) |
30790 | 124 |
125 | |
126 (defun authors-process-lines (program &rest args) | |
127 "Execute PROGRAM with ARGS, returning its output as a list of lines. | |
128 Signal an error if the program returns with a non-zero exit status." | |
129 (with-temp-buffer | |
130 (let ((status (apply 'call-process program nil (current-buffer) nil args))) | |
131 (unless (eq status 0) | |
132 (error "%s exited with status %s" program status)) | |
133 (goto-char (point-min)) | |
134 (let (lines) | |
135 (while (not (eobp)) | |
136 (setq lines (cons (buffer-substring-no-properties | |
137 (line-beginning-position) | |
138 (line-end-position)) | |
139 lines)) | |
140 (forward-line 1)) | |
141 (nreverse lines))))) | |
142 | |
143 | |
144 (defun authors-canonical-author-name (author) | |
145 "Return a canonicalized form of AUTHOR, an author name. | |
146 If AUTHOR has an alias, use that. Remove email addresses. Capitalize | |
147 words in the author's name." | |
148 (let ((aliases authors-aliases)) | |
149 (while aliases | |
150 (when (string-match (car (car aliases)) author) | |
151 (setq author (cdr (car aliases)) | |
152 aliases nil)) | |
153 (setq aliases (cdr aliases)))) | |
154 (setq author (replace-regexp-in-string "[ \t]*[(<].*$" "" author)) | |
155 (setq author (replace-regexp-in-string "^[ \t]+" "" author)) | |
156 (setq author (replace-regexp-in-string "[ \t]+$" "" author)) | |
157 (capitalize author)) | |
158 | |
159 | |
160 (defun authors-scan-change-log (file table) | |
161 "Scan change log FILE for author information. | |
162 | |
163 For each change mentioned in the log, add an entry to hash table TABLE | |
164 under the author's canonical name. | |
165 | |
166 Keys of TABLE are author names. Values are alists of entries (FILE | |
167 ACTION...). FILE is one file the author worked on. The rest of the | |
168 entry is a list of keyword symbols describing what he did with the | |
169 file. | |
170 | |
171 :wrote means the author wrote the file | |
172 :changed means he changed the file." | |
173 | |
174 (let* ((enable-local-variables t) | |
175 (enable-local-eval t) | |
176 (existing-buffer (get-file-buffer file)) | |
177 (buffer (find-file-noselect file)) | |
178 author) | |
179 (save-excursion | |
180 (set-buffer buffer) | |
181 (save-restriction | |
182 (widen) | |
183 (goto-char (point-min)) | |
184 (while (re-search-forward "^[0-9]\\|^[ \t]+\\* " nil t) | |
185 (beginning-of-line) | |
186 (cond ((looking-at "^[0-9]+-[0-9]+-[0-9]+") | |
187 (skip-chars-forward " \t+:0-9-") | |
188 (setq author (buffer-substring-no-properties | |
189 (point) (line-end-position))) | |
190 (setq author (authors-canonical-author-name author)) | |
191 (forward-line 1)) | |
192 ((looking-at "^[ \t]+\\*") | |
193 (let ((line (buffer-substring-no-properties | |
194 (match-end 0) (line-end-position)))) | |
195 (while (and (not (string-match ":" line)) | |
196 (forward-line 1) | |
197 (not (looking-at ":\\|^[ \t]*$"))) | |
198 (setq line (concat line | |
199 (buffer-substring-no-properties | |
200 (line-beginning-position) | |
201 (line-end-position))))) | |
202 (when (string-match ":" line) | |
203 (setq line (substring line 0 (match-beginning 0))) | |
204 (setq line (replace-regexp-in-string "[[(<{].*$" "" line)) | |
205 (setq line (replace-regexp-in-string "," "" line)) | |
206 (dolist (file (split-string line)) | |
207 (setq file (file-name-nondirectory file)) | |
208 ;(message "%s changed %s" author file) | |
209 (authors-add author file :changed table))) | |
210 (forward-line 1))))))) | |
211 (unless existing-buffer | |
212 (kill-buffer buffer)))) | |
213 | |
214 | |
215 (defun authors-scan-el (file table) | |
216 "Scan Lisp file FILE for author information. | |
217 TABLE is a hash table to add author information to." | |
218 (let* ((existing-buffer (get-file-buffer file)) | |
219 (enable-local-variables t) | |
220 (enable-local-eval t) | |
221 (buffer (find-file-noselect file))) | |
222 (save-excursion | |
223 (set-buffer buffer) | |
224 (save-restriction | |
225 (widen) | |
226 (goto-char (point-min)) | |
227 (while (and (re-search-forward | |
228 "^;+[ \t]*\\(Author\\|Commentary\\):[ \t]*" nil t) | |
229 (not (string= (match-string 1) "Commentary"))) | |
230 ;; Some entries contain a year range in front of the | |
231 ;; author's name. | |
232 (skip-chars-forward "-0-9 \t") | |
233 (let ((author (buffer-substring-no-properties | |
234 (point) (line-end-position)))) | |
235 (setq author (authors-canonical-author-name author)) | |
236 (setq file (file-name-nondirectory file)) | |
237 (authors-add author file :wrote table))))) | |
238 (unless existing-buffer | |
239 (kill-buffer buffer)))) | |
240 | |
241 | |
242 (defun authors-print (author changes) | |
243 "Insert information about AUTHOR's work on Emacs into the current buffer. | |
244 CHANGES is an alist of entries (FILE ACTION...), as produced by | |
245 `authors-scan-change-log'." | |
246 (unless (equal author "Ignore") | |
247 (let ((nchanged 0)) | |
248 (dolist (change changes) | |
249 (let ((actions (cdr change)) | |
250 (file (car change))) | |
251 (if (memq :wrote actions) | |
252 (insert author " (wrote) " file "\n") | |
253 (setq nchanged (1+ nchanged))))) | |
254 (if (> nchanged authors-many-files) | |
32005
01a7fea88dc1
(authors-print): Rephrase many-files string.
Miles Bader <miles@gnu.org>
parents:
31957
diff
changeset
|
255 (insert author " (changed) [more than " |
30790 | 256 (int-to-string authors-many-files) " files]\n") |
257 (dolist (change changes) | |
258 (let ((actions (cdr change)) | |
259 (file (car change))) | |
260 (unless (memq :wrote actions) | |
261 (insert author " (changed) " file "\n")))))))) | |
262 | |
263 | |
264 ;;;###autoload | |
265 (defun authors (root) | |
266 "Extract author information from change logs and Lisp source files. | |
267 ROOT is the root directory under which to find the files. If called | |
268 interactively, ROOT is read from the minibuffer. Result is a | |
269 buffer *Authors* containing authorship information." | |
270 (interactive "DEmacs source directory: ") | |
271 (let ((logs (authors-process-lines "find" root "-name" "ChangeLog*")) | |
272 (table (make-hash-table :test 'equal)) | |
273 (buffer-name "*Authors*")) | |
274 (setq root (expand-file-name root)) | |
275 (unless (file-exists-p (expand-file-name "src/emacs.c" root)) | |
276 (error "Not the root directory of Emacs: %s" root)) | |
277 (dolist (log logs) | |
278 (when (string-match "ChangeLog\\(.[0-9]+\\)?$" log) | |
279 (message "Scanning %s..." log) | |
280 (authors-scan-change-log log table))) | |
281 (let ((els (authors-process-lines "find" root "-name" "*.el"))) | |
282 (dolist (file els) | |
283 (message "Scanning %s..." file) | |
284 (authors-scan-el file table))) | |
285 (set-buffer (get-buffer-create buffer-name)) | |
286 (erase-buffer) | |
287 (maphash #'authors-print table) | |
288 (sort-lines nil (point-min) (point-max)) | |
289 (pop-to-buffer buffer-name))) | |
290 | |
291 | |
292 ;; authors.el ends here |