Mercurial > emacs
annotate lisp/emacs-lisp/authors.el @ 32229:108b464ba713
(eudc): Add :version, :link.
author | Dave Love <fx@gnu.org> |
---|---|
date | Fri, 06 Oct 2000 18:56:44 +0000 |
parents | 1bb0e9c9c64d |
children | efaa4e4c5fef |
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." | |
32028
1bb0e9c9c64d
(authors-obsolete-file-p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
32005
diff
changeset
|
116 (unless (authors-obsolete-file-p file) |
1bb0e9c9c64d
(authors-obsolete-file-p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
32005
diff
changeset
|
117 (let* ((value (gethash author table)) |
1bb0e9c9c64d
(authors-obsolete-file-p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
32005
diff
changeset
|
118 (entry (assoc file value))) |
1bb0e9c9c64d
(authors-obsolete-file-p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
32005
diff
changeset
|
119 (if (null entry) |
1bb0e9c9c64d
(authors-obsolete-file-p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
32005
diff
changeset
|
120 (puthash author (cons (list file action) value) table) |
1bb0e9c9c64d
(authors-obsolete-file-p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
32005
diff
changeset
|
121 (unless (memq action entry) |
1bb0e9c9c64d
(authors-obsolete-file-p): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
32005
diff
changeset
|
122 (nconc entry (list action))))))) |
30790 | 123 |
124 | |
125 (defun authors-process-lines (program &rest args) | |
126 "Execute PROGRAM with ARGS, returning its output as a list of lines. | |
127 Signal an error if the program returns with a non-zero exit status." | |
128 (with-temp-buffer | |
129 (let ((status (apply 'call-process program nil (current-buffer) nil args))) | |
130 (unless (eq status 0) | |
131 (error "%s exited with status %s" program status)) | |
132 (goto-char (point-min)) | |
133 (let (lines) | |
134 (while (not (eobp)) | |
135 (setq lines (cons (buffer-substring-no-properties | |
136 (line-beginning-position) | |
137 (line-end-position)) | |
138 lines)) | |
139 (forward-line 1)) | |
140 (nreverse lines))))) | |
141 | |
142 | |
143 (defun authors-canonical-author-name (author) | |
144 "Return a canonicalized form of AUTHOR, an author name. | |
145 If AUTHOR has an alias, use that. Remove email addresses. Capitalize | |
146 words in the author's name." | |
147 (let ((aliases authors-aliases)) | |
148 (while aliases | |
149 (when (string-match (car (car aliases)) author) | |
150 (setq author (cdr (car aliases)) | |
151 aliases nil)) | |
152 (setq aliases (cdr aliases)))) | |
153 (setq author (replace-regexp-in-string "[ \t]*[(<].*$" "" author)) | |
154 (setq author (replace-regexp-in-string "^[ \t]+" "" author)) | |
155 (setq author (replace-regexp-in-string "[ \t]+$" "" author)) | |
156 (capitalize author)) | |
157 | |
158 | |
159 (defun authors-scan-change-log (file table) | |
160 "Scan change log FILE for author information. | |
161 | |
162 For each change mentioned in the log, add an entry to hash table TABLE | |
163 under the author's canonical name. | |
164 | |
165 Keys of TABLE are author names. Values are alists of entries (FILE | |
166 ACTION...). FILE is one file the author worked on. The rest of the | |
167 entry is a list of keyword symbols describing what he did with the | |
168 file. | |
169 | |
170 :wrote means the author wrote the file | |
171 :changed means he changed the file." | |
172 | |
173 (let* ((enable-local-variables t) | |
174 (enable-local-eval t) | |
175 (existing-buffer (get-file-buffer file)) | |
176 (buffer (find-file-noselect file)) | |
177 author) | |
178 (save-excursion | |
179 (set-buffer buffer) | |
180 (save-restriction | |
181 (widen) | |
182 (goto-char (point-min)) | |
183 (while (re-search-forward "^[0-9]\\|^[ \t]+\\* " nil t) | |
184 (beginning-of-line) | |
185 (cond ((looking-at "^[0-9]+-[0-9]+-[0-9]+") | |
186 (skip-chars-forward " \t+:0-9-") | |
187 (setq author (buffer-substring-no-properties | |
188 (point) (line-end-position))) | |
189 (setq author (authors-canonical-author-name author)) | |
190 (forward-line 1)) | |
191 ((looking-at "^[ \t]+\\*") | |
192 (let ((line (buffer-substring-no-properties | |
193 (match-end 0) (line-end-position)))) | |
194 (while (and (not (string-match ":" line)) | |
195 (forward-line 1) | |
196 (not (looking-at ":\\|^[ \t]*$"))) | |
197 (setq line (concat line | |
198 (buffer-substring-no-properties | |
199 (line-beginning-position) | |
200 (line-end-position))))) | |
201 (when (string-match ":" line) | |
202 (setq line (substring line 0 (match-beginning 0))) | |
203 (setq line (replace-regexp-in-string "[[(<{].*$" "" line)) | |
204 (setq line (replace-regexp-in-string "," "" line)) | |
205 (dolist (file (split-string line)) | |
206 (setq file (file-name-nondirectory file)) | |
207 ;(message "%s changed %s" author file) | |
208 (authors-add author file :changed table))) | |
209 (forward-line 1))))))) | |
210 (unless existing-buffer | |
211 (kill-buffer buffer)))) | |
212 | |
213 | |
214 (defun authors-scan-el (file table) | |
215 "Scan Lisp file FILE for author information. | |
216 TABLE is a hash table to add author information to." | |
217 (let* ((existing-buffer (get-file-buffer file)) | |
218 (enable-local-variables t) | |
219 (enable-local-eval t) | |
220 (buffer (find-file-noselect file))) | |
221 (save-excursion | |
222 (set-buffer buffer) | |
223 (save-restriction | |
224 (widen) | |
225 (goto-char (point-min)) | |
226 (while (and (re-search-forward | |
227 "^;+[ \t]*\\(Author\\|Commentary\\):[ \t]*" nil t) | |
228 (not (string= (match-string 1) "Commentary"))) | |
229 ;; Some entries contain a year range in front of the | |
230 ;; author's name. | |
231 (skip-chars-forward "-0-9 \t") | |
232 (let ((author (buffer-substring-no-properties | |
233 (point) (line-end-position)))) | |
234 (setq author (authors-canonical-author-name author)) | |
235 (setq file (file-name-nondirectory file)) | |
236 (authors-add author file :wrote table))))) | |
237 (unless existing-buffer | |
238 (kill-buffer buffer)))) | |
239 | |
240 | |
241 (defun authors-print (author changes) | |
242 "Insert information about AUTHOR's work on Emacs into the current buffer. | |
243 CHANGES is an alist of entries (FILE ACTION...), as produced by | |
244 `authors-scan-change-log'." | |
245 (unless (equal author "Ignore") | |
246 (let ((nchanged 0)) | |
247 (dolist (change changes) | |
248 (let ((actions (cdr change)) | |
249 (file (car change))) | |
250 (if (memq :wrote actions) | |
251 (insert author " (wrote) " file "\n") | |
252 (setq nchanged (1+ nchanged))))) | |
253 (if (> nchanged authors-many-files) | |
32005
01a7fea88dc1
(authors-print): Rephrase many-files string.
Miles Bader <miles@gnu.org>
parents:
31957
diff
changeset
|
254 (insert author " (changed) [more than " |
30790 | 255 (int-to-string authors-many-files) " files]\n") |
256 (dolist (change changes) | |
257 (let ((actions (cdr change)) | |
258 (file (car change))) | |
259 (unless (memq :wrote actions) | |
260 (insert author " (changed) " file "\n")))))))) | |
261 | |
262 | |
263 ;;;###autoload | |
264 (defun authors (root) | |
265 "Extract author information from change logs and Lisp source files. | |
266 ROOT is the root directory under which to find the files. If called | |
267 interactively, ROOT is read from the minibuffer. Result is a | |
268 buffer *Authors* containing authorship information." | |
269 (interactive "DEmacs source directory: ") | |
270 (let ((logs (authors-process-lines "find" root "-name" "ChangeLog*")) | |
271 (table (make-hash-table :test 'equal)) | |
272 (buffer-name "*Authors*")) | |
273 (setq root (expand-file-name root)) | |
274 (unless (file-exists-p (expand-file-name "src/emacs.c" root)) | |
275 (error "Not the root directory of Emacs: %s" root)) | |
276 (dolist (log logs) | |
277 (when (string-match "ChangeLog\\(.[0-9]+\\)?$" log) | |
278 (message "Scanning %s..." log) | |
279 (authors-scan-change-log log table))) | |
280 (let ((els (authors-process-lines "find" root "-name" "*.el"))) | |
281 (dolist (file els) | |
282 (message "Scanning %s..." file) | |
283 (authors-scan-el file table))) | |
284 (set-buffer (get-buffer-create buffer-name)) | |
285 (erase-buffer) | |
286 (maphash #'authors-print table) | |
287 (sort-lines nil (point-min) (point-max)) | |
288 (pop-to-buffer buffer-name))) | |
289 | |
290 | |
291 ;; authors.el ends here |