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