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