(authors-aliases): Add mode aliases.
[bpt/emacs.git] / lisp / emacs-lisp / authors.el
CommitLineData
66fd374b 1;;; authors.el --- utility for maintaining Emacs' AUTHORS file -*-coding: iso-2022-7bit;-*-
3215096c 2
ceb4c4d3
TTN
3;; Copyright (C) 2000, 2002, 2003, 2004, 2005,
4;; 2006 Free Software Foundation, Inc.
3215096c 5
60e8e0a5 6;; Author: Gerd Moellmann <gerd@gnu.org>
f39caf44 7;; Maintainer: Kim F. Storm <storm@cua.dk>
60e8e0a5
GM
8;; Keywords: maint
9
3215096c
GM
10;; This file is part of GNU Emacs.
11
12;; GNU Emacs is free software; you can redistribute it and/or modify
13;; it under the terms of the GNU General Public License as published by
14;; the Free Software Foundation; either version 2, or (at your option)
15;; any later version.
16
17;; GNU Emacs is distributed in the hope that it will be useful,
18;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20;; GNU General Public License for more details.
21
22;; You should have received a copy of the GNU General Public License
23;; along with GNU Emacs; see the file COPYING. If not, write to the
3a35cf56
LK
24;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25;; Boston, MA 02110-1301, USA.
3215096c
GM
26
27;;; Commentary:
28
29;; Use M-x authors RET to create an *Authors* buffer that can used as
30;; or merged with Emacs' AUTHORS file.
31
32;;; Code:
33
f39caf44
KS
34(defvar authors-coding-system 'iso-2022-7bit
35 "Coding system used in the AUTHORS file.")
36
3215096c
GM
37(defconst authors-many-files 20
38 "Maximum number of files for which to print individual information.
f39caf44
KS
39If an author has modified more files, only the names of the most
40frequently modified files are printed and a count of the additional
41files.")
3215096c
GM
42
43(defconst authors-aliases
f39caf44 44 '(
9109bf49 45 ("Andrew Csillag" "Drew Csillag")
f39caf44
KS
46 ("Barry A. Warsaw" "Barry A. Warsaw, Century Computing, Inc."
47 "Barry A. Warsaw, ITB" "Barry Warsaw")
48 ("Bj\e,Av\e(Brn Torkelsson" "Bjorn Torkelsson")
49 ("Brian Fox" "Brian J. Fox")
50 ("Christoph Wedler" "Christoph.Wedler@sap.com")
51 ("Daniel Pfeiffer" "<Daniel.Pfeiffer@Informatik.START.db.de>"
52 "<Daniel.Pfeiffer@Informatik.START.dbp.de>")
53 ("David Gillespie" "Dave Gillespie")
54 ("David K\e,Ae\e(Bgedal" "David K..edal")
605046ef
KS
55 ("David M. Koppelman" "David M. Koppelman, Koppel@Ee.Lsu.Edu"
56 "David Koppelman")
d0f483e8
KS
57 ("David M. Smith" "David Smith" "David M Smith")
58 ("Ed L. Cashin" "Ed L Cashin")
f39caf44
KS
59 ("Edward M. Reingold" "Ed Reingold" "Edward M Reingold"
60 "Reingold Edward M")
61 ("Eli Zaretskii" "eliz")
4ee02020 62 ("Emilio C. Lopes" "Emilio Lopes")
d0f483e8 63 ("Era Eriksson" "Era@Iki.Fi")
f39caf44
KS
64 ("Eric M. Ludlam" "Eric Ludlam")
65 ("Eric S. Raymond" "Eric Raymond")
66 ("Eric Youngdale" "(Eric Youngdale at youngdale@v6550c.nrl.navy.mil)")
d0f483e8 67 ("Francis J. Wright" "Dr Francis J. Wright" "Francis Wright")
f39caf44 68 ("Fran\e,Ag\e(Bois Pinard" "Francois Pinard")
97c437db 69 ("Francesco Potort\e,Al\e(B" "Francesco Potorti" "Francesco Potorti`")
f39caf44
KS
70 ("Frederic Pierresteguy" "Fred Pierresteguy")
71 ("Geoff Voelker" "voelker")
72 ("Hallvard B. Furuseth" "Hallvard B Furuseth")
d0f483e8 73 ("Hrvoje Nik\e,B9\e(Bi\e,Bf\e(B" "Hrvoje Niksic")
f39caf44
KS
74 (nil "(afs@hplb.hpl.hp.com)")
75 (nil "<Use-Author-Address-Header@\\[127.1\\]>")
76 (nil "Code Extracted")
77 (nil "Fsf")
78 (nil "ISO-2022-JP")
79 ("Jaeyoun Chung" "Jae-youn Chung" "Jae-you Chung" "Chung Jae-youn")
80 ("Jan Dj\e,Ad\e(Brv" "Jan D." "Jan Djarv")
d0f483e8
KS
81 ("Jay K. Adams" "jka@ece.cmu.edu" "Jay Adams")
82 ("J\e,Ai\e(Br\e,At\e(Bme Marant" "J\e,bi\e(Br\e,bt\e(Bme Marant" "Jerome Marant")
f39caf44 83 ("Jens-Ulrik Holger Petersen" "Jens-Ulrik Petersen")
605046ef 84 ("Jeremy Bertram Maitin-Shepard" "Jeremy Maitin-Shepard")
56c3f16c 85 ("Johan Bockg\e,Ae\e(Brd" "Johan Bockgard")
4ee02020 86 ("John W. Eaton" "John Eaton")
f39caf44
KS
87 ("Jonathan I. Kamens" "Jonathan Kamens")
88 ("Joseph Arceneaux" "Joe Arceneaux")
4ee02020 89 ("Juan Le\e,As\e(Bn Lahoz Garc\e,Am\e(Ba" "Juan-Leon Lahoz Garcia")
f39caf44
KS
90 ("K. Shane Hartman" "Shane Hartman")
91 ("Kai Gro\e,A_\e(Bjohann" "Kai Grossjohann" "Kai Gro\e,b_\e(Bjohann"
d0f483e8
KS
92 "Kai.Grossjohann@Cs.Uni-Dortmund.De"
93 "Kai.Grossjohann@Gmx.Net")
f39caf44 94 ("Karl Berry" "K. Berry")
d0f483e8 95 ("Kazushi Marukawa" "Kazushi")
f39caf44
KS
96 ("Ken Manheimer" "Kenneth Manheimer")
97 ("Kenichi Handa" "Ken'ichi Handa" "Kenichi HANDA")
4ee02020 98 ("Kevin Greiner" "Kevin J. Greiner")
f39caf44 99 ("Kim F. Storm" "Kim Storm")
d0f483e8 100 ("Kyle Jones" "Kyle E. Jones")
f39caf44 101 ("Marcus G. Daniels" "Marcus Daniels")
d0f483e8
KS
102 ("Mark D. Baushke" "Mark D Baushke")
103 ("Martin Lorentzon" "Martin Lorentzson")
104 ("Matt Swift" "Matthew Swift")
4ee02020 105 ("Michael R. Mauger" "Michael Mauger")
f39caf44
KS
106 ("Michael D. Ernst" "Michael Ernst")
107 ("Michael I. Bushnell" "Michael I Bushnell" "Michael I. Bushnell, P/Bsg")
4ee02020 108 ("Mikio Nakajima" "Nakajima Mikio")
f39caf44
KS
109 ("Paul Eggert" "eggert")
110 ("Paul Reilly" "(pmr@legacy.pajato.com)")
d0f483e8 111 ("Pavel Jan\e,Bm\e(Bk" "Pavel Jan\e,Am\e(Bk Ml." "Pavel Jan\e,Am\e(Bk" "Pavel@Janik.Cz")
f39caf44 112 ("Per Abrahamsen" "Per Abhiddenware")
d0f483e8
KS
113 ("Peter S. Galbraith" "Peter Galbraith")
114 ("Peter Runestig" "Peter 'luna' Runestig")
f39caf44
KS
115 ("Peter S. Galbraith" "Peter S Galbraith")
116 ("Richard M. Stallman" "Richard M. Stallman,,," "Richard Stallman"
a1506d29 117 "rms" "rms@gnu.org")
f39caf44
KS
118 ("Robert J. Chassell" "Bob Chassell")
119 ("Roland B. Roberts" "Roland B Roberts" "Roland Roberts")
120 ("Rui-Tao Dong" "Rui-Tao Dong ~{6-Hpln~}")
121 ("Sam Steingold" "Sam Shteingold")
9109bf49 122 ("Satyaki Das" "Indexed search by Satyaki Das")
d0f483e8 123 ("Stefan Monnier" "Stefan")
f39caf44
KS
124 ("Stephen A. Wood" "(saw@cebaf.gov)")
125 ("Steven L. Baur" "SL Baur" "Steven L Baur")
126 ("Takaaki Ota" "Tak Ota")
4ee02020 127 ("Takahashi Naoto" "Naoto Takahashi")
d0f483e8 128 ("Teodor Zlatanov" "Ted Zlatanov")
f39caf44
KS
129 ("Torbj\e,Av\e(Brn Axelsson" "Torbjvrn Axelsson")
130 ("Torbj\e,Av\e(Brn Einarsson" "Torbj.*rn Einarsson")
131 ("Toru Tomabechi" "Toru Tomabechi,")
132 ("Vincent Del Vecchio" "Vince Del Vecchio")
9109bf49 133 ("William M. Perry" "Bill Perry")
f39caf44
KS
134 ("Wlodzimierz Bzyl" "W.*dek Bzyl")
135 ("Yutaka NIIBE" "NIIBE Yutaka")
d5ab63b2 136 )
3215096c
GM
137 "Alist of author aliases.
138
f39caf44 139Each entry is of the form (REALNAME REGEXP...). If an author's name
a1506d29 140matches one of the REGEXPs, use REALNAME instead.
f39caf44 141If REALNAME is nil, ignore that author.")
3215096c
GM
142
143
0a521885
GM
144(defvar authors-public-domain-files
145 '("auto-show\\.el"
146 "form-d2\\.el"
147 "emerge\\.el"
148 "unused\\.el"
149 "vi\\.el"
150 "feedmail\\.el"
151 "mailpost\\.el"
152 "hanoi\\.el"
153 "meese\\.el"
154 "studly\\.el"
155 "modula2\\.el")
156 "List of regexps matching files for which the FSF doesn't need papers.")
157
158
8a5506f2
GM
159(defvar authors-obsolete-files-regexps
160 '("vc-\\*\\.el$"
161 "spec.txt$"
162 "vc-\\(rcs\\|cvs\\|sccs\\)-hooks\\.el$")
163 "List of regexps matching obsolete files.
164Changes to files matching one of the regexps in this list are not
165listed.")
166
4ee02020
KS
167(defconst authors-ignored-files
168 '("external-lisp"
169 "lock" "share-lib" "local-lisp"
170 "noleim-Makefile.in"
605046ef 171 "NEWS" "PROBLEMS" "FAQ" "AUTHORS")
4ee02020
KS
172 "List of files and directories to ignore.
173Changes to files in this list are not listed.")
8a5506f2 174
d5ab63b2 175(defconst authors-fixed-entries
f39caf44
KS
176 '(("Richard M. Stallman" :wrote "[The original GNU emacs and numerous files]")
177 ("Joseph Arceneaux" :wrote "xrdb.c")
d5ab63b2
GM
178 ("Blitz Product Development Corporation" :wrote "ispell.el")
179 ("Frank Bresz" :wrote "diff.el")
180 ("David M. Brown" :wrote "array.el")
181 ("Gary Byers" :changed "xenix.h")
182 ("Shawn M. Carey" :wrote "freebsd.h")
183 ("Eric Decker" :changed "hp9000s800.h" "hpux.h" "sysdep.c")
184 ("Lawrence R. Dodd" :wrote "dired-x.el")
185 ("Viktor Dukhovni" :wrote "unexsunos4.c")
186 ("Paul Eggert" :wrote "rcs2log" "vcdiff")
187 ("Fred Fish" :changed "unexec.c")
188 ("Tim Fleehart" :wrote "makefile.nt")
189 ("Keith Gabryelski" :wrote "hexl.c")
190 ("Kevin Gallagher" :wrote "flow-ctrl.el")
191 ("Howard Gayle" :wrote "disp-table.el" "iso-syntax.el" "casetab.c")
192 ("Stephen Gildea" :wrote "refcard.tex" "mh-funcs.el" "mh-pick.el")
193 ("David Gillespie" :wrote "cl.texinfo")
194 ("Hewlett-Packard" :changed "emacsclient.c" "emacsserver.c"
195 "server.el" "keyboard.c")
196 ("Thomas Horsley" :wrote "cxux.h" "cxux7.h")
197 ("Indiana University Foundation" :changed "buffer.c" "buffer.h"
198 "indent.c" "search.c" "xdisp.c" "region-cache.c" "region-cache.h")
199 ("International Business Machines" :changed "emacs.c" "fileio.c"
200 "ibmrt.h" "process.c" "sysdep.c" "unexec.c" "ibmrt-aix.h")
201 ("Ishikawa Chiaki" :changed "aviion.h" "dgux.h")
202 ("Michael K. Johnson" :changed "configure.in" "emacs.c" "intel386.h"
203 "mem-limits.h" "process.c" "template.h" "sysdep.c" "syssignal.h" "systty.h" "unexec.c"
204 "ymakefile" "linux.h")
56c3f16c 205 ("Kyle Jones" :wrote "mldrag.el")
4ee02020 206 ("Henry Kautz" :wrote "bib-mode.el")
d5ab63b2
GM
207 ("Joseph M. Kelsey" :changed "fileio.c" "vms-pwd.h" "vmsfns.c" "dir.h"
208 "uaf.h")
209 ("Sam Kendall" :changed "etags.c" "etags.el")
210 ("Richard King" :wrote "backquote.el" "userlock.el" "filelock.c")
211 ("Larry Kolodney" :wrote "cvtmail.c")
212 ("Sebastian Kremer" :changed "add-log.el")
213 ("Mark Lambert" :changed "process.c" "process.h")
214 ("Aaron Larson" :changed "bibtex.el")
215 ("James R. Larus" :wrote "mh-e.el")
216 ("Lars Lindberg" :changed "dabbrev.el" :wrote "imenu.el")
217 ("Lucid, Inc." :changed "bytecode.c" "byte-opt.el" "byte-run.el"
218 "bytecomp.el" "delsel.el" "disass.el" "faces.el" "font-lock.el"
219 "lmenu.el" "lselect.el" "mailabbrev.el" "select.el" "xfaces.c"
220 "xselect.c")
221 ("MCC" :changed "etags.c" "emacsclient.c" "emacsserver.c" "movemail.c"
222 "rmail.el" "rmailedit.el" "rmailkwd.el"
223 "rmailmsc.el" "rmailout.el" "rmailsum.el" "scribe.el"
224 "server.el" "lisp.h" "sysdep.c" "unexec.c" :wrote "xmenu.c")
225 ("Niall Mansfield" :changed "etags.c")
226 ("Brian Marick" :wrote "hideif.el")
227 ("Marko Kohtala" :changed "info.el")
228 ("Sidney Markowitz" :changed "doctor.el")
229 ("Richard Mlynarik" :wrote "env.c" "ehelp.el")
230 ("Mosur Mohan" :changed "etags.c")
231 ("Jeff Morgenthaler" :changed "flow-ctrl.el" "vt200.el" "vt201.el"
232 "vt220.el" "vt240.el")
233 ("Motorola" :changed "buff-menu.el")
234 ("Hiroshi Nakano" :changed "ralloc.c")
235 ("Sundar Narasimhan" :changed "rnewspost.el")
236 ("NeXT, Inc." :wrote "unexnext.c")
237 ("Mark Neale" :changed "fortran.el")
238 ("Martin Neitzel" :changed "sc.el")
239 ("Andrew Oram" :changed "miscellaneous changes to files in man/"
240 "man/calendar.texi")
241 ("Frederic Pierresteguy" :wrote "widget.c")
242 ("Michael D. Prange" :changed "tex-mode.el")
243 ("Paul Reilly" :wrote "gux5-4r2.h" "dgux5-4r3.h")
d0f483e8 244 ("Roland B. Roberts" :changed "files.el" "sort.el" "vmsproc.el"
d5ab63b2
GM
245 "buffer.h" "callproc.c" "dired.c" "process.c" "sysdep.c" "systty.h"
246 "vmspaths.h" "build.com" "compile.com" "kepteditor.com" "precomp.com"
247 :wrote "logout.com" "mailemacs.com")
248 ("Guillermo J. Rozas" :wrote "fakemail.c")
249 ("Wolfgang Rupprecht" :changed "lisp-mode.el" "loadup.el"
250 "sort.el" "alloc.c" "callint.c"
251 "config.h.in" "crt0.c" "data.c" "fns.c"
252 "lisp.h" "lread.c" "sun3.h"
253 "print.c" "ymakefile" :wrote "float-sup.el" "floatfns.c")
254 ("Schlumberger Technology Corporation" :changed "gud.el")
255 ("Gregor Schmid" :wrote "tcl-mode.el")
256 ("Rainer Schoepf" :wrote "alpha.h" "unexalpha.c")
257 ("William Sommerfeld" :wrote "emacsclient.c" "emacsserver.c" "scribe.el")
258 ("Leigh Stoller" :changed "emacsclient.c" "emacsserver.c" "server.el")
259 ("Steve Strassman" :wrote "spook.el")
260 ("Shinichirou Sugou" :changed "etags.c")
261 ("Sun Microsystems, Inc" :changed "emacsclient.c" "emacsserver.c"
262 "server.el" :wrote "emacs.icon" "emacstool.1" "emacstool.c" "sun-curs.el"
263 "sun-fns.el" "sun-mouse.el" "sun.el" "sunfns.c")
264 ("Kayvan Sylvan" :changed "sc.el")
265 ("Spencer Thomas" :changed "emacsclient.c" "emacsserver.c" "server.el"
266 "dabbrev.el" "unexec.c" "tcp.c" "gnus.texi")
267 ("Jonathan Vail" :changed "vc.el")
268 ("James Van Artsdalen" :changed "usg5-4.h" "unexec.c")
269 ("Geoff Voelker" :wrote "src/makefile.nt" "lisp/makefile.nt" "winnt.el"
270 "nt.c" "nt.h" "ntheap.c" "ntheap.h" "ntinevt.c"
271 "ntproc.c" "ntterm.c" "windowsnt.h")
272 ("Morten Welinder" :wrote "dosfns.c" "[many MSDOS files]" "msdos.h")
273 ("Pace Willisson" :wrote "ispell.el")
274 ("Garrett Wollman" :changed "sendmail.el")
9109bf49 275 ("Dale R. Worley" :changed "mail-extr.el")
d5ab63b2
GM
276 ("Jamie Zawinski" :changed "bytecode.c" :wrote "disass.el" "tar-mode.el"))
277 "Actions taken from the original, manually (un)maintained AUTHORS file.")
278
279
f39caf44
KS
280(defconst authors-valid-file-names
281 '("aclocal.m4"
4ee02020
KS
282 "makedist.bat"
283 "make-delta")
f39caf44
KS
284 "File names which are valid, but no longer exists (or cannot be
285found) in the repository.")
286
287(defconst authors-renamed-files-alist
288 '(("nt.c" . "w32.c") ("nt.h" . "w32.h")
289 ("ntheap.c" . "w32heap.c") ("ntheap.h" . "w32heap.h")
290 ("ntinevt.c" . "w32inevt.c") ("ntinevt.h" . "w32inevt.h")
291 ("ntproc.c" . "w32proc.c")
292 ("w32console.c" . "w32term.c")
293 ("unexnt.c" . "unexw32.c")
294 ("s/windowsnt.h" . "s/ms-w32.h")
295 ("config.emacs" . "configure")
296 ("GETTING.GNU.SOFTWARE" . "FTP")
4ee02020
KS
297 ("leim-Makefile" . "leim/Makefile")
298 ("leim-Makefile.in" . "leim/Makefile.in")
299 ("INSTALL-CVS" . "INSTALL.CVS")
f39caf44
KS
300 )
301 "Alist of files which have been renamed during their lifetime.
302Elements are (OLDNAME . NEWNAME).")
303
304(defconst authors-renamed-files-regexps
305 '(("^m/m-\\(.*\\.h\\)$" . "m/\\1")
306 ("^m-\\(.*\\.h\\)$" . "\\1")
307 ("^s/s-\\(.*\\.h\\)$" . "s/\\1")
308 ("^s-\\(.*\\.h\\)$" . "\\1")
309 ("^s/[-.a-zA-Z0-9_]+\\.h$" . t)
310 ("\\(.*\\)\\.cmd$" . "\\1.bat")
311 ("\\.bat$" . t)
312 ("\\.[ch]$" . t)
313 ("\\.el$" . t)
314 ("\\.ps$" . t)
315 ("\\.texi?$" . t)
316 ("\\.texinfo$" . t)
317 ("\\.xml?$" . t)
318 ("\\.x[pb]m$" . t)
319 ("\\.[xp]bm$" . t)
320 ("^paths\\." . t)
321 ("^install\\." . t)
322 )
323 "List regexps and rewriting rules for renamed files.
324Elements are (REGEXP . REPLACE). If REPLACE is a string, the file
325name matching REGEXP is replaced by REPLACE using `replace-string'.
326Otherwise, the file name is accepted as is.")
327
328(defvar authors-checked-files-alist)
329(defvar authors-invalid-file-names)
330
331(defun authors-canonical-file-name (file log-file pos author)
332 "Return canonical file name for FILE found in LOG-FILE at POS for AUTHOR.
333Checks whether FILE is a valid (existing) file name, has been renamed,
334or is on the list of removed files. Returns the non-diretory part of
335the file name."
336 (let ((entry (assoc file authors-checked-files-alist))
337 relname
338 valid)
339 (if entry
340 (cdr entry)
341 (setq relname (file-name-nondirectory file))
342 (if (or (member relname authors-valid-file-names)
343 (file-exists-p file)
344 (file-exists-p relname)
345 (file-exists-p (concat "etc/" relname)))
346 (setq valid relname)
347 (setq valid (assoc file authors-renamed-files-alist))
348 (if valid
349 (setq valid (cdr valid))
350 (let ((rules authors-renamed-files-regexps))
351 (while rules
352 (if (string-match (car (car rules)) file)
353 (setq valid (if (stringp (cdr (car rules)))
354 (file-name-nondirectory
355 (replace-match (cdr (car rules)) t nil file))
356 relname)
357 rules nil))
358 (setq rules (cdr rules))))))
359 (setq authors-checked-files-alist
360 (cons (cons file valid) authors-checked-files-alist))
9109bf49
KS
361 (unless (or valid
362 (string-match "[*]" file)
363 (string-match "^[0-9.]+$" file))
a1506d29 364 (setq authors-invalid-file-names
f39caf44
KS
365 (cons (format "%s:%d: unrecognized `%s' for %s"
366 log-file
367 (1+ (count-lines (point-min) pos))
368 file author)
369 authors-invalid-file-names)))
370 valid)))
371
d5ab63b2
GM
372(defun authors-add-fixed-entries (table)
373 "Add actions from `authors-fixed-entries' to TABLE."
374 (dolist (entry authors-fixed-entries)
375 (let ((author (car entry))
376 action)
377 (dolist (item (cdr entry))
378 (if (symbolp item)
379 (setq action item)
380 (authors-add author item action table))))))
381
3932b29a 382
8a5506f2
GM
383(defun authors-obsolete-file-p (file)
384 "Return non-nil if FILE is obsolete.
3932b29a 385FILE is considered obsolete if it matches one of the regular expressions
8a5506f2
GM
386from `authors-obsolete-files-regexps'."
387 (let (obsolete-p
388 (regexps authors-obsolete-files-regexps))
389 (while (and regexps (not obsolete-p))
390 (setq obsolete-p (string-match (car regexps) file)
391 regexps (cdr regexps)))
392 obsolete-p))
393
394
3215096c
GM
395(defun authors-add (author file action table)
396 "Record that AUTHOR worked on FILE.
397ACTION is a keyword symbol describing what he did. Record file,
398author and what he did in hash table TABLE. See the description of
399`authors-scan-change-log' for the structure of the hash table."
4ee02020
KS
400 (unless (or (member file authors-ignored-files)
401 (authors-obsolete-file-p file)
9c1af546 402 (equal author ""))
8a5506f2 403 (let* ((value (gethash author table))
f39caf44
KS
404 (entry (assoc file value))
405 slot)
8a5506f2 406 (if (null entry)
f39caf44
KS
407 (puthash author (cons (list file (cons action 1)) value) table)
408 (if (setq slot (assoc action (cdr entry)))
409 (setcdr slot (1+ (cdr slot)))
410 (nconc entry (list (cons action 1))))))))
3215096c
GM
411
412
413(defun authors-process-lines (program &rest args)
414 "Execute PROGRAM with ARGS, returning its output as a list of lines.
415Signal an error if the program returns with a non-zero exit status."
416 (with-temp-buffer
417 (let ((status (apply 'call-process program nil (current-buffer) nil args)))
418 (unless (eq status 0)
419 (error "%s exited with status %s" program status))
420 (goto-char (point-min))
421 (let (lines)
422 (while (not (eobp))
423 (setq lines (cons (buffer-substring-no-properties
424 (line-beginning-position)
425 (line-end-position))
426 lines))
427 (forward-line 1))
428 (nreverse lines)))))
429
430
431(defun authors-canonical-author-name (author)
432 "Return a canonicalized form of AUTHOR, an author name.
433If AUTHOR has an alias, use that. Remove email addresses. Capitalize
434words in the author's name."
f39caf44
KS
435 (let* ((aliases authors-aliases)
436 regexps realname)
3215096c 437 (while aliases
f39caf44
KS
438 (setq realname (car (car aliases))
439 regexps (cdr (car aliases))
440 aliases (cdr aliases))
441 (while regexps
442 (if (string-match (car regexps) author)
443 (setq author realname
444 regexps nil
445 aliases nil)
446 (setq regexps (cdr regexps))))))
447 (when author
448 (setq author (replace-regexp-in-string "[ \t]*[(<].*$" "" author))
d0f483e8 449 (setq author (replace-regexp-in-string "\`[ \t]+" "" author))
f39caf44 450 (setq author (replace-regexp-in-string "[ \t]+$" "" author))
d0f483e8
KS
451 (setq author (replace-regexp-in-string "[ \t]+" " " author))
452 (unless (string-match "[-, \t]" author)
453 (setq author ""))
f39caf44
KS
454 (capitalize author)))
455
f39caf44
KS
456(defun authors-scan-change-log (log-file table)
457 "Scan change log LOG-FILE for author information.
3215096c
GM
458
459For each change mentioned in the log, add an entry to hash table TABLE
460under the author's canonical name.
461
462Keys of TABLE are author names. Values are alists of entries (FILE
f39caf44
KS
463\(ACTION . COUNT) ...). FILE is one file the author worked on. The
464rest of the entry is a list of keyword symbols describing what he did
465with the file and the number of each action.
3215096c
GM
466
467:wrote means the author wrote the file
f39caf44 468:changed means he changed the file COUNT times."
3932b29a 469
3215096c
GM
470 (let* ((enable-local-variables t)
471 (enable-local-eval t)
f39caf44
KS
472 (existing-buffer (get-file-buffer log-file))
473 (buffer (find-file-noselect log-file))
474 author file pos)
3215096c
GM
475 (save-excursion
476 (set-buffer buffer)
477 (save-restriction
478 (widen)
479 (goto-char (point-min))
480 (while (re-search-forward "^[0-9]\\|^[ \t]+\\* " nil t)
481 (beginning-of-line)
f39caf44 482 (setq pos (point))
3215096c
GM
483 (cond ((looking-at "^[0-9]+-[0-9]+-[0-9]+")
484 (skip-chars-forward " \t+:0-9-")
485 (setq author (buffer-substring-no-properties
486 (point) (line-end-position)))
487 (setq author (authors-canonical-author-name author))
488 (forward-line 1))
489 ((looking-at "^[ \t]+\\*")
490 (let ((line (buffer-substring-no-properties
491 (match-end 0) (line-end-position))))
492 (while (and (not (string-match ":" line))
493 (forward-line 1)
494 (not (looking-at ":\\|^[ \t]*$")))
495 (setq line (concat line
496 (buffer-substring-no-properties
497 (line-beginning-position)
498 (line-end-position)))))
499 (when (string-match ":" line)
500 (setq line (substring line 0 (match-beginning 0)))
501 (setq line (replace-regexp-in-string "[[(<{].*$" "" line))
502 (setq line (replace-regexp-in-string "," "" line))
503 (dolist (file (split-string line))
f39caf44
KS
504 (when (setq file (authors-canonical-file-name file log-file pos author))
505 ;;(message "%s changed %s" author file)
506 (authors-add author file :changed table))))
3215096c
GM
507 (forward-line 1)))))))
508 (unless existing-buffer
509 (kill-buffer buffer))))
510
511
512(defun authors-scan-el (file table)
513 "Scan Lisp file FILE for author information.
514TABLE is a hash table to add author information to."
515 (let* ((existing-buffer (get-file-buffer file))
516 (enable-local-variables t)
517 (enable-local-eval t)
518 (buffer (find-file-noselect file)))
519 (save-excursion
520 (set-buffer buffer)
521 (save-restriction
522 (widen)
523 (goto-char (point-min))
524 (while (and (re-search-forward
525 "^;+[ \t]*\\(Author\\|Commentary\\):[ \t]*" nil t)
526 (not (string= (match-string 1) "Commentary")))
527 ;; Some entries contain a year range in front of the
528 ;; author's name.
529 (skip-chars-forward "-0-9 \t")
530 (let ((author (buffer-substring-no-properties
531 (point) (line-end-position))))
532 (setq author (authors-canonical-author-name author))
533 (setq file (file-name-nondirectory file))
534 (authors-add author file :wrote table)))))
535 (unless existing-buffer
536 (kill-buffer buffer))))
537
538
0a521885
GM
539(defun authors-public-domain-p (file)
540 "Return t if FILE is a file that was put in public domain."
541 (let ((public-domain-p nil)
542 (list authors-public-domain-files))
543 (while (and list (not public-domain-p))
544 (when (string-match (car list) file)
545 (setq public-domain-p t))
546 (setq list (cdr list)))
547 public-domain-p))
548
f39caf44
KS
549(defvar authors-author-list)
550
551(defun authors-add-to-author-list (author changes)
552 "Insert information about AUTHOR's work on Emacs into `authors-author-list'.
553CHANGES is an alist of entries (FILE (ACTION . COUNT) ...), as produced by
554`authors-scan-change-log'.
555The element added to `authors-author-list' is (AUTHOR WROTE CHANGED), where
a1506d29 556WROTE and CHANGED are lists of the files written and changed by AUTHOR."
f39caf44
KS
557 (when author
558 (let ((nchanged 0)
559 wrote-list
560 changed-list)
3215096c
GM
561 (dolist (change changes)
562 (let ((actions (cdr change))
f39caf44
KS
563 (file (car change))
564 slot)
565 (if (assq :wrote actions)
566 (setq wrote-list
567 (cons
568 (if (authors-public-domain-p file)
569 (concat file " (public domain)")
570 file)
571 wrote-list))
572 (setq changed-list
573 (cons (cons file (cdr (assq :changed actions)))
574 changed-list)))))
575 (if wrote-list
576 (setq wrote-list (sort wrote-list 'string-lessp)))
577 (when changed-list
578 (setq changed-list (sort changed-list
579 (lambda (a b)
580 (if (= (cdr a) (cdr b))
581 (string-lessp (car a) (car b))
582 (> (cdr a) (cdr b))))))
583 (setq nchanged (length changed-list))
584 (setq changed-list (mapcar 'car changed-list)))
585 (if (> (- nchanged authors-many-files) 2)
586 (setcdr (nthcdr authors-many-files changed-list)
587 (list (format "and %d other files" (- nchanged authors-many-files)))))
588 (setq authors-author-list
589 (cons (list author wrote-list changed-list)
590 authors-author-list)))))
3215096c 591
3215096c
GM
592(defun authors (root)
593 "Extract author information from change logs and Lisp source files.
594ROOT is the root directory under which to find the files. If called
a1506d29 595interactively, ROOT is read from the minibuffer.
f39caf44
KS
596Result is a buffer *Authors* containing authorship information, and a
597buffer *Authors Errors* containing references to unknown files."
3215096c 598 (interactive "DEmacs source directory: ")
d2f288c6 599 (setq root (expand-file-name root))
3215096c
GM
600 (let ((logs (authors-process-lines "find" root "-name" "ChangeLog*"))
601 (table (make-hash-table :test 'equal))
f39caf44
KS
602 (buffer-name "*Authors*")
603 authors-checked-files-alist
604 authors-invalid-file-names)
d5ab63b2 605 (authors-add-fixed-entries table)
3215096c
GM
606 (unless (file-exists-p (expand-file-name "src/emacs.c" root))
607 (error "Not the root directory of Emacs: %s" root))
608 (dolist (log logs)
77777daf 609 (when (string-match "ChangeLog\\(.[0-9]+\\)?$" log)
3215096c
GM
610 (message "Scanning %s..." log)
611 (authors-scan-change-log log table)))
612 (let ((els (authors-process-lines "find" root "-name" "*.el")))
613 (dolist (file els)
614 (message "Scanning %s..." file)
615 (authors-scan-el file table)))
f39caf44 616 (message "Generating buffer %s..." buffer-name)
3215096c
GM
617 (set-buffer (get-buffer-create buffer-name))
618 (erase-buffer)
f39caf44 619 (set-buffer-file-coding-system authors-coding-system)
a1506d29 620 (insert
f39caf44
KS
621"Many people have contributed code included in the Free Software
622Foundation's distribution of GNU Emacs. To show our appreciation for
623their public spirit, we list here in alphabetical order a condensed
624list of their contributions.\n")
625 (let (authors-author-list a)
626 (maphash #'authors-add-to-author-list table)
a1506d29 627 (setq authors-author-list
f39caf44
KS
628 (sort authors-author-list
629 (lambda (a b) (string-lessp (car a) (car b)))))
630 (dolist (a authors-author-list)
631 (let ((author (car a))
632 (wrote (nth 1 a))
633 (changed (nth 2 a))
634 file)
635 (insert "\n" author ": ")
636 (when wrote
637 (insert "wrote")
638 (dolist (file wrote)
639 (if (> (+ (current-column) (length file)) 72)
640 (insert "\n "))
641 (insert " " file))
642 (insert "\n"))
643 (when changed
644 (if wrote
645 (insert "and "))
646 (insert "changed")
647 (dolist (file changed)
648 (if (> (+ (current-column) (length file)) 72)
649 (insert "\n "))
650 (insert " " file))
651 (insert "\n")))))
a1506d29 652 (insert "\nLocal" " Variables:\ncoding: "
f39caf44
KS
653 (symbol-name authors-coding-system) "\nEnd:\n")
654 (message "Generating buffer %s... done" buffer-name)
d5ab63b2 655 (unless noninteractive
f39caf44
KS
656 (when authors-invalid-file-names
657 (with-current-buffer (get-buffer-create "*Authors Errors*")
658 (erase-buffer)
659 (set-buffer-file-coding-system authors-coding-system)
660 (insert "Unrecognized file entries found:\n\n")
661 (mapcar (lambda (f) (if (not (string-match "^[A-Za-z]+$" f)) (insert f "\n")))
662 (sort authors-invalid-file-names 'string-lessp))
663 (goto-char (point-min))
664 (compilation-mode)
665 (message "Errors were found. See buffer %s" (buffer-name))))
d5ab63b2
GM
666 (pop-to-buffer buffer-name))))
667
668
d5ab63b2
GM
669(defun batch-update-authors ()
670 "Produce an AUTHORS file.
671Call this function in batch mode with two command line arguments FILE
672and ROOT. FILE is the file to write, ROOT is the root directory of
673the Emacs source tree, from which to build the file."
674 (unless noninteractive
675 (error "`batch-update-authors' is to be used only with -batch"))
676 (when (/= (length command-line-args-left) 2)
677 (error "Call `batch-update-authors' with the name of the file to write"))
678 (let* ((file (pop command-line-args-left))
679 (root (pop command-line-args-left)))
680 (authors root)
681 (write-file file)))
3215096c 682
ab5796a9 683;;; arch-tag: 659d5900-5ff2-43b0-954c-a315cc1e4dc1
55535639 684;;; authors.el ends here