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