1 ;;; authors.el --- utility for maintaining Emacs' AUTHORS file
3 ;; Copyright (C) 2000 Free Software Foundation, Inc.
5 ;; Author: Gerd Moellmann <gerd@gnu.org>
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)
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.
28 ;; Use M-x authors RET to create an *Authors* buffer that can used as
29 ;; or merged with Emacs' AUTHORS file.
33 (defconst authors-many-files
20
34 "Maximum number of files for which to print individual information.
35 If an author has modified more files, only a single entry is
36 printed telling how many files he changed, instead of listing each
39 (defconst authors-aliases
40 '(("eliz" .
"Eli Zaretskii")
41 ("Richard Stallman" .
"Richard M. Stallman")
42 ("Richard M. Stallman,,," .
"Richard M. Stallman")
43 ("rms@gnu.org" .
"Richard M. Stallman")
44 ("NIIBE Yutaka" .
"Yutaka NIIBE")
45 ("(saw@cebaf.gov)" .
"Stephen A. Wood")
46 ("(pmr@legacy.pajato.com)" .
"Paul Reilly")
47 ("(Eric Youngdale at youngdale@v6550c.nrl.navy.mil)" .
"Eric Youngdale")
48 ("<Daniel.Pfeiffer@Informatik.START.db.de>" .
"Daniel Pfeiffer")
49 ("<Daniel.Pfeiffer@Informatik.START.dbp.de>" .
"Daniel Pfeiffer")
50 ("(afs@hplb.hpl.hp.com)" .
"ignore")
51 ("<Use-Author-Address-Header@\\[127.1\\]>" .
"ignore")
52 ("Code Extracted" .
"ignore")
54 ("David M. Koppelman, Koppel@Ee.Lsu.Edu" .
"David M. Koppelman")
55 ("jka@ece.cmu.edu" .
"Jay K. Adams")
56 ("Per Abhiddenware; you can redistribute it and/or modify" .
"Per Abrahamsen")
57 ("Andrw Innes" .
"Andrew Innes")
58 ("Barry Warsaw" .
"Barry A. Warsaw")
59 ("Barry A. Warsaw, Century Computing, Inc." .
"Barry A. Warsaw")
60 ("Barry A. Warsaw, ITB" .
"Barry A. Warsaw")
61 ("Ken'ichi Handa" .
"Kenichi Handa")
62 ("Bob Chassell" .
"Robert J. Chassell")
63 ("SL Baur" .
"Steven L. Baur")
64 ("Steven L Baur" .
"Steven L. Baur")
65 ("eggert" .
"Paul Eggert")
66 ("voelker" .
"Geoff Voelker")
67 ("rms" .
"Richard M. Stallman")
68 ("Edward M Reingold" .
"Edward M. Reingold")
69 ("Eric Ludlam" .
"Eric M. Ludlam")
70 ("Eric Raymond" .
"Eric S. Raymond")
71 ("Francois Pinard" .
"François Pinard")
72 ("Fred Pierresteguy" .
"Frederic Pierresteguy")
73 ("Hallvard B Furuseth" .
"Hallvard B. Furuseth")
74 ("ISO-2022-JP" .
"ignore")
75 ("Jens-Ulrik Petersen" .
"Jens-Ulrik Holger Petersen")
76 ("Christoph.Wedler@sap.com" .
"Christoph Wedler")
77 ("Jonathan Kamens" .
"Jonathan I. Kamens")
78 ("Kim Storm" .
"Kim F. Storm")
79 ("Marcus Daniels" .
"Marcus G. Daniels")
80 ("Michael I Bushnell" .
"Michael I. Bushnell")
81 ("Michael I. Bushnell, P/Bsg" .
"Michael I. Bushnell")
82 ("Reingold Edward M" .
"Edward M. Reingold")
83 ("Roland B Roberts" .
"Roland B. Roberts")
84 ("Sam Shteingold" .
"Sam Steingold")
85 ("W{\L}Odek Bzyl" .
"Wlodzimierz Bzyl")
86 ("Kenneth Manheimer" .
"Ken Manheimer")
87 ("Kenichi HANDA" .
"Kenichi Handa")
88 ("Jay Adams" .
"Jay R. Adams")
89 ("Joe Arceneaux" .
"Josef Arceneaux")
90 ("K. Berry" .
"Karl Berry")
91 ("Michael Ernst" .
"Michael D. Ernst")
92 ("Dave Gillespie" .
"David Gillespie")
93 ("Shane Hartman" .
"K. Shane Hartman")
94 ("Francesco Potorti`" .
"Francesco Potorti")
95 ("Roland Roberts" .
"Roland B. Roberts")
96 ("David Smith" .
"David M. Smith")
98 "Alist of author aliases.
100 Each entry is of the form (REGEXP . ALIAS). If an author's name
101 matches REGEXP, use ALIAS instead. The special alias \"ignore\" means
102 ignore that author.")
105 (defvar authors-public-domain-files
117 "List of regexps matching files for which the FSF doesn't need papers.")
120 (defvar authors-obsolete-files-regexps
123 "vc-\\(rcs\\|cvs\\|sccs\\)-hooks\\.el$")
124 "List of regexps matching obsolete files.
125 Changes to files matching one of the regexps in this list are not
129 (defconst authors-fixed-entries
130 '(("Joe Arceneax" :wrote
"xrdb.c")
131 ("Blitz Product Development Corporation" :wrote
"ispell.el")
132 ("Frank Bresz" :wrote
"diff.el")
133 ("David M. Brown" :wrote
"array.el")
134 ("Gary Byers" :changed
"xenix.h")
135 ("Shawn M. Carey" :wrote
"freebsd.h")
136 ("Eric Decker" :changed
"hp9000s800.h" "hpux.h" "sysdep.c")
137 ("Lawrence R. Dodd" :wrote
"dired-x.el")
138 ("Viktor Dukhovni" :wrote
"unexsunos4.c")
139 ("Paul Eggert" :wrote
"rcs2log" "vcdiff")
140 ("Fred Fish" :changed
"unexec.c")
141 ("Tim Fleehart" :wrote
"makefile.nt")
142 ("Keith Gabryelski" :wrote
"hexl.c")
143 ("Kevin Gallagher" :wrote
"flow-ctrl.el")
144 ("Howard Gayle" :wrote
"disp-table.el" "iso-syntax.el" "casetab.c")
145 ("Stephen Gildea" :wrote
"refcard.tex" "mh-funcs.el" "mh-pick.el")
146 ("David Gillespie" :wrote
"cl.texinfo")
147 ("Hewlett-Packard" :changed
"emacsclient.c" "emacsserver.c"
148 "server.el" "keyboard.c")
149 ("Thomas Horsley" :wrote
"cxux.h" "cxux7.h")
150 ("Indiana University Foundation" :changed
"buffer.c" "buffer.h"
151 "indent.c" "search.c" "xdisp.c" "region-cache.c" "region-cache.h")
152 ("International Business Machines" :changed
"emacs.c" "fileio.c"
153 "ibmrt.h" "process.c" "sysdep.c" "unexec.c" "ibmrt-aix.h")
154 ("Ishikawa Chiaki" :changed
"aviion.h" "dgux.h")
155 ("Michael K. Johnson" :changed
"configure.in" "emacs.c" "intel386.h"
156 "mem-limits.h" "process.c" "template.h" "sysdep.c" "syssignal.h" "systty.h" "unexec.c"
157 "ymakefile" "linux.h")
158 ("Kyle E. Jones" :wrote
"mldrag.el")
159 ("Kenry Kautz" :wrote
"bib-mode.el")
160 ("Joseph M. Kelsey" :changed
"fileio.c" "vms-pwd.h" "vmsfns.c" "dir.h"
162 ("Sam Kendall" :changed
"etags.c" "etags.el")
163 ("Richard King" :wrote
"backquote.el" "userlock.el" "filelock.c")
164 ("Larry Kolodney" :wrote
"cvtmail.c")
165 ("Sebastian Kremer" :changed
"add-log.el")
166 ("Mark Lambert" :changed
"process.c" "process.h")
167 ("Aaron Larson" :changed
"bibtex.el")
168 ("James R. Larus" :wrote
"mh-e.el")
169 ("Lars Lindberg" :changed
"dabbrev.el" :wrote
"imenu.el")
170 ("Lucid, Inc." :changed
"bytecode.c" "byte-opt.el" "byte-run.el"
171 "bytecomp.el" "delsel.el" "disass.el" "faces.el" "font-lock.el"
172 "lmenu.el" "lselect.el" "mailabbrev.el" "select.el" "xfaces.c"
174 ("MCC" :changed
"etags.c" "emacsclient.c" "emacsserver.c" "movemail.c"
175 "rmail.el" "rmailedit.el" "rmailkwd.el"
176 "rmailmsc.el" "rmailout.el" "rmailsum.el" "scribe.el"
177 "server.el" "lisp.h" "sysdep.c" "unexec.c" :wrote
"xmenu.c")
178 ("Niall Mansfield" :changed
"etags.c")
179 ("Brian Marick" :wrote
"hideif.el")
180 ("Marko Kohtala" :changed
"info.el")
181 ("Sidney Markowitz" :changed
"doctor.el")
182 ("Richard Mlynarik" :wrote
"env.c" "ehelp.el")
183 ("Mosur Mohan" :changed
"etags.c")
184 ("Jeff Morgenthaler" :changed
"flow-ctrl.el" "vt200.el" "vt201.el"
185 "vt220.el" "vt240.el")
186 ("Motorola" :changed
"buff-menu.el")
187 ("Hiroshi Nakano" :changed
"ralloc.c")
188 ("Sundar Narasimhan" :changed
"rnewspost.el")
189 ("NeXT, Inc." :wrote
"unexnext.c")
190 ("Mark Neale" :changed
"fortran.el")
191 ("Martin Neitzel" :changed
"sc.el")
192 ("Andrew Oram" :changed
"miscellaneous changes to files in man/"
194 ("Frederic Pierresteguy" :wrote
"widget.c")
195 ("Michael D. Prange" :changed
"tex-mode.el")
196 ("Paul Reilly" :wrote
"gux5-4r2.h" "dgux5-4r3.h")
197 ("Roland B Roberts" :changed
"files.el" "sort.el" "vmsproc.el"
198 "buffer.h" "callproc.c" "dired.c" "process.c" "sysdep.c" "systty.h"
199 "vmspaths.h" "build.com" "compile.com" "kepteditor.com" "precomp.com"
200 :wrote
"logout.com" "mailemacs.com")
201 ("Guillermo J. Rozas" :wrote
"fakemail.c")
202 ("Wolfgang Rupprecht" :changed
"lisp-mode.el" "loadup.el"
203 "sort.el" "alloc.c" "callint.c"
204 "config.h.in" "crt0.c" "data.c" "fns.c"
205 "lisp.h" "lread.c" "sun3.h"
206 "print.c" "ymakefile" :wrote
"float-sup.el" "floatfns.c")
207 ("Schlumberger Technology Corporation" :changed
"gud.el")
208 ("Gregor Schmid" :wrote
"tcl-mode.el")
209 ("Rainer Schoepf" :wrote
"alpha.h" "unexalpha.c")
210 ("William Sommerfeld" :wrote
"emacsclient.c" "emacsserver.c" "scribe.el")
211 ("Leigh Stoller" :changed
"emacsclient.c" "emacsserver.c" "server.el")
212 ("Steve Strassman" :wrote
"spook.el")
213 ("Shinichirou Sugou" :changed
"etags.c")
214 ("Sun Microsystems, Inc" :changed
"emacsclient.c" "emacsserver.c"
215 "server.el" :wrote
"emacs.icon" "emacstool.1" "emacstool.c" "sun-curs.el"
216 "sun-fns.el" "sun-mouse.el" "sun.el" "sunfns.c")
217 ("Kayvan Sylvan" :changed
"sc.el")
218 ("Spencer Thomas" :changed
"emacsclient.c" "emacsserver.c" "server.el"
219 "dabbrev.el" "unexec.c" "tcp.c" "gnus.texi")
220 ("Jonathan Vail" :changed
"vc.el")
221 ("James Van Artsdalen" :changed
"usg5-4.h" "unexec.c")
222 ("Geoff Voelker" :wrote
"src/makefile.nt" "lisp/makefile.nt" "winnt.el"
223 "nt.c" "nt.h" "ntheap.c" "ntheap.h" "ntinevt.c"
224 "ntproc.c" "ntterm.c" "windowsnt.h")
225 ("Morten Welinder" :wrote
"dosfns.c" "[many MSDOS files]" "msdos.h")
226 ("Pace Willisson" :wrote
"ispell.el")
227 ("Garrett Wollman" :changed
"sendmail.el")
228 ("Dale Worley" :changed
"mail-extr.el")
229 ("Jamie Zawinski" :changed
"bytecode.c" :wrote
"disass.el" "tar-mode.el"))
230 "Actions taken from the original, manually (un)maintained AUTHORS file.")
233 (defun authors-add-fixed-entries (table)
234 "Add actions from `authors-fixed-entries' to TABLE."
235 (dolist (entry authors-fixed-entries
)
236 (let ((author (car entry
))
238 (dolist (item (cdr entry
))
241 (authors-add author item action table
))))))
244 (defun authors-obsolete-file-p (file)
245 "Return non-nil if FILE is obsolete.
246 FILE is considered obsolete if it matches on of the regular expressions
247 from `authors-obsolete-files-regexps'."
249 (regexps authors-obsolete-files-regexps
))
250 (while (and regexps
(not obsolete-p
))
251 (setq obsolete-p
(string-match (car regexps
) file
)
252 regexps
(cdr regexps
)))
256 (defun authors-add (author file action table
)
257 "Record that AUTHOR worked on FILE.
258 ACTION is a keyword symbol describing what he did. Record file,
259 author and what he did in hash table TABLE. See the description of
260 `authors-scan-change-log' for the structure of the hash table."
261 (unless (or (authors-obsolete-file-p file
)
263 (let* ((value (gethash author table
))
264 (entry (assoc file value
)))
266 (puthash author
(cons (list file action
) value
) table
)
267 (unless (memq action entry
)
268 (nconc entry
(list action
)))))))
271 (defun authors-process-lines (program &rest args
)
272 "Execute PROGRAM with ARGS, returning its output as a list of lines.
273 Signal an error if the program returns with a non-zero exit status."
275 (let ((status (apply 'call-process program nil
(current-buffer) nil args
)))
276 (unless (eq status
0)
277 (error "%s exited with status %s" program status
))
278 (goto-char (point-min))
281 (setq lines
(cons (buffer-substring-no-properties
282 (line-beginning-position)
289 (defun authors-canonical-author-name (author)
290 "Return a canonicalized form of AUTHOR, an author name.
291 If AUTHOR has an alias, use that. Remove email addresses. Capitalize
292 words in the author's name."
293 (let ((aliases authors-aliases
))
295 (when (string-match (car (car aliases
)) author
)
296 (setq author
(cdr (car aliases
))
298 (setq aliases
(cdr aliases
))))
299 (setq author
(replace-regexp-in-string "[ \t]*[(<].*$" "" author
))
300 (setq author
(replace-regexp-in-string "^[ \t]+" "" author
))
301 (setq author
(replace-regexp-in-string "[ \t]+$" "" author
))
305 (defun authors-scan-change-log (file table
)
306 "Scan change log FILE for author information.
308 For each change mentioned in the log, add an entry to hash table TABLE
309 under the author's canonical name.
311 Keys of TABLE are author names. Values are alists of entries (FILE
312 ACTION...). FILE is one file the author worked on. The rest of the
313 entry is a list of keyword symbols describing what he did with the
316 :wrote means the author wrote the file
317 :changed means he changed the file."
319 (let* ((enable-local-variables t
)
320 (enable-local-eval t
)
321 (existing-buffer (get-file-buffer file
))
322 (buffer (find-file-noselect file
))
328 (goto-char (point-min))
329 (while (re-search-forward "^[0-9]\\|^[ \t]+\\* " nil t
)
331 (cond ((looking-at "^[0-9]+-[0-9]+-[0-9]+")
332 (skip-chars-forward " \t+:0-9-")
333 (setq author
(buffer-substring-no-properties
334 (point) (line-end-position)))
335 (setq author
(authors-canonical-author-name author
))
337 ((looking-at "^[ \t]+\\*")
338 (let ((line (buffer-substring-no-properties
339 (match-end 0) (line-end-position))))
340 (while (and (not (string-match ":" line
))
342 (not (looking-at ":\\|^[ \t]*$")))
343 (setq line
(concat line
344 (buffer-substring-no-properties
345 (line-beginning-position)
346 (line-end-position)))))
347 (when (string-match ":" line
)
348 (setq line
(substring line
0 (match-beginning 0)))
349 (setq line
(replace-regexp-in-string "[[(<{].*$" "" line
))
350 (setq line
(replace-regexp-in-string "," "" line
))
351 (dolist (file (split-string line
))
352 (setq file
(file-name-nondirectory file
))
353 ;(message "%s changed %s" author file)
354 (authors-add author file
:changed table
)))
355 (forward-line 1)))))))
356 (unless existing-buffer
357 (kill-buffer buffer
))))
360 (defun authors-scan-el (file table
)
361 "Scan Lisp file FILE for author information.
362 TABLE is a hash table to add author information to."
363 (let* ((existing-buffer (get-file-buffer file
))
364 (enable-local-variables t
)
365 (enable-local-eval t
)
366 (buffer (find-file-noselect file
)))
371 (goto-char (point-min))
372 (while (and (re-search-forward
373 "^;+[ \t]*\\(Author\\|Commentary\\):[ \t]*" nil t
)
374 (not (string= (match-string 1) "Commentary")))
375 ;; Some entries contain a year range in front of the
377 (skip-chars-forward "-0-9 \t")
378 (let ((author (buffer-substring-no-properties
379 (point) (line-end-position))))
380 (setq author
(authors-canonical-author-name author
))
381 (setq file
(file-name-nondirectory file
))
382 (authors-add author file
:wrote table
)))))
383 (unless existing-buffer
384 (kill-buffer buffer
))))
387 (defun authors-public-domain-p (file)
388 "Return t if FILE is a file that was put in public domain."
389 (let ((public-domain-p nil
)
390 (list authors-public-domain-files
))
391 (while (and list
(not public-domain-p
))
392 (when (string-match (car list
) file
)
393 (setq public-domain-p t
))
394 (setq list
(cdr list
)))
398 (defun authors-print (author changes
)
399 "Insert information about AUTHOR's work on Emacs into the current buffer.
400 CHANGES is an alist of entries (FILE ACTION...), as produced by
401 `authors-scan-change-log'."
402 (unless (equal author
"Ignore")
404 (dolist (change changes
)
405 (let ((actions (cdr change
))
407 (if (memq :wrote actions
)
409 (insert author
" (wrote) " file
)
410 (when (authors-public-domain-p file
)
411 (insert " (public domain)"))
413 (setq nchanged
(1+ nchanged
)))))
414 (if (> nchanged authors-many-files
)
415 (insert author
" (changed) [more than "
416 (int-to-string authors-many-files
) " files]\n")
417 (dolist (change changes
)
418 (let ((actions (cdr change
))
420 (unless (memq :wrote actions
)
421 (insert author
" (changed) " file
"\n"))))))))
424 (defun authors (root)
425 "Extract author information from change logs and Lisp source files.
426 ROOT is the root directory under which to find the files. If called
427 interactively, ROOT is read from the minibuffer. Result is a
428 buffer *Authors* containing authorship information."
429 (interactive "DEmacs source directory: ")
430 (setq root
(expand-file-name root
))
431 (let ((logs (authors-process-lines "find" root
"-name" "ChangeLog*"))
432 (table (make-hash-table :test
'equal
))
433 (buffer-name "*Authors*"))
434 (authors-add-fixed-entries table
)
435 (unless (file-exists-p (expand-file-name "src/emacs.c" root
))
436 (error "Not the root directory of Emacs: %s" root
))
438 (when (and (string-match "ChangeLog\\(.[0-9]+\\)?$" log
)
439 (not (string-match "/lispref/" log
)))
440 (message "Scanning %s..." log
)
441 (authors-scan-change-log log table
)))
442 (let ((els (authors-process-lines "find" root
"-name" "*.el")))
444 (message "Scanning %s..." file
)
445 (authors-scan-el file table
)))
446 (set-buffer (get-buffer-create buffer-name
))
448 (set-buffer-file-coding-system 'iso-2022-7bit
)
449 (maphash #'authors-print table
)
450 (sort-lines nil
(point-min) (point-max))
451 (insert "\nLocal" " Variables:\ncoding: iso-2022-7bit\nEnd:\n")
452 (unless noninteractive
453 (pop-to-buffer buffer-name
))))
456 (defun batch-update-authors ()
457 "Produce an AUTHORS file.
458 Call this function in batch mode with two command line arguments FILE
459 and ROOT. FILE is the file to write, ROOT is the root directory of
460 the Emacs source tree, from which to build the file."
461 (unless noninteractive
462 (error "`batch-update-authors' is to be used only with -batch"))
463 (when (/= (length command-line-args-left
) 2)
464 (error "Call `batch-update-authors' with the name of the file to write"))
465 (let* ((file (pop command-line-args-left
))
466 (root (pop command-line-args-left
)))
470 ;;; authors.el ends here