In comments, write delete_frame instead of Fdelete_frame.
[bpt/emacs.git] / admin / admin.el
CommitLineData
74499542
GM
1;;; admin.el --- utilities for Emacs administration
2
a70c9a7a 3;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
4e6835db 4;; Free Software Foundation, Inc.
74499542
GM
5
6;; This file is part of GNU Emacs.
7
9ad5de0c 8;; GNU Emacs is free software: you can redistribute it and/or modify
74499542 9;; it under the terms of the GNU General Public License as published by
9ad5de0c
GM
10;; the Free Software Foundation, either version 3 of the License, or
11;; (at your option) any later version.
74499542
GM
12
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.
17
18;; You should have received a copy of the GNU General Public License
9ad5de0c 19;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
74499542
GM
20
21;;; Commentary:
22
54381691
LK
23;; add-release-logs Add ``Version X released'' change log entries.
24;; set-version Change Emacs version number in source tree.
a3045b7e
GM
25;; set-copyright Change emacs short copyright string (eg as
26;; printed by --version) in source tree.
74499542
GM
27
28;;; Code:
29
74499542
GM
30(defun add-release-logs (root version)
31 "Add \"Version VERSION released.\" change log entries in ROOT.
32Root must be the root of an Emacs source tree."
33 (interactive "DEmacs root directory: \nNVersion number: ")
3f4a4bdf 34 (setq root (expand-file-name root))
74499542
GM
35 (unless (file-exists-p (expand-file-name "src/emacs.c" root))
36 (error "%s doesn't seem to be the root of an Emacs source tree" root))
54381691 37 (require 'add-log)
74499542
GM
38 (let* ((logs (process-lines "find" root "-name" "ChangeLog"))
39 (entry (format "%s %s <%s>\n\n\t* Version %s released.\n\n"
3f4a4bdf
FP
40 (funcall add-log-time-format)
41 (or add-log-full-name (user-full-name))
42 (or add-log-mailing-address user-mail-address)
43 version)))
74499542 44 (dolist (log logs)
e568708b 45 (unless (string-match "/gnus/" log)
74499542
GM
46 (find-file log)
47 (goto-char (point-min))
48 (insert entry)))))
49
74499542
GM
50(defun set-version-in-file (root file version rx)
51 (find-file (expand-file-name file root))
52 (goto-char (point-min))
53 (unless (re-search-forward rx nil t)
54 (error "Version not found in %s" file))
55 (replace-match (format "%s" version) nil nil nil 1))
56
74499542
GM
57(defun set-version (root version)
58 "Set Emacs version to VERSION in relevant files under ROOT.
59Root must be the root of an Emacs source tree."
91ebb8c9 60 (interactive "DEmacs root directory: \nsVersion number: ")
74499542
GM
61 (unless (file-exists-p (expand-file-name "src/emacs.c" root))
62 (error "%s doesn't seem to be the root of an Emacs source tree" root))
63 (set-version-in-file root "lisp/version.el" version
64 (rx (and "emacs-version" (0+ space)
65 ?\" (submatch (1+ (not (in ?\")))) ?\")))
66 (set-version-in-file root "README" version
67 (rx (and "version" (1+ space)
68 (submatch (1+ (in "0-9."))))))
24bbe01e
GM
69 (set-version-in-file root "configure.in" version
70 (rx (and "AC_INIT" (1+ (not (in ?,)))
71 ?, (0+ space)
72 (submatch (1+ (in "0-9."))))))
73 (set-version-in-file root "doc/emacs/emacs.texi" version
49e3fad2
LK
74 (rx (and "EMACSVER" (1+ space)
75 (submatch (1+ (in "0-9."))))))
24bbe01e 76 (set-version-in-file root "doc/lispref/elisp.texi" version
74499542 77 (rx (and "EMACSVER" (1+ space)
95f76284 78 (submatch (1+ (in "0-9."))))))
f2d8d275
GM
79 (set-version-in-file root "doc/lispref/vol1.texi" version
80 (rx (and "EMACSVER" (1+ space)
81 (submatch (1+ (in "0-9."))))))
82 (set-version-in-file root "doc/lispref/vol2.texi" version
83 (rx (and "EMACSVER" (1+ space)
84 (submatch (1+ (in "0-9."))))))
5de85e83
GM
85 (set-version-in-file root "doc/lispref/book-spine.texinfo" version
86 (rx (and "Emacs Version" (1+ space)
87 (submatch (1+ (in "0-9."))))))
adf94aa6
GM
88 (set-version-in-file root "doc/man/emacs.1" version
89 (rx (and ".TH EMACS" (1+ not-newline)
90 "GNU Emacs" (1+ space)
91 (submatch (1+ (in "0-9."))))))
611bee81
GM
92 (set-version-in-file root "doc/misc/faq.texi" version
93 (rx (and "VER" (1+ space)
94 (submatch (1+ (in "0-9."))))))
91236f63
GM
95 (set-version-in-file root "doc/misc/ns-emacs.texi" version
96 (rx (and "VER" (1+ space)
97 (submatch (1+ (in "0-9."))))))
1fe1ef05
JB
98 (set-version-in-file root "lib-src/makefile.w32-in" version
99 (rx (and "VERSION" (0+ space) "=" (0+ space)
100 (submatch (1+ (in "0-9."))))))
95f76284
JR
101 ;; nt/emacs.rc also contains the version number, but in an awkward
102 ;; format. It must contain four components, separated by commas, and
103 ;; in two places those commas are followed by space, in two other
104 ;; places they are not.
105 (let* ((version-components (append (split-string version "\\.")
106 '("0" "0")))
107 (comma-version
108 (concat (car version-components) ","
109 (cadr version-components) ","
d0834a5c 110 (cadr (cdr version-components)) ","
95f76284
JR
111 (cadr (cdr (cdr version-components)))))
112 (comma-space-version
113 (concat (car version-components) ", "
114 (cadr version-components) ", "
d0834a5c 115 (cadr (cdr version-components)) ", "
95f76284
JR
116 (cadr (cdr (cdr version-components))))))
117 (set-version-in-file root "nt/emacs.rc" comma-version
118 (rx (and "FILEVERSION" (1+ space)
119 (submatch (1+ (in "0-9,"))))))
120 (set-version-in-file root "nt/emacs.rc" comma-version
121 (rx (and "PRODUCTVERSION" (1+ space)
122 (submatch (1+ (in "0-9,"))))))
123 (set-version-in-file root "nt/emacs.rc" comma-space-version
124 (rx (and "\"FileVersion\"" (0+ space) ?, (0+ space)
125 ?\" (submatch (1+ (in "0-9, "))) "\\0\"")))
126 (set-version-in-file root "nt/emacs.rc" comma-space-version
127 (rx (and "\"ProductVersion\"" (0+ space) ?,
128 (0+ space) ?\" (submatch (1+ (in "0-9, ")))
b7063e7e
JR
129 "\\0\"")))
130 ;; Likewise for emacsclient.rc
131 (set-version-in-file root "nt/emacsclient.rc" comma-version
132 (rx (and "FILEVERSION" (1+ space)
133 (submatch (1+ (in "0-9,"))))))
134 (set-version-in-file root "nt/emacsclient.rc" comma-version
135 (rx (and "PRODUCTVERSION" (1+ space)
136 (submatch (1+ (in "0-9,"))))))
137 (set-version-in-file root "nt/emacsclient.rc" comma-space-version
138 (rx (and "\"FileVersion\"" (0+ space) ?, (0+ space)
139 ?\" (submatch (1+ (in "0-9, "))) "\\0\"")))
140 (set-version-in-file root "nt/emacsclient.rc" comma-space-version
95f76284
JR
141 (rx (and "\"ProductVersion\"" (0+ space) ?,
142 (0+ space) ?\" (submatch (1+ (in "0-9, ")))
9e2a2647 143 "\\0\""))))
d3841127
GM
144 ;; nextstep.
145 (set-version-in-file
146 root "nextstep/Cocoa/Emacs.base/Contents/Info.plist"
147 version (rx (and "CFBundleGetInfoString" (1+ anything) "Emacs" (1+ space)
148 (submatch (1+ (in "0-9."))))))
149 (set-version-in-file
150 root "nextstep/Cocoa/Emacs.base/Contents/Info.plist"
91236f63
GM
151 version (rx (and "CFBundleShortVersionString" (1+ not-newline) ?\n
152 (0+ not-newline) "<string>" (0+ space)
d3841127
GM
153 (submatch (1+ (in "0-9."))))))
154 (set-version-in-file
155 root "nextstep/Cocoa/Emacs.base/Contents/Resources/English.lproj/InfoPlist.strings"
156 version (rx (and "CFBundleShortVersionString" (0+ space) ?= (0+ space)
157 ?\" (0+ space) "Version" (1+ space)
158 (submatch (1+ (in "0-9."))))))
159 (set-version-in-file
160 root "nextstep/Cocoa/Emacs.base/Contents/Resources/English.lproj/InfoPlist.strings"
161 version (rx (and "CFBundleGetInfoString" (0+ space) ?= (0+ space)
162 ?\" (0+ space) "Emacs version" (1+ space)
163 (submatch (1+ (in "0-9."))))))
91236f63
GM
164 (set-version-in-file
165 root "nextstep/GNUstep/Emacs.base/Resources/Info-gnustep.plist"
166 version (rx (and "ApplicationRelease" (0+ space) ?= (0+ space)
167 ?\" (0+ space) (submatch (1+ (in "0-9."))))))
d3841127
GM
168 (set-version-in-file
169 root "nextstep/GNUstep/Emacs.base/Resources/Info-gnustep.plist"
170 version (rx (and "FullVersionID" (0+ space) ?= (0+ space)
171 ?\" (0+ space) "Emacs" (1+ space)
91236f63
GM
172 (submatch (1+ (in "0-9."))))))
173 (set-version-in-file
174 root "nextstep/GNUstep/Emacs.base/Resources/Emacs.desktop"
175 version (rx (and "Version=" (submatch (1+ (in "0-9.")))))))
3f4a4bdf 176
a3045b7e 177;; Note this makes some assumptions about form of short copyright.
6916ec08 178;; FIXME add the \year in the refcards/*.tex files.
a3045b7e
GM
179(defun set-copyright (root copyright)
180 "Set Emacs short copyright to COPYRIGHT in relevant files under ROOT.
181Root must be the root of an Emacs source tree."
182 (interactive (list
183 (read-directory-name "Emacs root directory: " nil nil t)
184 (read-string
185 "Short copyright string: "
186 (format "Copyright (C) %s Free Software Foundation, Inc."
187 (format-time-string "%Y")))))
188 (unless (file-exists-p (expand-file-name "src/emacs.c" root))
189 (error "%s doesn't seem to be the root of an Emacs source tree" root))
190 (set-version-in-file root "lisp/version.el" copyright
191 (rx (and "emacs-copyright" (0+ space)
192 ?\" (submatch (1+ (not (in ?\")))) ?\")))
a70c9a7a
GM
193 (set-version-in-file root "lib-src/ebrowse.c" copyright
194 (rx (and "emacs_copyright" (0+ (not (in ?\")))
195 ?\" (submatch (1+ (not (in ?\")))) ?\")))
a3045b7e
GM
196 (set-version-in-file root "lib-src/etags.c" copyright
197 (rx (and "emacs_copyright" (0+ (not (in ?\")))
198 ?\" (submatch (1+ (not (in ?\")))) ?\")))
199 (set-version-in-file root "lib-src/rcs2log" copyright
200 (rx (and "Copyright" (0+ space) ?= (0+ space)
201 ?\' (submatch (1+ nonl)))))
a3045b7e
GM
202 ;; This one is a nuisance, as it needs to be split over two lines.
203 (string-match "\\(.*[0-9]\\{4\\} *\\)\\(.*\\)" copyright)
d3841127
GM
204 ;; nextstep.
205 (set-version-in-file
206 root "nextstep/Cocoa/Emacs.base/Contents/Info.plist"
207 copyright (rx (and "CFBundleGetInfoString" (1+ anything) "Emacs" (1+ space)
208 (1+ (in "0-9.")) (1+ space)
209 (submatch (1+ (not (in ?\<)))))))
210 (set-version-in-file
211 root "nextstep/Cocoa/Emacs.base/Contents/Resources/English.lproj/InfoPlist.strings"
212 copyright (rx (and "NSHumanReadableCopyright" (0+ space) ?\= (0+ space)
7963f8ab
GM
213 ?\" (submatch (1+ (not (in ?\")))))))
214 (set-version-in-file
215 root "nextstep/GNUstep/Emacs.base/Resources/Info-gnustep.plist"
216 copyright (rx (and "Copyright" (0+ space) ?\= (0+ space)
217 ?\" (submatch (1+ (not (in ?\"))))))))
a3045b7e 218
69c52df1
GM
219(provide 'admin)
220
d3841127
GM
221;; arch-tag: 4ea83636-2293-408b-884e-ad64f22a3bf5
222;;; admin.el ends here