(tags-table-mode): Disable undo.
[emacs.git] / admin / admin.el
blob67b0c161f5beae3d48845bf0c99ff9b4991a6b01
1 ;;; admin.el --- utilities for Emacs administration
3 ;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
4 ;; Free Software Foundation, Inc.
6 ;; This file is part of GNU Emacs.
8 ;; GNU Emacs is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation; either version 3, or (at your option)
11 ;; any later version.
13 ;; GNU Emacs is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GNU Emacs; see the file COPYING. If not, write to the
20 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 ;; Boston, MA 02110-1301, USA.
23 ;;; Commentary:
25 ;; add-release-logs Add ``Version X released'' change log entries.
26 ;; set-version Change Emacs version number in source tree.
28 ;;; Code:
30 (defun process-lines (program &rest args)
31 "Execute PROGRAM with ARGS, returning its output as a list of lines.
32 Signal an error if the program returns with a non-zero exit status."
33 (with-temp-buffer
34 (let ((status (apply 'call-process program nil (current-buffer) nil args)))
35 (unless (eq status 0)
36 (error "%s exited with status %s" program status))
37 (goto-char (point-min))
38 (let (lines)
39 (while (not (eobp))
40 (setq lines (cons (buffer-substring-no-properties
41 (line-beginning-position)
42 (line-end-position))
43 lines))
44 (forward-line 1))
45 (nreverse lines)))))
47 (defun add-release-logs (root version)
48 "Add \"Version VERSION released.\" change log entries in ROOT.
49 Root must be the root of an Emacs source tree."
50 (interactive "DEmacs root directory: \nNVersion number: ")
51 (setq root (expand-file-name root))
52 (unless (file-exists-p (expand-file-name "src/emacs.c" root))
53 (error "%s doesn't seem to be the root of an Emacs source tree" root))
54 (require 'add-log)
55 (let* ((logs (process-lines "find" root "-name" "ChangeLog"))
56 (entry (format "%s %s <%s>\n\n\t* Version %s released.\n\n"
57 (funcall add-log-time-format)
58 (or add-log-full-name (user-full-name))
59 (or add-log-mailing-address user-mail-address)
60 version)))
61 (dolist (log logs)
62 (unless (string-match "/gnus/" log)
63 (find-file log)
64 (goto-char (point-min))
65 (insert entry)))))
67 (defun set-version-in-file (root file version rx)
68 (find-file (expand-file-name file root))
69 (goto-char (point-min))
70 (unless (re-search-forward rx nil t)
71 (error "Version not found in %s" file))
72 (replace-match (format "%s" version) nil nil nil 1))
74 (defun set-version (root version)
75 "Set Emacs version to VERSION in relevant files under ROOT.
76 Root must be the root of an Emacs source tree."
77 (interactive "DEmacs root directory: \nsVersion number: ")
78 (unless (file-exists-p (expand-file-name "src/emacs.c" root))
79 (error "%s doesn't seem to be the root of an Emacs source tree" root))
80 (set-version-in-file root "lisp/version.el" version
81 (rx (and "emacs-version" (0+ space)
82 ?\" (submatch (1+ (not (in ?\")))) ?\")))
83 (set-version-in-file root "README" version
84 (rx (and "version" (1+ space)
85 (submatch (1+ (in "0-9."))))))
86 (set-version-in-file root "man/emacs.texi" version
87 (rx (and "EMACSVER" (1+ space)
88 (submatch (1+ (in "0-9."))))))
89 (set-version-in-file root "lispref/elisp.texi" version
90 (rx (and "EMACSVER" (1+ space)
91 (submatch (1+ (in "0-9."))))))
92 (set-version-in-file root "lib-src/makefile.w32-in" version
93 (rx (and "VERSION" (0+ space) "=" (0+ space)
94 (submatch (1+ (in "0-9."))))))
95 ;; nt/emacs.rc also contains the version number, but in an awkward
96 ;; format. It must contain four components, separated by commas, and
97 ;; in two places those commas are followed by space, in two other
98 ;; places they are not.
99 (let* ((version-components (append (split-string version "\\.")
100 '("0" "0")))
101 (comma-version
102 (concat (car version-components) ","
103 (cadr version-components) ","
104 (cadr (cdr version-components)) ","
105 (cadr (cdr (cdr version-components)))))
106 (comma-space-version
107 (concat (car version-components) ", "
108 (cadr version-components) ", "
109 (cadr (cdr version-components)) ", "
110 (cadr (cdr (cdr version-components))))))
111 (set-version-in-file root "nt/emacs.rc" comma-version
112 (rx (and "FILEVERSION" (1+ space)
113 (submatch (1+ (in "0-9,"))))))
114 (set-version-in-file root "nt/emacs.rc" comma-version
115 (rx (and "PRODUCTVERSION" (1+ space)
116 (submatch (1+ (in "0-9,"))))))
117 (set-version-in-file root "nt/emacs.rc" comma-space-version
118 (rx (and "\"FileVersion\"" (0+ space) ?, (0+ space)
119 ?\" (submatch (1+ (in "0-9, "))) "\\0\"")))
120 (set-version-in-file root "nt/emacs.rc" comma-space-version
121 (rx (and "\"ProductVersion\"" (0+ space) ?,
122 (0+ space) ?\" (submatch (1+ (in "0-9, ")))
123 "\\0\"")))
124 ;; Some files in the "mac" subdirectory also contain the version
125 ;; number.
126 (set-version-in-file
127 root "mac/Emacs.app/Contents/Resources/English.lproj/InfoPlist.strings"
128 version (rx (and "CFBundleShortVersionString" (0+ space) ?= (0+ space) ?\"
129 (submatch (1+ (in "0-9."))))))
130 (set-version-in-file
131 root "mac/Emacs.app/Contents/Resources/English.lproj/InfoPlist.strings"
132 version (rx (and "CFBundleGetInfoString" (0+ space) ?= (0+ space) ?\"
133 (submatch (1+ (in "0-9."))))))
134 (set-version-in-file root "mac/src/Emacs.r" (car version-components)
135 (rx (and "GNU Emacs " (submatch (1+ (in "0-9")))
136 " for Mac OS")))
137 (set-version-in-file root "mac/src/Emacs.r" (car version-components)
138 (rx (and (submatch (1+ (in "0-9"))) (0+ space) ?\,
139 (0+ space) "/* Major revision in BCD */")))
140 (set-version-in-file root "mac/src/Emacs.r" (cadr version-components)
141 (rx (and (submatch (1+ (in "0-9"))) (0+ space) ?\,
142 (0+ space) "/* Minor revision in BCD */")))
143 (set-version-in-file root "mac/src/Emacs.r" (cadr (cdr version-components))
144 (rx (and (submatch (1+ (in "0-9"))) (0+ space) ?\,
145 (0+ space) "/* Non-final release # */")))
146 (set-version-in-file root "mac/src/Emacs.r" version
147 (rx (and (submatch (1+ (in "0-9."))) (0+ space) ?\" ?\,
148 (0+ space) "/* Short version number */")))
149 (set-version-in-file root "mac/src/Emacs.r" version
150 (rx (and "/* Short version number */" (0+ space) ?\"
151 (submatch (1+ (in "0-9."))))))
152 (let* ((third-component (string-to-number (cadr (cdr version-components))))
153 (release (cond ((>= third-component 90) "alpha")
154 ((>= third-component 50) "development")
155 (t "final"))))
156 (set-version-in-file
157 root "mac/src/Emacs.r" release
158 (rx (and (submatch (1+ (in "a-z"))) (0+ space) ?\, (0+ space)
159 "/* development, alpha, beta, or final (release) */"))))))
161 ;;; arch-tag: 4ea83636-2293-408b-884e-ad64f22a3bf5
162 ;; admin.el ends here.