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