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