(msb-mode): Drop unneeded positional args.
[emacs.git] / lisp / emacs-lisp / authors.el
blob1e5c48323e835d10fcd2a8e71b34d4950564f845
1 ;;; authors.el --- utility for maintaining Emacs' AUTHORS file
3 ;; Copyright (C) 2000 Free Software Foundation, Inc.
5 ;; This file is part of GNU Emacs.
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.
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.
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.
22 ;;; Commentary:
24 ;; Use M-x authors RET to create an *Authors* buffer that can used as
25 ;; or merged with Emacs' AUTHORS file.
27 ;;; Code:
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.")
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 ("W{\L}Odek Bzyl" . "Wlodzimierz Bzyl")
83 ("Kenneth Manheimer" . "Ken Manheimer")
84 ("Kenichi HANDA" . "Kenichi Handa")
85 ("Jay Adams" . "Jay R. Adams")
86 ("Joe Arceneaux" . "Josef Arceneaux")
87 ("K. Berry" . "Karl Berry")
88 ("Michael Ernst" . "Michael D. Ernst")
89 ("Dave Gillespie" . "David Gillespie")
90 ("Shane Hartman" . "K. Shane Hartman")
91 ("Francesco Potorti`" . "Francesco Potorti")
92 ("Roland Roberts" . "Roland B. Roberts")
93 ("David Smith" . "David M. Smith")
95 "Alist of author aliases.
97 Each entry is of the form (REGEXP . ALIAS). If an author's name
98 matches REGEXP, use ALIAS instead. The special alias \"ignore\" means
99 ignore that author.")
102 (defvar authors-public-domain-files
103 '("auto-show\\.el"
104 "form-d2\\.el"
105 "emerge\\.el"
106 "unused\\.el"
107 "vi\\.el"
108 "feedmail\\.el"
109 "mailpost\\.el"
110 "hanoi\\.el"
111 "meese\\.el"
112 "studly\\.el"
113 "modula2\\.el")
114 "List of regexps matching files for which the FSF doesn't need papers.")
117 (defvar authors-obsolete-files-regexps
118 '("vc-\\*\\.el$"
119 "spec.txt$"
120 "vc-\\(rcs\\|cvs\\|sccs\\)-hooks\\.el$")
121 "List of regexps matching obsolete files.
122 Changes to files matching one of the regexps in this list are not
123 listed.")
126 (defconst authors-fixed-entries
127 '(("Joe Arceneax" :wrote "xrdb.c")
128 ("Blitz Product Development Corporation" :wrote "ispell.el")
129 ("Frank Bresz" :wrote "diff.el")
130 ("David M. Brown" :wrote "array.el")
131 ("Gary Byers" :changed "xenix.h")
132 ("Shawn M. Carey" :wrote "freebsd.h")
133 ("Eric Decker" :changed "hp9000s800.h" "hpux.h" "sysdep.c")
134 ("Lawrence R. Dodd" :wrote "dired-x.el")
135 ("Viktor Dukhovni" :wrote "unexsunos4.c")
136 ("Paul Eggert" :wrote "rcs2log" "vcdiff")
137 ("Fred Fish" :changed "unexec.c")
138 ("Tim Fleehart" :wrote "makefile.nt")
139 ("Keith Gabryelski" :wrote "hexl.c")
140 ("Kevin Gallagher" :wrote "flow-ctrl.el")
141 ("Howard Gayle" :wrote "disp-table.el" "iso-syntax.el" "casetab.c")
142 ("Stephen Gildea" :wrote "refcard.tex" "mh-funcs.el" "mh-pick.el")
143 ("David Gillespie" :wrote "cl.texinfo")
144 ("Hewlett-Packard" :changed "emacsclient.c" "emacsserver.c"
145 "server.el" "keyboard.c")
146 ("Thomas Horsley" :wrote "cxux.h" "cxux7.h")
147 ("Indiana University Foundation" :changed "buffer.c" "buffer.h"
148 "indent.c" "search.c" "xdisp.c" "region-cache.c" "region-cache.h")
149 ("International Business Machines" :changed "emacs.c" "fileio.c"
150 "ibmrt.h" "process.c" "sysdep.c" "unexec.c" "ibmrt-aix.h")
151 ("Ishikawa Chiaki" :changed "aviion.h" "dgux.h")
152 ("Michael K. Johnson" :changed "configure.in" "emacs.c" "intel386.h"
153 "mem-limits.h" "process.c" "template.h" "sysdep.c" "syssignal.h" "systty.h" "unexec.c"
154 "ymakefile" "linux.h")
155 ("Kyle E. Jones" :wrote "mldrag.el")
156 ("Kenry Kautz" :wrote "bib-mode.el")
157 ("Joseph M. Kelsey" :changed "fileio.c" "vms-pwd.h" "vmsfns.c" "dir.h"
158 "uaf.h")
159 ("Sam Kendall" :changed "etags.c" "etags.el")
160 ("Richard King" :wrote "backquote.el" "userlock.el" "filelock.c")
161 ("Larry Kolodney" :wrote "cvtmail.c")
162 ("Sebastian Kremer" :changed "add-log.el")
163 ("Mark Lambert" :changed "process.c" "process.h")
164 ("Aaron Larson" :changed "bibtex.el")
165 ("James R. Larus" :wrote "mh-e.el")
166 ("Lars Lindberg" :changed "dabbrev.el" :wrote "imenu.el")
167 ("Lucid, Inc." :changed "bytecode.c" "byte-opt.el" "byte-run.el"
168 "bytecomp.el" "delsel.el" "disass.el" "faces.el" "font-lock.el"
169 "lmenu.el" "lselect.el" "mailabbrev.el" "select.el" "xfaces.c"
170 "xselect.c")
171 ("MCC" :changed "etags.c" "emacsclient.c" "emacsserver.c" "movemail.c"
172 "rmail.el" "rmailedit.el" "rmailkwd.el"
173 "rmailmsc.el" "rmailout.el" "rmailsum.el" "scribe.el"
174 "server.el" "lisp.h" "sysdep.c" "unexec.c" :wrote "xmenu.c")
175 ("Niall Mansfield" :changed "etags.c")
176 ("Brian Marick" :wrote "hideif.el")
177 ("Marko Kohtala" :changed "info.el")
178 ("Sidney Markowitz" :changed "doctor.el")
179 ("Richard Mlynarik" :wrote "env.c" "ehelp.el")
180 ("Mosur Mohan" :changed "etags.c")
181 ("Jeff Morgenthaler" :changed "flow-ctrl.el" "vt200.el" "vt201.el"
182 "vt220.el" "vt240.el")
183 ("Motorola" :changed "buff-menu.el")
184 ("Hiroshi Nakano" :changed "ralloc.c")
185 ("Sundar Narasimhan" :changed "rnewspost.el")
186 ("NeXT, Inc." :wrote "unexnext.c")
187 ("Mark Neale" :changed "fortran.el")
188 ("Martin Neitzel" :changed "sc.el")
189 ("Andrew Oram" :changed "miscellaneous changes to files in man/"
190 "man/calendar.texi")
191 ("Frederic Pierresteguy" :wrote "widget.c")
192 ("Michael D. Prange" :changed "tex-mode.el")
193 ("Paul Reilly" :wrote "gux5-4r2.h" "dgux5-4r3.h")
194 ("Roland B Roberts" :changed "files.el" "sort.el" "vmsproc.el"
195 "buffer.h" "callproc.c" "dired.c" "process.c" "sysdep.c" "systty.h"
196 "vmspaths.h" "build.com" "compile.com" "kepteditor.com" "precomp.com"
197 :wrote "logout.com" "mailemacs.com")
198 ("Guillermo J. Rozas" :wrote "fakemail.c")
199 ("Wolfgang Rupprecht" :changed "lisp-mode.el" "loadup.el"
200 "sort.el" "alloc.c" "callint.c"
201 "config.h.in" "crt0.c" "data.c" "fns.c"
202 "lisp.h" "lread.c" "sun3.h"
203 "print.c" "ymakefile" :wrote "float-sup.el" "floatfns.c")
204 ("Schlumberger Technology Corporation" :changed "gud.el")
205 ("Gregor Schmid" :wrote "tcl-mode.el")
206 ("Rainer Schoepf" :wrote "alpha.h" "unexalpha.c")
207 ("William Sommerfeld" :wrote "emacsclient.c" "emacsserver.c" "scribe.el")
208 ("Leigh Stoller" :changed "emacsclient.c" "emacsserver.c" "server.el")
209 ("Steve Strassman" :wrote "spook.el")
210 ("Shinichirou Sugou" :changed "etags.c")
211 ("Sun Microsystems, Inc" :changed "emacsclient.c" "emacsserver.c"
212 "server.el" :wrote "emacs.icon" "emacstool.1" "emacstool.c" "sun-curs.el"
213 "sun-fns.el" "sun-mouse.el" "sun.el" "sunfns.c")
214 ("Kayvan Sylvan" :changed "sc.el")
215 ("Spencer Thomas" :changed "emacsclient.c" "emacsserver.c" "server.el"
216 "dabbrev.el" "unexec.c" "tcp.c" "gnus.texi")
217 ("Jonathan Vail" :changed "vc.el")
218 ("James Van Artsdalen" :changed "usg5-4.h" "unexec.c")
219 ("Geoff Voelker" :wrote "src/makefile.nt" "lisp/makefile.nt" "winnt.el"
220 "nt.c" "nt.h" "ntheap.c" "ntheap.h" "ntinevt.c"
221 "ntproc.c" "ntterm.c" "windowsnt.h")
222 ("Morten Welinder" :wrote "dosfns.c" "[many MSDOS files]" "msdos.h")
223 ("Pace Willisson" :wrote "ispell.el")
224 ("Garrett Wollman" :changed "sendmail.el")
225 ("Dale Worley" :changed "mail-extr.el")
226 ("Jamie Zawinski" :changed "bytecode.c" :wrote "disass.el" "tar-mode.el"))
227 "Actions taken from the original, manually (un)maintained AUTHORS file.")
230 (defun authors-add-fixed-entries (table)
231 "Add actions from `authors-fixed-entries' to TABLE."
232 (dolist (entry authors-fixed-entries)
233 (let ((author (car entry))
234 action)
235 (dolist (item (cdr entry))
236 (if (symbolp item)
237 (setq action item)
238 (authors-add author item action table))))))
241 (defun authors-obsolete-file-p (file)
242 "Return non-nil if FILE is obsolete.
243 FILE is considered obsolete if it matches on of the regular expressions
244 from `authors-obsolete-files-regexps'."
245 (let (obsolete-p
246 (regexps authors-obsolete-files-regexps))
247 (while (and regexps (not obsolete-p))
248 (setq obsolete-p (string-match (car regexps) file)
249 regexps (cdr regexps)))
250 obsolete-p))
253 (defun authors-add (author file action table)
254 "Record that AUTHOR worked on FILE.
255 ACTION is a keyword symbol describing what he did. Record file,
256 author and what he did in hash table TABLE. See the description of
257 `authors-scan-change-log' for the structure of the hash table."
258 (unless (or (authors-obsolete-file-p file)
259 (equal author ""))
260 (let* ((value (gethash author table))
261 (entry (assoc file value)))
262 (if (null entry)
263 (puthash author (cons (list file action) value) table)
264 (unless (memq action entry)
265 (nconc entry (list action)))))))
268 (defun authors-process-lines (program &rest args)
269 "Execute PROGRAM with ARGS, returning its output as a list of lines.
270 Signal an error if the program returns with a non-zero exit status."
271 (with-temp-buffer
272 (let ((status (apply 'call-process program nil (current-buffer) nil args)))
273 (unless (eq status 0)
274 (error "%s exited with status %s" program status))
275 (goto-char (point-min))
276 (let (lines)
277 (while (not (eobp))
278 (setq lines (cons (buffer-substring-no-properties
279 (line-beginning-position)
280 (line-end-position))
281 lines))
282 (forward-line 1))
283 (nreverse lines)))))
286 (defun authors-canonical-author-name (author)
287 "Return a canonicalized form of AUTHOR, an author name.
288 If AUTHOR has an alias, use that. Remove email addresses. Capitalize
289 words in the author's name."
290 (let ((aliases authors-aliases))
291 (while aliases
292 (when (string-match (car (car aliases)) author)
293 (setq author (cdr (car aliases))
294 aliases nil))
295 (setq aliases (cdr aliases))))
296 (setq author (replace-regexp-in-string "[ \t]*[(<].*$" "" author))
297 (setq author (replace-regexp-in-string "^[ \t]+" "" author))
298 (setq author (replace-regexp-in-string "[ \t]+$" "" author))
299 (capitalize author))
302 (defun authors-scan-change-log (file table)
303 "Scan change log FILE for author information.
305 For each change mentioned in the log, add an entry to hash table TABLE
306 under the author's canonical name.
308 Keys of TABLE are author names. Values are alists of entries (FILE
309 ACTION...). FILE is one file the author worked on. The rest of the
310 entry is a list of keyword symbols describing what he did with the
311 file.
313 :wrote means the author wrote the file
314 :changed means he changed the file."
316 (let* ((enable-local-variables t)
317 (enable-local-eval t)
318 (existing-buffer (get-file-buffer file))
319 (buffer (find-file-noselect file))
320 author)
321 (save-excursion
322 (set-buffer buffer)
323 (save-restriction
324 (widen)
325 (goto-char (point-min))
326 (while (re-search-forward "^[0-9]\\|^[ \t]+\\* " nil t)
327 (beginning-of-line)
328 (cond ((looking-at "^[0-9]+-[0-9]+-[0-9]+")
329 (skip-chars-forward " \t+:0-9-")
330 (setq author (buffer-substring-no-properties
331 (point) (line-end-position)))
332 (setq author (authors-canonical-author-name author))
333 (forward-line 1))
334 ((looking-at "^[ \t]+\\*")
335 (let ((line (buffer-substring-no-properties
336 (match-end 0) (line-end-position))))
337 (while (and (not (string-match ":" line))
338 (forward-line 1)
339 (not (looking-at ":\\|^[ \t]*$")))
340 (setq line (concat line
341 (buffer-substring-no-properties
342 (line-beginning-position)
343 (line-end-position)))))
344 (when (string-match ":" line)
345 (setq line (substring line 0 (match-beginning 0)))
346 (setq line (replace-regexp-in-string "[[(<{].*$" "" line))
347 (setq line (replace-regexp-in-string "," "" line))
348 (dolist (file (split-string line))
349 (setq file (file-name-nondirectory file))
350 ;(message "%s changed %s" author file)
351 (authors-add author file :changed table)))
352 (forward-line 1)))))))
353 (unless existing-buffer
354 (kill-buffer buffer))))
357 (defun authors-scan-el (file table)
358 "Scan Lisp file FILE for author information.
359 TABLE is a hash table to add author information to."
360 (let* ((existing-buffer (get-file-buffer file))
361 (enable-local-variables t)
362 (enable-local-eval t)
363 (buffer (find-file-noselect file)))
364 (save-excursion
365 (set-buffer buffer)
366 (save-restriction
367 (widen)
368 (goto-char (point-min))
369 (while (and (re-search-forward
370 "^;+[ \t]*\\(Author\\|Commentary\\):[ \t]*" nil t)
371 (not (string= (match-string 1) "Commentary")))
372 ;; Some entries contain a year range in front of the
373 ;; author's name.
374 (skip-chars-forward "-0-9 \t")
375 (let ((author (buffer-substring-no-properties
376 (point) (line-end-position))))
377 (setq author (authors-canonical-author-name author))
378 (setq file (file-name-nondirectory file))
379 (authors-add author file :wrote table)))))
380 (unless existing-buffer
381 (kill-buffer buffer))))
384 (defun authors-public-domain-p (file)
385 "Return t if FILE is a file that was put in public domain."
386 (let ((public-domain-p nil)
387 (list authors-public-domain-files))
388 (while (and list (not public-domain-p))
389 (when (string-match (car list) file)
390 (setq public-domain-p t))
391 (setq list (cdr list)))
392 public-domain-p))
395 (defun authors-print (author changes)
396 "Insert information about AUTHOR's work on Emacs into the current buffer.
397 CHANGES is an alist of entries (FILE ACTION...), as produced by
398 `authors-scan-change-log'."
399 (unless (equal author "Ignore")
400 (let ((nchanged 0))
401 (dolist (change changes)
402 (let ((actions (cdr change))
403 (file (car change)))
404 (if (memq :wrote actions)
405 (progn
406 (insert author " (wrote) " file)
407 (when (authors-public-domain-p file)
408 (insert " (public domain)"))
409 (insert "\n"))
410 (setq nchanged (1+ nchanged)))))
411 (if (> nchanged authors-many-files)
412 (insert author " (changed) [more than "
413 (int-to-string authors-many-files) " files]\n")
414 (dolist (change changes)
415 (let ((actions (cdr change))
416 (file (car change)))
417 (unless (memq :wrote actions)
418 (insert author " (changed) " file "\n"))))))))
421 ;;;###autoload
422 (defun authors (root)
423 "Extract author information from change logs and Lisp source files.
424 ROOT is the root directory under which to find the files. If called
425 interactively, ROOT is read from the minibuffer. Result is a
426 buffer *Authors* containing authorship information."
427 (interactive "DEmacs source directory: ")
428 (let ((logs (authors-process-lines "find" root "-name" "ChangeLog*"))
429 (table (make-hash-table :test 'equal))
430 (buffer-name "*Authors*"))
431 (setq root (expand-file-name root))
432 (authors-add-fixed-entries table)
433 (unless (file-exists-p (expand-file-name "src/emacs.c" root))
434 (error "Not the root directory of Emacs: %s" root))
435 (dolist (log logs)
436 (when (and (string-match "ChangeLog\\(.[0-9]+\\)?$" log)
437 (not (string-match "/lispref/" log)))
438 (message "Scanning %s..." log)
439 (authors-scan-change-log log table)))
440 (let ((els (authors-process-lines "find" root "-name" "*.el")))
441 (dolist (file els)
442 (message "Scanning %s..." file)
443 (authors-scan-el file table)))
444 (set-buffer (get-buffer-create buffer-name))
445 (erase-buffer)
446 (set-buffer-file-coding-system 'iso-2022-7bit)
447 (maphash #'authors-print table)
448 (sort-lines nil (point-min) (point-max))
449 (insert "\nLocal" " Variables:\ncoding: iso-2022-7bit\nEnd:\n")
450 (unless noninteractive
451 (pop-to-buffer buffer-name))))
454 ;;;###autoload
455 (defun batch-update-authors ()
456 "Produce an AUTHORS file.
457 Call this function in batch mode with two command line arguments FILE
458 and ROOT. FILE is the file to write, ROOT is the root directory of
459 the Emacs source tree, from which to build the file."
460 (unless noninteractive
461 (error "`batch-update-authors' is to be used only with -batch"))
462 (when (/= (length command-line-args-left) 2)
463 (error "Call `batch-update-authors' with the name of the file to write"))
464 (let* ((file (pop command-line-args-left))
465 (root (pop command-line-args-left)))
466 (authors root)
467 (write-file file)))
469 ;; authors.el ends here