authors.el 26.2 KB
Newer Older
Jan Djärv's avatar
Jan Djärv committed
1
;;; authors.el --- utility for maintaining Emacs' AUTHORS file -*-coding: iso-2022-7bit;-*-
Gerd Moellmann's avatar
Gerd Moellmann committed
2

Glenn Morris's avatar
Glenn Morris committed
3
;; Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005,
4
;;   2006 Free Software Foundation, Inc.
Gerd Moellmann's avatar
Gerd Moellmann committed
5

6
;; Author: Gerd Moellmann <gerd@gnu.org>
7
;; Maintainer: Kim F. Storm <storm@cua.dk>
8 9
;; Keywords: maint

Gerd Moellmann's avatar
Gerd Moellmann committed
10 11 12 13 14 15 16 17 18 19 20 21 22 23
;; This file is part of GNU Emacs.

;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING.  If not, write to the
Lute Kamstra's avatar
Lute Kamstra committed
24 25
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
Gerd Moellmann's avatar
Gerd Moellmann committed
26 27 28 29 30 31 32 33

;;; Commentary:

;; Use M-x authors RET to create an *Authors* buffer that can used as
;; or merged with Emacs' AUTHORS file.

;;; Code:

34 35 36
(defvar authors-coding-system 'iso-2022-7bit
  "Coding system used in the AUTHORS file.")

Gerd Moellmann's avatar
Gerd Moellmann committed
37 38
(defconst authors-many-files 20
  "Maximum number of files for which to print individual information.
39 40 41
If an author has modified more files, only the names of the most
frequently modified files are printed and a count of the additional
files.")
Gerd Moellmann's avatar
Gerd Moellmann committed
42 43

(defconst authors-aliases
44
  '(
45
    ("Andrew Csillag" "Drew Csillag")
46
    ("Anna M. Bigatti" "Anna Bigatti")
47 48 49 50 51 52 53 54 55
    ("Barry A. Warsaw" "Barry A. Warsaw, Century Computing, Inc."
     "Barry A. Warsaw, ITB" "Barry Warsaw")
    ("Bj,Av(Brn Torkelsson" "Bjorn Torkelsson")
    ("Brian Fox" "Brian J. Fox")
    ("Christoph Wedler" "Christoph.Wedler@sap.com")
    ("Daniel Pfeiffer" "<Daniel.Pfeiffer@Informatik.START.db.de>"
     "<Daniel.Pfeiffer@Informatik.START.dbp.de>")
    ("David Gillespie" "Dave Gillespie")
    ("David K,Ae(Bgedal" "David K..edal")
56 57
    ("David M. Koppelman" "David M. Koppelman, Koppel@Ee.Lsu.Edu"
     "David Koppelman")
58 59
    ("David M. Smith" "David Smith" "David M Smith")
    ("Ed L. Cashin" "Ed L Cashin")
60 61 62
    ("Edward M. Reingold" "Ed Reingold" "Edward M Reingold"
     "Reingold Edward M")
    ("Eli Zaretskii" "eliz")
Kim F. Storm's avatar
Kim F. Storm committed
63
    ("Emilio C. Lopes" "Emilio Lopes")
64
    ("Era Eriksson" "Era@Iki.Fi")
65 66 67
    ("Eric M. Ludlam" "Eric Ludlam")
    ("Eric S. Raymond" "Eric Raymond")
    ("Eric Youngdale" "(Eric Youngdale at youngdale@v6550c.nrl.navy.mil)")
68
    ("Francis J. Wright" "Dr Francis J. Wright" "Francis Wright")
69
    ("Fran,Ag(Bois Pinard" "Francois Pinard")
70
    ("Francesco Potort,Al(B" "Francesco Potorti" "Francesco Potorti`")
71 72 73
    ("Frederic Pierresteguy" "Fred Pierresteguy")
    ("Geoff Voelker" "voelker")
    ("Hallvard B. Furuseth" "Hallvard B Furuseth")
74
    ("Hrvoje Nik,B9(Bi,Bf(B" "Hrvoje Niksic")
75 76 77 78 79 80 81
    (nil "(afs@hplb.hpl.hp.com)")
    (nil "<Use-Author-Address-Header@\\[127.1\\]>")
    (nil "Code Extracted")
    (nil "Fsf")
    (nil "ISO-2022-JP")
    ("Jaeyoun Chung" "Jae-youn Chung" "Jae-you Chung" "Chung Jae-youn")
    ("Jan Dj,Ad(Brv" "Jan D." "Jan Djarv")
82 83
    ("Jay K. Adams" "jka@ece.cmu.edu" "Jay Adams")
    ("J,Ai(Br,At(Bme Marant" "J,bi(Br,bt(Bme Marant" "Jerome Marant")
84
    ("Jens-Ulrik Holger Petersen" "Jens-Ulrik Petersen")
85
    ("Jeremy Bertram Maitin-Shepard" "Jeremy Maitin-Shepard")
Kim F. Storm's avatar
Kim F. Storm committed
86
    ("Johan Bockg,Ae(Brd" "Johan Bockgard")
Kim F. Storm's avatar
Kim F. Storm committed
87
    ("John W. Eaton" "John Eaton")
88 89
    ("Jonathan I. Kamens" "Jonathan Kamens")
    ("Joseph Arceneaux" "Joe Arceneaux")
Kim F. Storm's avatar
Kim F. Storm committed
90
    ("Juan Le,As(Bn Lahoz Garc,Am(Ba" "Juan-Leon Lahoz Garcia")
91 92
    ("K. Shane Hartman" "Shane Hartman")
    ("Kai Gro,A_(Bjohann" "Kai Grossjohann" "Kai Gro,b_(Bjohann"
93 94
     "Kai.Grossjohann@Cs.Uni-Dortmund.De"
     "Kai.Grossjohann@Gmx.Net")
95
    ("Karl Berry" "K. Berry")
Károly Lőrentey's avatar
Update.  
Károly Lőrentey committed
96
    ("K,Aa(Broly L$,1 q(Brentey" "K,Aa(Broly L,Bu(Brentey" "L$,1 q(Brentey K,Aa(Broly")
97
    ("Kazushi Marukawa" "Kazushi")
98 99
    ("Ken Manheimer" "Kenneth Manheimer")
    ("Kenichi Handa" "Ken'ichi Handa" "Kenichi HANDA")
Kim F. Storm's avatar
Kim F. Storm committed
100
    ("Kevin Greiner" "Kevin J. Greiner")
101
    ("Kim F. Storm" "Kim Storm")
102
    ("Kyle Jones" "Kyle E. Jones")
103
    ("Marcus G. Daniels" "Marcus Daniels")
104 105 106
    ("Mark D. Baushke" "Mark D Baushke")
    ("Martin Lorentzon" "Martin Lorentzson")
    ("Matt Swift" "Matthew Swift")
Kim F. Storm's avatar
Kim F. Storm committed
107
    ("Michael R. Mauger" "Michael Mauger")
108
    ("Michael D. Ernst" "Michael Ernst")
109
    ("Micha,Ak(Bl Cadilhac" "Michael Cadilhac")
110
    ("Michael I. Bushnell" "Michael I Bushnell" "Michael I. Bushnell, P/Bsg")
Kim F. Storm's avatar
Kim F. Storm committed
111
    ("Mikio Nakajima" "Nakajima Mikio")
112 113
    ("Paul Eggert" "eggert")
    ("Paul Reilly" "(pmr@legacy.pajato.com)")
114
    ("Pavel Jan,Bm(Bk" "Pavel Jan,Am(Bk Ml." "Pavel Jan,Am(Bk" "Pavel@Janik.Cz")
115
    ("Per Abrahamsen" "Per Abhiddenware")
116 117
    ("Peter S. Galbraith" "Peter Galbraith")
    ("Peter Runestig" "Peter 'luna' Runestig")
118 119
    ("Peter S. Galbraith" "Peter S Galbraith")
    ("Richard M. Stallman" "Richard M. Stallman,,," "Richard Stallman"
120
     "rms" "rms@gnu.org")
121 122 123
    ("Robert J. Chassell" "Bob Chassell")
    ("Roland B. Roberts" "Roland B Roberts" "Roland Roberts")
    ("Rui-Tao Dong" "Rui-Tao Dong ~{6-Hpln~}")
Romain Francoise's avatar
Romain Francoise committed
124
    ("Sacha Chua" "Sandra Jean Chua")
125
    ("Sam Steingold" "Sam Shteingold")
126
    ("Satyaki Das" "Indexed search by Satyaki Das")
127
    ("Stefan Monnier" "Stefan")
128 129 130
    ("Stephen A. Wood" "(saw@cebaf.gov)")
    ("Steven L. Baur" "SL Baur" "Steven L Baur")
    ("Takaaki Ota" "Tak Ota")
Kim F. Storm's avatar
Kim F. Storm committed
131
    ("Takahashi Naoto" "Naoto Takahashi")
132
    ("Teodor Zlatanov" "Ted Zlatanov")
133 134 135 136
    ("Torbj,Av(Brn Axelsson" "Torbjvrn Axelsson")
    ("Torbj,Av(Brn Einarsson" "Torbj.*rn Einarsson")
    ("Toru Tomabechi" "Toru Tomabechi,")
    ("Vincent Del Vecchio" "Vince Del Vecchio")
137
    ("William M. Perry" "Bill Perry")
138 139
    ("Wlodzimierz Bzyl" "W.*dek Bzyl")
    ("Yutaka NIIBE" "NIIBE Yutaka")
140
    )
Gerd Moellmann's avatar
Gerd Moellmann committed
141 142
  "Alist of author aliases.

143
Each entry is of the form (REALNAME REGEXP...).  If an author's name
144
matches one of the REGEXPs, use REALNAME instead.
145
If REALNAME is nil, ignore that author.")
Gerd Moellmann's avatar
Gerd Moellmann committed
146 147


148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
(defvar authors-public-domain-files
  '("auto-show\\.el"
    "form-d2\\.el"
    "emerge\\.el"
    "unused\\.el"
    "vi\\.el"
    "feedmail\\.el"
    "mailpost\\.el"
    "hanoi\\.el"
    "meese\\.el"
    "studly\\.el"
    "modula2\\.el")
  "List of regexps matching files for which the FSF doesn't need papers.")


163 164 165 166 167 168 169 170
(defvar authors-obsolete-files-regexps
  '("vc-\\*\\.el$"
    "spec.txt$"
    "vc-\\(rcs\\|cvs\\|sccs\\)-hooks\\.el$")
  "List of regexps matching obsolete files.
Changes to files matching one of the regexps in this list are not
listed.")

Kim F. Storm's avatar
Kim F. Storm committed
171 172 173 174
(defconst authors-ignored-files
  '("external-lisp"
    "lock" "share-lib" "local-lisp"
    "noleim-Makefile.in"
175
    "NEWS" "PROBLEMS" "FAQ" "AUTHORS" "FOR-RELEASE" "TODO")
Kim F. Storm's avatar
Kim F. Storm committed
176 177
  "List of files and directories to ignore.
Changes to files in this list are not listed.")
178

179
(defconst authors-fixed-entries
180
  '(("Richard M. Stallman" :wrote "[The original GNU Emacs and numerous files]")
181
    ("Joseph Arceneaux" :wrote "xrdb.c")
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
    ("Blitz Product Development Corporation" :wrote "ispell.el")
    ("Frank Bresz" :wrote "diff.el")
    ("David M. Brown" :wrote "array.el")
    ("Gary Byers" :changed "xenix.h")
    ("Shawn M. Carey" :wrote "freebsd.h")
    ("Eric Decker"  :changed "hp9000s800.h" "hpux.h" "sysdep.c")
    ("Lawrence R. Dodd" :wrote "dired-x.el")
    ("Viktor Dukhovni" :wrote "unexsunos4.c")
    ("Paul Eggert" :wrote "rcs2log" "vcdiff")
    ("Fred Fish" :changed "unexec.c")
    ("Tim Fleehart" :wrote "makefile.nt")
    ("Keith Gabryelski" :wrote "hexl.c")
    ("Kevin Gallagher" :wrote "flow-ctrl.el")
    ("Howard Gayle" :wrote "disp-table.el" "iso-syntax.el" "casetab.c")
    ("Stephen Gildea" :wrote "refcard.tex" "mh-funcs.el" "mh-pick.el")
    ("David Gillespie" :wrote "cl.texinfo")
    ("Hewlett-Packard" :changed "emacsclient.c" "emacsserver.c"
     "server.el" "keyboard.c")
    ("Thomas Horsley" :wrote "cxux.h" "cxux7.h")
    ("Indiana University Foundation" :changed "buffer.c" "buffer.h"
     "indent.c" "search.c" "xdisp.c" "region-cache.c" "region-cache.h")
    ("International Business Machines" :changed "emacs.c" "fileio.c"
     "ibmrt.h" "process.c" "sysdep.c" "unexec.c" "ibmrt-aix.h")
    ("Ishikawa Chiaki" :changed "aviion.h" "dgux.h")
    ("Michael K. Johnson" :changed "configure.in" "emacs.c" "intel386.h"
     "mem-limits.h" "process.c" "template.h" "sysdep.c" "syssignal.h" "systty.h" "unexec.c"
      "ymakefile" "linux.h")
Kim F. Storm's avatar
Kim F. Storm committed
209
    ("Kyle Jones" :wrote "mldrag.el")
Kim F. Storm's avatar
Kim F. Storm committed
210
    ("Henry Kautz" :wrote "bib-mode.el")
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247
    ("Joseph M. Kelsey" :changed "fileio.c" "vms-pwd.h" "vmsfns.c" "dir.h"
     "uaf.h")
    ("Sam Kendall" :changed "etags.c" "etags.el")
    ("Richard King" :wrote "backquote.el" "userlock.el" "filelock.c")
    ("Larry Kolodney" :wrote "cvtmail.c")
    ("Sebastian Kremer" :changed "add-log.el")
    ("Mark Lambert" :changed "process.c" "process.h")
    ("Aaron Larson" :changed "bibtex.el")
    ("James R. Larus" :wrote "mh-e.el")
    ("Lars Lindberg" :changed "dabbrev.el" :wrote "imenu.el")
    ("Lucid, Inc." :changed "bytecode.c" "byte-opt.el" "byte-run.el"
     "bytecomp.el" "delsel.el" "disass.el" "faces.el" "font-lock.el"
     "lmenu.el" "lselect.el" "mailabbrev.el" "select.el" "xfaces.c"
     "xselect.c")
    ("MCC" :changed "etags.c" "emacsclient.c" "emacsserver.c" "movemail.c"
     "rmail.el" "rmailedit.el" "rmailkwd.el"
     "rmailmsc.el" "rmailout.el" "rmailsum.el" "scribe.el"
     "server.el" "lisp.h" "sysdep.c" "unexec.c" :wrote "xmenu.c")
    ("Niall Mansfield" :changed "etags.c")
    ("Brian Marick" :wrote "hideif.el")
    ("Marko Kohtala" :changed "info.el")
    ("Sidney Markowitz" :changed "doctor.el")
    ("Richard Mlynarik" :wrote "env.c" "ehelp.el")
    ("Mosur Mohan" :changed "etags.c")
    ("Jeff Morgenthaler" :changed "flow-ctrl.el" "vt200.el" "vt201.el"
     "vt220.el" "vt240.el")
    ("Motorola" :changed "buff-menu.el")
    ("Hiroshi Nakano" :changed "ralloc.c")
    ("Sundar Narasimhan" :changed "rnewspost.el")
    ("NeXT, Inc." :wrote "unexnext.c")
    ("Mark Neale" :changed "fortran.el")
    ("Martin Neitzel" :changed "sc.el")
    ("Andrew Oram" :changed "miscellaneous changes to files in man/"
     "man/calendar.texi")
    ("Frederic Pierresteguy" :wrote "widget.c")
    ("Michael D. Prange" :changed "tex-mode.el")
    ("Paul Reilly" :wrote "gux5-4r2.h" "dgux5-4r3.h")
248
    ("Roland B. Roberts" :changed "files.el" "sort.el" "vmsproc.el"
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278
     "buffer.h" "callproc.c" "dired.c" "process.c" "sysdep.c" "systty.h"
     "vmspaths.h" "build.com" "compile.com" "kepteditor.com" "precomp.com"
     :wrote "logout.com" "mailemacs.com")
    ("Guillermo J. Rozas" :wrote "fakemail.c")
    ("Wolfgang Rupprecht" :changed "lisp-mode.el" "loadup.el"
     "sort.el" "alloc.c" "callint.c"
     "config.h.in" "crt0.c" "data.c" "fns.c"
     "lisp.h" "lread.c" "sun3.h"
     "print.c" "ymakefile" :wrote "float-sup.el" "floatfns.c")
    ("Schlumberger Technology Corporation" :changed "gud.el")
    ("Gregor Schmid" :wrote "tcl-mode.el")
    ("Rainer Schoepf" :wrote "alpha.h" "unexalpha.c")
    ("William Sommerfeld" :wrote "emacsclient.c" "emacsserver.c" "scribe.el")
    ("Leigh Stoller" :changed "emacsclient.c" "emacsserver.c" "server.el")
    ("Steve Strassman" :wrote "spook.el")
    ("Shinichirou Sugou" :changed "etags.c")
    ("Sun Microsystems, Inc" :changed "emacsclient.c" "emacsserver.c"
     "server.el" :wrote "emacs.icon" "emacstool.1" "emacstool.c" "sun-curs.el"
     "sun-fns.el" "sun-mouse.el" "sun.el" "sunfns.c")
    ("Kayvan Sylvan" :changed "sc.el")
    ("Spencer Thomas" :changed "emacsclient.c" "emacsserver.c" "server.el"
     "dabbrev.el" "unexec.c" "tcp.c" "gnus.texi")
    ("Jonathan Vail" :changed "vc.el")
    ("James Van Artsdalen" :changed "usg5-4.h" "unexec.c")
    ("Geoff Voelker" :wrote "src/makefile.nt" "lisp/makefile.nt" "winnt.el"
     "nt.c" "nt.h" "ntheap.c" "ntheap.h" "ntinevt.c"
     "ntproc.c" "ntterm.c" "windowsnt.h")
    ("Morten Welinder" :wrote "dosfns.c" "[many MSDOS files]" "msdos.h")
    ("Pace Willisson" :wrote "ispell.el")
    ("Garrett Wollman" :changed "sendmail.el")
279
    ("Dale R. Worley" :changed "mail-extr.el")
280 281 282 283
    ("Jamie Zawinski" :changed "bytecode.c" :wrote "disass.el" "tar-mode.el"))
  "Actions taken from the original, manually (un)maintained AUTHORS file.")


284 285
(defconst authors-valid-file-names
  '("aclocal.m4"
Kim F. Storm's avatar
Kim F. Storm committed
286 287
    "makedist.bat"
    "make-delta")
288 289 290 291 292 293 294 295 296 297 298 299 300
  "File names which are valid, but no longer exists (or cannot be
found) in the repository.")

(defconst authors-renamed-files-alist
  '(("nt.c" . "w32.c") ("nt.h" . "w32.h")
    ("ntheap.c" . "w32heap.c") ("ntheap.h" . "w32heap.h")
    ("ntinevt.c" . "w32inevt.c") ("ntinevt.h" . "w32inevt.h")
    ("ntproc.c" . "w32proc.c")
    ("w32console.c" . "w32term.c")
    ("unexnt.c" . "unexw32.c")
    ("s/windowsnt.h" . "s/ms-w32.h")
    ("config.emacs" . "configure")
    ("GETTING.GNU.SOFTWARE" . "FTP")
Kim F. Storm's avatar
Kim F. Storm committed
301 302 303
    ("leim-Makefile" . "leim/Makefile")
    ("leim-Makefile.in" . "leim/Makefile.in")
    ("INSTALL-CVS" . "INSTALL.CVS")
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364
    )
  "Alist of files which have been renamed during their lifetime.
Elements are (OLDNAME . NEWNAME).")

(defconst authors-renamed-files-regexps
  '(("^m/m-\\(.*\\.h\\)$" . "m/\\1")
    ("^m-\\(.*\\.h\\)$" . "\\1")
    ("^s/s-\\(.*\\.h\\)$" . "s/\\1")
    ("^s-\\(.*\\.h\\)$" . "\\1")
    ("^s/[-.a-zA-Z0-9_]+\\.h$" . t)
    ("\\(.*\\)\\.cmd$" . "\\1.bat")
    ("\\.bat$" . t)
    ("\\.[ch]$" . t)
    ("\\.el$" . t)
    ("\\.ps$" . t)
    ("\\.texi?$" . t)
    ("\\.texinfo$" . t)
    ("\\.xml?$" . t)
    ("\\.x[pb]m$" . t)
    ("\\.[xp]bm$" . t)
    ("^paths\\." . t)
    ("^install\\." . t)
    )
  "List regexps and rewriting rules for renamed files.
Elements are (REGEXP . REPLACE).  If REPLACE is a string, the file
name matching REGEXP is replaced by REPLACE using `replace-string'.
Otherwise, the file name is accepted as is.")

(defvar authors-checked-files-alist)
(defvar authors-invalid-file-names)

(defun authors-canonical-file-name (file log-file pos author)
  "Return canonical file name for FILE found in LOG-FILE at POS for AUTHOR.
Checks whether FILE is a valid (existing) file name, has been renamed,
or is on the list of removed files.  Returns the non-diretory part of
the file name."
  (let ((entry (assoc file authors-checked-files-alist))
	relname
	valid)
    (if entry
	(cdr entry)
      (setq relname (file-name-nondirectory file))
      (if (or (member relname authors-valid-file-names)
	      (file-exists-p file)
	      (file-exists-p relname)
	      (file-exists-p (concat "etc/" relname)))
	  (setq valid relname)
	(setq valid (assoc file authors-renamed-files-alist))
	(if valid
	    (setq valid (cdr valid))
	  (let ((rules authors-renamed-files-regexps))
	    (while rules
	      (if (string-match (car (car rules)) file)
		  (setq valid (if (stringp (cdr (car rules)))
				  (file-name-nondirectory
				   (replace-match (cdr (car rules)) t nil file))
				relname)
			rules nil))
	      (setq rules (cdr rules))))))
      (setq authors-checked-files-alist
	    (cons (cons file valid) authors-checked-files-alist))
365 366 367
      (unless (or valid
		  (string-match "[*]" file)
		  (string-match "^[0-9.]+$" file))
368
	(setq authors-invalid-file-names
369 370 371 372 373 374 375
	      (cons (format "%s:%d: unrecognized `%s' for %s"
			    log-file
			    (1+ (count-lines (point-min) pos))
			    file author)
		    authors-invalid-file-names)))
      valid)))

376 377 378 379 380 381 382 383 384 385
(defun authors-add-fixed-entries (table)
  "Add actions from `authors-fixed-entries' to TABLE."
  (dolist (entry authors-fixed-entries)
    (let ((author (car entry))
	  action)
      (dolist (item (cdr entry))
	(if (symbolp item)
	    (setq action item)
	  (authors-add author item action table))))))

386

387 388
(defun authors-obsolete-file-p (file)
  "Return non-nil if FILE is obsolete.
389
FILE is considered obsolete if it matches one of the regular expressions
390 391 392 393 394 395 396 397 398
from `authors-obsolete-files-regexps'."
  (let (obsolete-p
	(regexps authors-obsolete-files-regexps))
    (while (and regexps (not obsolete-p))
      (setq obsolete-p (string-match (car regexps) file)
	    regexps (cdr regexps)))
    obsolete-p))


Gerd Moellmann's avatar
Gerd Moellmann committed
399 400 401 402 403
(defun authors-add (author file action table)
  "Record that AUTHOR worked on FILE.
ACTION is a keyword symbol describing what he did.  Record file,
author and what he did in hash table TABLE.  See the description of
`authors-scan-change-log' for the structure of the hash table."
Kim F. Storm's avatar
Kim F. Storm committed
404 405
  (unless (or (member file authors-ignored-files)
	      (authors-obsolete-file-p file)
406
	      (equal author ""))
407
    (let* ((value (gethash author table))
408 409
	   (entry (assoc file value))
	   slot)
410
      (if (null entry)
411 412 413 414
	  (puthash author (cons (list file (cons action 1)) value) table)
	(if (setq slot (assoc action (cdr entry)))
	    (setcdr slot (1+ (cdr slot)))
	  (nconc entry (list (cons action 1))))))))
Gerd Moellmann's avatar
Gerd Moellmann committed
415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438


(defun authors-process-lines (program &rest args)
  "Execute PROGRAM with ARGS, returning its output as a list of lines.
Signal an error if the program returns with a non-zero exit status."
  (with-temp-buffer
    (let ((status (apply 'call-process program nil (current-buffer) nil args)))
      (unless (eq status 0)
	(error "%s exited with status %s" program status))
      (goto-char (point-min))
      (let (lines)
	(while (not (eobp))
	  (setq lines (cons (buffer-substring-no-properties
			     (line-beginning-position)
			     (line-end-position))
			    lines))
	  (forward-line 1))
	(nreverse lines)))))


(defun authors-canonical-author-name (author)
  "Return a canonicalized form of AUTHOR, an author name.
If AUTHOR has an alias, use that.  Remove email addresses.  Capitalize
words in the author's name."
439 440
  (let* ((aliases authors-aliases)
	 regexps realname)
Gerd Moellmann's avatar
Gerd Moellmann committed
441
    (while aliases
442 443 444 445 446 447 448 449 450 451 452
      (setq realname (car (car aliases))
	    regexps (cdr (car aliases))
	    aliases (cdr aliases))
      (while regexps
	(if (string-match (car regexps) author)
	    (setq author realname
		  regexps nil
		  aliases nil)
	  (setq regexps (cdr regexps))))))
  (when author
    (setq author (replace-regexp-in-string "[ \t]*[(<].*$" "" author))
453
    (setq author (replace-regexp-in-string "\`[ \t]+" "" author))
454
    (setq author (replace-regexp-in-string "[ \t]+$" "" author))
455 456 457
    (setq author (replace-regexp-in-string "[ \t]+" " " author))
    (unless (string-match "[-, \t]" author)
      (setq author ""))
458 459 460 461
    (capitalize author)))

(defun authors-scan-change-log (log-file table)
  "Scan change log LOG-FILE for author information.
Gerd Moellmann's avatar
Gerd Moellmann committed
462 463 464 465 466

For each change mentioned in the log, add an entry to hash table TABLE
under the author's canonical name.

Keys of TABLE are author names.  Values are alists of entries (FILE
467 468 469
\(ACTION . COUNT) ...).  FILE is one file the author worked on.  The
rest of the entry is a list of keyword symbols describing what he did
with the file and the number of each action.
Gerd Moellmann's avatar
Gerd Moellmann committed
470 471

:wrote		means the author wrote the file
472
:changed	means he changed the file COUNT times."
473

Gerd Moellmann's avatar
Gerd Moellmann committed
474 475
  (let* ((enable-local-variables t)
	 (enable-local-eval t)
476 477 478
	 (existing-buffer (get-file-buffer log-file))
	 (buffer (find-file-noselect log-file))
	 author file pos)
Gerd Moellmann's avatar
Gerd Moellmann committed
479 480 481 482 483 484 485
    (save-excursion
      (set-buffer buffer)
      (save-restriction
	(widen)
	(goto-char (point-min))
	(while (re-search-forward "^[0-9]\\|^[ \t]+\\* " nil t)
	  (beginning-of-line)
486
	  (setq pos (point))
Gerd Moellmann's avatar
Gerd Moellmann committed
487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507
	  (cond ((looking-at "^[0-9]+-[0-9]+-[0-9]+")
		 (skip-chars-forward " \t+:0-9-")
		 (setq author (buffer-substring-no-properties
			       (point) (line-end-position)))
		 (setq author (authors-canonical-author-name author))
		 (forward-line 1))
		((looking-at "^[ \t]+\\*")
		 (let ((line (buffer-substring-no-properties
			      (match-end 0) (line-end-position))))
		   (while (and (not (string-match ":" line))
			       (forward-line 1)
			       (not (looking-at ":\\|^[ \t]*$")))
		     (setq line (concat line
					(buffer-substring-no-properties
					 (line-beginning-position)
					 (line-end-position)))))
		   (when (string-match ":" line)
		     (setq line (substring line 0 (match-beginning 0)))
		     (setq line (replace-regexp-in-string "[[(<{].*$" "" line))
		     (setq line (replace-regexp-in-string "," "" line))
		     (dolist (file (split-string line))
508 509 510
		       (when (setq file (authors-canonical-file-name file log-file pos author))
			 ;;(message "%s changed %s" author file)
			 (authors-add author file :changed table))))
Gerd Moellmann's avatar
Gerd Moellmann committed
511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542
		   (forward-line 1)))))))
    (unless existing-buffer
      (kill-buffer buffer))))


(defun authors-scan-el (file table)
  "Scan Lisp file FILE for author information.
TABLE is a hash table to add author information to."
  (let* ((existing-buffer (get-file-buffer file))
	 (enable-local-variables t)
	 (enable-local-eval t)
	 (buffer (find-file-noselect file)))
    (save-excursion
      (set-buffer buffer)
      (save-restriction
	(widen)
	(goto-char (point-min))
	(while (and (re-search-forward
		     "^;+[ \t]*\\(Author\\|Commentary\\):[ \t]*" nil t)
		    (not (string= (match-string 1) "Commentary")))
	  ;; Some entries contain a year range in front of the
	  ;; author's name.
	  (skip-chars-forward "-0-9 \t")
	  (let ((author (buffer-substring-no-properties
			 (point) (line-end-position))))
	    (setq author (authors-canonical-author-name author))
	    (setq file (file-name-nondirectory file))
	    (authors-add author file :wrote table)))))
    (unless existing-buffer
      (kill-buffer buffer))))


543 544 545 546 547 548 549 550 551 552
(defun authors-public-domain-p (file)
  "Return t if FILE is a file that was put in public domain."
  (let ((public-domain-p nil)
	(list authors-public-domain-files))
    (while (and list (not public-domain-p))
      (when (string-match (car list) file)
	(setq public-domain-p t))
      (setq list (cdr list)))
    public-domain-p))

553 554 555 556 557 558 559
(defvar authors-author-list)

(defun authors-add-to-author-list (author changes)
  "Insert information about AUTHOR's work on Emacs into `authors-author-list'.
CHANGES is an alist of entries (FILE (ACTION . COUNT) ...), as produced by
`authors-scan-change-log'.
The element added to `authors-author-list' is (AUTHOR WROTE CHANGED), where
560
WROTE and CHANGED are lists of the files written and changed by AUTHOR."
561 562 563 564
  (when author
    (let ((nchanged 0)
	  wrote-list
	  changed-list)
Gerd Moellmann's avatar
Gerd Moellmann committed
565 566
      (dolist (change changes)
	(let ((actions (cdr change))
567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594
	      (file (car change))
	      slot)
	  (if (assq :wrote actions)
	      (setq wrote-list
		    (cons
		     (if (authors-public-domain-p file)
			 (concat file " (public domain)")
		       file)
		     wrote-list))
	    (setq changed-list
		  (cons (cons file (cdr (assq :changed actions)))
			changed-list)))))
      (if wrote-list
	  (setq wrote-list (sort wrote-list 'string-lessp)))
      (when changed-list
	(setq changed-list (sort changed-list
				 (lambda (a b)
				   (if (= (cdr a) (cdr b))
				       (string-lessp (car a) (car b))
				     (> (cdr a) (cdr b))))))
	(setq nchanged (length changed-list))
	(setq changed-list (mapcar 'car changed-list)))
      (if (> (- nchanged authors-many-files) 2)
	  (setcdr (nthcdr authors-many-files changed-list)
		  (list (format "and %d other files" (- nchanged authors-many-files)))))
      (setq authors-author-list
	    (cons (list author wrote-list changed-list)
		  authors-author-list)))))
Gerd Moellmann's avatar
Gerd Moellmann committed
595 596 597 598

(defun authors (root)
  "Extract author information from change logs and Lisp source files.
ROOT is the root directory under which to find the files.  If called
599
interactively, ROOT is read from the minibuffer.
600 601
Result is a buffer *Authors* containing authorship information, and a
buffer *Authors Errors* containing references to unknown files."
Gerd Moellmann's avatar
Gerd Moellmann committed
602
  (interactive "DEmacs source directory: ")
603
  (setq root (expand-file-name root))
Gerd Moellmann's avatar
Gerd Moellmann committed
604 605
  (let ((logs (authors-process-lines "find" root "-name" "ChangeLog*"))
	(table (make-hash-table :test 'equal))
606 607 608
	(buffer-name "*Authors*")
	authors-checked-files-alist
	authors-invalid-file-names)
609
    (authors-add-fixed-entries table)
Gerd Moellmann's avatar
Gerd Moellmann committed
610 611 612
    (unless (file-exists-p (expand-file-name "src/emacs.c" root))
      (error "Not the root directory of Emacs: %s" root))
    (dolist (log logs)
613
      (when (string-match "ChangeLog\\(.[0-9]+\\)?$" log)
Gerd Moellmann's avatar
Gerd Moellmann committed
614 615 616 617 618 619
	(message "Scanning %s..." log)
	(authors-scan-change-log log table)))
    (let ((els (authors-process-lines "find" root "-name" "*.el")))
      (dolist (file els)
	(message "Scanning %s..." file)
	(authors-scan-el file table)))
620
    (message "Generating buffer %s..." buffer-name)
Gerd Moellmann's avatar
Gerd Moellmann committed
621 622
    (set-buffer (get-buffer-create buffer-name))
    (erase-buffer)
623
    (set-buffer-file-coding-system authors-coding-system)
624
    (insert
625 626 627 628 629 630
"Many people have contributed code included in the Free Software
Foundation's distribution of GNU Emacs.  To show our appreciation for
their public spirit, we list here in alphabetical order a condensed
list of their contributions.\n")
    (let (authors-author-list a)
      (maphash #'authors-add-to-author-list table)
631
      (setq authors-author-list
632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655
	    (sort authors-author-list
		  (lambda (a b) (string-lessp (car a) (car b)))))
      (dolist (a authors-author-list)
	(let ((author (car a))
	      (wrote (nth 1 a))
	      (changed (nth 2 a))
	      file)
	(insert "\n" author ": ")
	(when wrote
	  (insert "wrote")
	  (dolist (file wrote)
	    (if (> (+ (current-column) (length file)) 72)
	      (insert "\n "))
	    (insert " " file))
	  (insert "\n"))
	(when changed
	  (if wrote
	      (insert "and "))
	  (insert "changed")
	  (dolist (file changed)
	    (if (> (+ (current-column) (length file)) 72)
		(insert "\n "))
	    (insert " " file))
	  (insert "\n")))))
656
    (insert "\nLocal" " Variables:\ncoding: "
657 658
	    (symbol-name authors-coding-system) "\nEnd:\n")
    (message "Generating buffer %s... done" buffer-name)
659
    (unless noninteractive
660 661 662 663 664 665 666 667 668 669
      (when authors-invalid-file-names
	(with-current-buffer (get-buffer-create "*Authors Errors*")
	  (erase-buffer)
	  (set-buffer-file-coding-system authors-coding-system)
	  (insert "Unrecognized file entries found:\n\n")
	  (mapcar (lambda (f) (if (not (string-match "^[A-Za-z]+$" f)) (insert f "\n")))
		  (sort authors-invalid-file-names 'string-lessp))
	  (goto-char (point-min))
	  (compilation-mode)
	  (message "Errors were found.  See buffer %s" (buffer-name))))
670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685
      (pop-to-buffer buffer-name))))


(defun batch-update-authors ()
  "Produce an AUTHORS file.
Call this function in batch mode with two command line arguments FILE
and ROOT.  FILE is the file to write, ROOT is the root directory of
the Emacs source tree, from which to build the file."
  (unless noninteractive
    (error "`batch-update-authors' is to be used only with -batch"))
  (when (/= (length command-line-args-left) 2)
    (error "Call `batch-update-authors' with the name of the file to write"))
  (let* ((file (pop command-line-args-left))
	 (root (pop command-line-args-left)))
    (authors root)
    (write-file file)))
Gerd Moellmann's avatar
Gerd Moellmann committed
686

Miles Bader's avatar
Miles Bader committed
687
;;; arch-tag: 659d5900-5ff2-43b0-954c-a315cc1e4dc1
688
;;; authors.el ends here