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