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