Fix whitespace highlighting of context diffs.
[emacs.git] / admin / admin.el
blob27b2b3ab64860af7e34978ddde967ad9c80ab8f8
1 ;;; admin.el --- utilities for Emacs administration
3 ;; Copyright (C) 2001-2012 Free Software Foundation, Inc.
5 ;; This file is part of GNU Emacs.
7 ;; GNU Emacs is free software: you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation, either version 3 of the License, or
10 ;; (at your option) any later version.
12 ;; GNU Emacs is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
20 ;;; Commentary:
22 ;; add-release-logs Add ``Version X released'' change log entries.
23 ;; set-version Change Emacs version number in source tree.
24 ;; set-copyright Change emacs short copyright string (eg as
25 ;; printed by --version) in source tree.
27 ;;; Code:
29 (defun add-release-logs (root version)
30 "Add \"Version VERSION released.\" change log entries in ROOT.
31 Root must be the root of an Emacs source tree."
32 (interactive "DEmacs root directory: \nNVersion number: ")
33 (setq root (expand-file-name root))
34 (unless (file-exists-p (expand-file-name "src/emacs.c" root))
35 (error "%s doesn't seem to be the root of an Emacs source tree" root))
36 (require 'add-log)
37 (let* ((logs (process-lines "find" root "-name" "ChangeLog"))
38 (entry (format "%s %s <%s>\n\n\t* Version %s released.\n\n"
39 (funcall add-log-time-format)
40 (or add-log-full-name (user-full-name))
41 (or add-log-mailing-address user-mail-address)
42 version)))
43 (dolist (log logs)
44 (unless (string-match "/gnus/" log)
45 (find-file log)
46 (goto-char (point-min))
47 (insert entry)))))
49 (defun set-version-in-file (root file version rx)
50 (find-file (expand-file-name file root))
51 (goto-char (point-min))
52 (unless (re-search-forward rx nil t)
53 (error "Version not found in %s" file))
54 (replace-match (format "%s" version) nil nil nil 1))
56 (defun set-version (root version)
57 "Set Emacs version to VERSION in relevant files under ROOT.
58 Root must be the root of an Emacs source tree."
59 (interactive "DEmacs root directory: \nsVersion number: ")
60 (unless (file-exists-p (expand-file-name "src/emacs.c" root))
61 (error "%s doesn't seem to be the root of an Emacs source tree" root))
62 (set-version-in-file root "README" version
63 (rx (and "version" (1+ space)
64 (submatch (1+ (in "0-9."))))))
65 (set-version-in-file root "configure.in" version
66 (rx (and "AC_INIT" (1+ (not (in ?,)))
67 ?, (0+ space)
68 (submatch (1+ (in "0-9."))))))
69 (set-version-in-file root "doc/emacs/emacsver.texi" version
70 (rx (and "EMACSVER" (1+ space)
71 (submatch (1+ (in "0-9."))))))
72 (set-version-in-file root "doc/man/emacs.1" version
73 (rx (and ".TH EMACS" (1+ not-newline)
74 "GNU Emacs" (1+ space)
75 (submatch (1+ (in "0-9."))))))
76 (set-version-in-file root "nt/config.nt" version
77 (rx (and bol "#" (0+ blank) "define" (1+ blank)
78 "VERSION" (1+ blank) "\""
79 (submatch (1+ (in "0-9."))))))
80 (set-version-in-file root "msdos/sed2v2.inp" version
81 (rx (and bol "/^#undef " (1+ not-newline)
82 "define VERSION" (1+ space) "\""
83 (submatch (1+ (in "0-9."))))))
84 (set-version-in-file root "nt/makefile.w32-in" version
85 (rx (and "VERSION" (0+ space) "=" (0+ space)
86 (submatch (1+ (in "0-9."))))))
87 ;; nt/emacs.rc also contains the version number, but in an awkward
88 ;; format. It must contain four components, separated by commas, and
89 ;; in two places those commas are followed by space, in two other
90 ;; places they are not.
91 (let* ((version-components (append (split-string version "\\.")
92 '("0" "0")))
93 (comma-version
94 (concat (car version-components) ","
95 (cadr version-components) ","
96 (cadr (cdr version-components)) ","
97 (cadr (cdr (cdr version-components)))))
98 (comma-space-version
99 (concat (car version-components) ", "
100 (cadr version-components) ", "
101 (cadr (cdr version-components)) ", "
102 (cadr (cdr (cdr version-components))))))
103 (set-version-in-file root "nt/emacs.rc" comma-version
104 (rx (and "FILEVERSION" (1+ space)
105 (submatch (1+ (in "0-9,"))))))
106 (set-version-in-file root "nt/emacs.rc" comma-version
107 (rx (and "PRODUCTVERSION" (1+ space)
108 (submatch (1+ (in "0-9,"))))))
109 (set-version-in-file root "nt/emacs.rc" comma-space-version
110 (rx (and "\"FileVersion\"" (0+ space) ?, (0+ space)
111 ?\" (submatch (1+ (in "0-9, "))) "\\0\"")))
112 (set-version-in-file root "nt/emacs.rc" comma-space-version
113 (rx (and "\"ProductVersion\"" (0+ space) ?,
114 (0+ space) ?\" (submatch (1+ (in "0-9, ")))
115 "\\0\"")))
116 ;; Likewise for emacsclient.rc
117 (set-version-in-file root "nt/emacsclient.rc" comma-version
118 (rx (and "FILEVERSION" (1+ space)
119 (submatch (1+ (in "0-9,"))))))
120 (set-version-in-file root "nt/emacsclient.rc" comma-version
121 (rx (and "PRODUCTVERSION" (1+ space)
122 (submatch (1+ (in "0-9,"))))))
123 (set-version-in-file root "nt/emacsclient.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/emacsclient.rc" comma-space-version
127 (rx (and "\"ProductVersion\"" (0+ space) ?,
128 (0+ space) ?\" (submatch (1+ (in "0-9, ")))
129 "\\0\""))))
130 ;; nextstep.
131 (set-version-in-file
132 root "nextstep/Cocoa/Emacs.base/Contents/Info.plist"
133 version (rx (and "CFBundleGetInfoString" (1+ anything) "Emacs" (1+ space)
134 (submatch (1+ (in "0-9."))))))
135 (set-version-in-file
136 root "nextstep/Cocoa/Emacs.base/Contents/Info.plist"
137 version (rx (and "CFBundleShortVersionString" (1+ not-newline) ?\n
138 (0+ not-newline) "<string>" (0+ space)
139 (submatch (1+ (in "0-9."))))))
140 (set-version-in-file
141 root "nextstep/Cocoa/Emacs.base/Contents/Resources/English.lproj/InfoPlist.strings"
142 version (rx (and "CFBundleShortVersionString" (0+ space) ?= (0+ space)
143 ?\" (0+ space) "Version" (1+ space)
144 (submatch (1+ (in "0-9."))))))
145 (set-version-in-file
146 root "nextstep/Cocoa/Emacs.base/Contents/Resources/English.lproj/InfoPlist.strings"
147 version (rx (and "CFBundleGetInfoString" (0+ space) ?= (0+ space)
148 ?\" (0+ space) "Emacs version" (1+ space)
149 (submatch (1+ (in "0-9."))))))
150 (set-version-in-file
151 root "nextstep/GNUstep/Emacs.base/Resources/Info-gnustep.plist"
152 version (rx (and "ApplicationRelease" (0+ space) ?= (0+ space)
153 ?\" (0+ space) (submatch (1+ (in "0-9."))))))
154 (set-version-in-file
155 root "nextstep/GNUstep/Emacs.base/Resources/Info-gnustep.plist"
156 version (rx (and "FullVersionID" (0+ space) ?= (0+ space)
157 ?\" (0+ space) "Emacs" (1+ space)
158 (submatch (1+ (in "0-9."))))))
159 (set-version-in-file
160 root "nextstep/GNUstep/Emacs.base/Resources/Emacs.desktop"
161 version (rx (and "Version=" (submatch (1+ (in "0-9.")))))))
163 ;; Note this makes some assumptions about form of short copyright.
164 (defun set-copyright (root copyright)
165 "Set Emacs short copyright to COPYRIGHT in relevant files under ROOT.
166 Root must be the root of an Emacs source tree."
167 (interactive (list
168 (read-directory-name "Emacs root directory: " nil nil t)
169 (read-string
170 "Short copyright string: "
171 (format "Copyright (C) %s Free Software Foundation, Inc."
172 (format-time-string "%Y")))))
173 (unless (file-exists-p (expand-file-name "src/emacs.c" root))
174 (error "%s doesn't seem to be the root of an Emacs source tree" root))
175 (set-version-in-file root "src/emacs.c" copyright
176 (rx (and "emacs_copyright" (0+ (not (in ?\")))
177 ?\" (submatch (1+ (not (in ?\")))) ?\")))
178 (set-version-in-file root "lib-src/ebrowse.c" copyright
179 (rx (and "emacs_copyright" (0+ (not (in ?\")))
180 ?\" (submatch (1+ (not (in ?\")))) ?\")))
181 (set-version-in-file root "lib-src/etags.c" copyright
182 (rx (and "emacs_copyright" (0+ (not (in ?\")))
183 ?\" (submatch (1+ (not (in ?\")))) ?\")))
184 (set-version-in-file root "lib-src/rcs2log" copyright
185 (rx (and "Copyright" (0+ space) ?= (0+ space)
186 ?\' (submatch (1+ nonl)))))
187 ;; This one is a nuisance, as it needs to be split over two lines.
188 (string-match "\\(.*[0-9]\\{4\\} *\\)\\(.*\\)" copyright)
189 ;; nextstep.
190 (set-version-in-file
191 root "nextstep/Cocoa/Emacs.base/Contents/Info.plist"
192 copyright (rx (and "CFBundleGetInfoString" (1+ anything) "Emacs" (1+ space)
193 (1+ (in "0-9.")) (1+ space)
194 (submatch (1+ (not (in ?\<)))))))
195 (set-version-in-file
196 root "nextstep/Cocoa/Emacs.base/Contents/Resources/English.lproj/InfoPlist.strings"
197 copyright (rx (and "NSHumanReadableCopyright" (0+ space) ?\= (0+ space)
198 ?\" (submatch (1+ (not (in ?\")))))))
199 (set-version-in-file
200 root "nextstep/GNUstep/Emacs.base/Resources/Info-gnustep.plist"
201 copyright (rx (and "Copyright" (0+ space) ?\= (0+ space)
202 ?\" (submatch (1+ (not (in ?\")))))))
203 (when (string-match "\\([0-9]\\{4\\}\\)" copyright)
204 (setq copyright (match-string 1 copyright))
205 (dolist (file (directory-files (expand-file-name "etc/refcards" root)
206 t "\\.tex\\'"))
207 (unless (string-match "gnus-refcard\\.tex" file)
208 (set-version-in-file
209 root file copyright
210 (concat (if (string-match "ru-refcard\\.tex" file)
211 "\\\\newcommand{\\\\cyear}\\[0\\]{"
212 "\\\\def\\\\year{")
213 "\\([0-9]\\{4\\}\\)}.+%.+copyright year"))))))
215 ;;; Various bits of magic for generating the web manuals
217 (defun make-manuals (root)
218 "Generate the web manuals for the Emacs webpage."
219 (interactive "DEmacs root directory: ")
220 (let* ((dest (expand-file-name "manual" root))
221 (html-node-dir (expand-file-name "html_node" dest))
222 (html-mono-dir (expand-file-name "html_mono" dest))
223 (txt-dir (expand-file-name "text" dest))
224 (dvi-dir (expand-file-name "dvi" dest))
225 (ps-dir (expand-file-name "ps" dest)))
226 (when (file-directory-p dest)
227 (if (y-or-n-p (format "Directory %s exists, delete it first?" dest))
228 (delete-directory dest t)
229 (error "Aborted")))
230 (make-directory dest)
231 (make-directory html-node-dir)
232 (make-directory html-mono-dir)
233 (make-directory txt-dir)
234 (make-directory dvi-dir)
235 (make-directory ps-dir)
236 ;; Emacs manual
237 (let ((texi (expand-file-name "doc/emacs/emacs.texi" root)))
238 (manual-html-node texi (expand-file-name "emacs" html-node-dir))
239 (manual-html-mono texi (expand-file-name "emacs.html" html-mono-dir))
240 (manual-txt texi (expand-file-name "emacs.txt" txt-dir))
241 (manual-pdf texi (expand-file-name "emacs.pdf" dest))
242 (manual-dvi texi (expand-file-name "emacs.dvi" dvi-dir)
243 (expand-file-name "emacs.ps" ps-dir)))
244 ;; Lisp manual
245 (let ((texi (expand-file-name "doc/lispref/elisp.texi" root)))
246 (manual-html-node texi (expand-file-name "elisp" html-node-dir))
247 (manual-html-mono texi (expand-file-name "elisp.html" html-mono-dir))
248 (manual-txt texi (expand-file-name "elisp.txt" txt-dir))
249 (manual-pdf texi (expand-file-name "elisp.pdf" dest))
250 (manual-dvi texi (expand-file-name "elisp.dvi" dvi-dir)
251 (expand-file-name "elisp.ps" ps-dir)))
252 (message "Manuals created in %s" dest)))
254 (defconst manual-doctype-string
255 "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
256 \"http://www.w3.org/TR/html4/loose.dtd\">\n\n")
258 (defconst manual-meta-string
259 "<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">
260 <link rev=\"made\" href=\"mailto:webmasters@gnu.org\">
261 <link rel=\"icon\" type=\"image/png\" href=\"/graphics/gnu-head-mini.png\">
262 <meta name=\"ICBM\" content=\"42.256233,-71.006581\">
263 <meta name=\"DC.title\" content=\"gnu.org\">\n\n")
265 (defconst manual-style-string "<style type=\"text/css\">
266 @import url('/style.css');\n</style>\n")
268 (defun manual-html-mono (texi-file dest)
269 "Run Makeinfo on TEXI-FILE, emitting mono HTML output to DEST.
270 This function also edits the HTML files so that they validate as
271 HTML 4.01 Transitional, and pulls in the gnu.org stylesheet using
272 the @import directive."
273 (call-process "makeinfo" nil nil nil
274 "--html" "--no-split" texi-file "-o" dest)
275 (with-temp-buffer
276 (insert-file-contents dest)
277 (setq buffer-file-name dest)
278 (manual-html-fix-headers)
279 (manual-html-fix-index-1)
280 (manual-html-fix-index-2 t)
281 (manual-html-fix-node-div)
282 (goto-char (point-max))
283 (re-search-backward "</body>[\n \t]*</html>")
284 (insert "</div>\n\n")
285 (save-buffer)))
287 (defun manual-html-node (texi-file dir)
288 "Run Makeinfo on TEXI-FILE, emitting per-node HTML output to DIR.
289 This function also edits the HTML files so that they validate as
290 HTML 4.01 Transitional, and pulls in the gnu.org stylesheet using
291 the @import directive."
292 (unless (file-exists-p texi-file)
293 (error "Manual file %s not found" texi-file))
294 (call-process "makeinfo" nil nil nil
295 "--html" texi-file "-o" dir)
296 ;; Loop through the node files, fixing them up.
297 (dolist (f (directory-files dir nil "\\.html\\'"))
298 (let (opoint)
299 (with-temp-buffer
300 (insert-file-contents (expand-file-name f dir))
301 (setq buffer-file-name (expand-file-name f dir))
302 (if (looking-at "<meta http-equiv")
303 ;; Ignore those HTML files that are just redirects.
304 (set-buffer-modified-p nil)
305 (manual-html-fix-headers)
306 (if (equal f "index.html")
307 (let (copyright-text)
308 (manual-html-fix-index-1)
309 ;; Move copyright notice to the end.
310 (re-search-forward "[ \t]*<p>Copyright &copy;")
311 (setq opoint (match-beginning 0))
312 (re-search-forward "</blockquote>")
313 (setq copyright-text (buffer-substring opoint (point)))
314 (delete-region opoint (point))
315 (manual-html-fix-index-2)
316 (insert copyright-text "\n</div>\n"))
317 ;; For normal nodes, give the header div a blue bg.
318 (manual-html-fix-node-div))
319 (save-buffer))))))
321 (defun manual-txt (texi-file dest)
322 "Run Makeinfo on TEXI-FILE, emitting plaintext output to DEST."
323 (call-process "makeinfo" nil nil nil
324 "--plaintext" "--no-split" texi-file "-o" dest)
325 (shell-command (concat "gzip -c " dest " > " (concat dest ".gz"))))
327 (defun manual-pdf (texi-file dest)
328 "Run texi2pdf on TEXI-FILE, emitting plaintext output to DEST."
329 (call-process "texi2pdf" nil nil nil texi-file "-o" dest))
331 (defun manual-dvi (texi-file dest ps-dest)
332 "Run texi2dvi on TEXI-FILE, emitting dvi output to DEST.
333 Also generate PostScript output in PS-DEST."
334 (call-process "texi2dvi" nil nil nil texi-file "-o" dest)
335 (call-process "dvips" nil nil nil dest "-o" ps-dest)
336 (call-process "gzip" nil nil nil dest)
337 (call-process "gzip" nil nil nil ps-dest))
339 (defun manual-html-fix-headers ()
340 "Fix up HTML headers for the Emacs manual in the current buffer."
341 (let (opoint)
342 (insert manual-doctype-string)
343 (search-forward "<head>\n")
344 (insert manual-meta-string)
345 (search-forward "<meta")
346 (setq opoint (match-beginning 0))
347 (re-search-forward "<!--")
348 (goto-char (match-beginning 0))
349 (delete-region opoint (point))
350 (insert manual-style-string)
351 (search-forward "<meta http-equiv=\"Content-Style")
352 (setq opoint (match-beginning 0))
353 (search-forward "</head>")
354 (delete-region opoint (match-beginning 0))))
356 (defun manual-html-fix-node-div ()
357 "Fix up HTML \"node\" divs in the current buffer."
358 (let (opoint div-end)
359 (while (search-forward "<div class=\"node\">" nil t)
360 (replace-match
361 "<div class=\"node\" style=\"background-color:#DDDDFF\">"
362 t t)
363 (setq opoint (point))
364 (re-search-forward "</div>")
365 (setq div-end (match-beginning 0))
366 (goto-char opoint)
367 (if (search-forward "<hr>" div-end 'move)
368 (replace-match "" t t)))))
370 (defun manual-html-fix-index-1 ()
371 (let (opoint)
372 (re-search-forward "<body>\n\\(<h1 class=\"settitle\\)")
373 (setq opoint (match-beginning 1))
374 (search-forward "<h2 class=\"unnumbered")
375 (goto-char (match-beginning 0))
376 (delete-region opoint (point))
377 (insert "<div id=\"content\" class=\"inner\">\n\n")))
379 (defun manual-html-fix-index-2 (&optional table-workaround)
380 "Replace the index list in the current buffer with a HTML table."
381 (let (done open-td tag desc)
382 ;; Convert the list that Makeinfo made into a table.
383 (search-forward "<ul class=\"menu\">")
384 (replace-match "<table style=\"float:left\" width=\"100%\">")
385 (forward-line 1)
386 (while (not done)
387 (cond
388 ((or (looking-at "<li>\\(<a.+</a>\\):[ \t]+\\(.*\\)$")
389 (looking-at "<li>\\(<a.+</a>\\)$"))
390 (setq tag (match-string 1))
391 (setq desc (match-string 2))
392 (replace-match "" t t)
393 (when open-td
394 (save-excursion
395 (forward-char -1)
396 (skip-chars-backward " ")
397 (delete-region (point) (line-end-position))
398 (insert "</td>\n </tr>")))
399 (insert " <tr>\n ")
400 (if table-workaround
401 ;; This works around a Firefox bug in the mono file.
402 (insert "<td bgcolor=\"white\">")
403 (insert "<td>"))
404 (insert tag "</td>\n <td>" (or desc ""))
405 (setq open-td t))
406 ((eq (char-after) ?\n)
407 (delete-char 1)
408 ;; Negate the following `forward-line'.
409 (forward-line -1))
410 ((looking-at "<!-- ")
411 (search-forward "-->"))
412 ((looking-at "<p>[- ]*The Detailed Node Listing[- \n]*")
413 (replace-match " </td></tr></table>\n
414 <h3>Detailed Node Listing</h3>\n\n" t t)
415 (search-forward "<p>")
416 (search-forward "<p>")
417 (goto-char (match-beginning 0))
418 (skip-chars-backward "\n ")
419 (setq open-td nil)
420 (insert "</p>\n\n<table style=\"float:left\" width=\"100%\">"))
421 ((looking-at "</li></ul>")
422 (replace-match "" t t))
423 ((looking-at "<p>")
424 (replace-match "" t t)
425 (when open-td
426 (insert " </td></tr>")
427 (setq open-td nil))
428 (insert " <tr>
429 <th colspan=\"2\" align=\"left\" style=\"text-align:left\">")
430 (re-search-forward "</p>[ \t\n]*<ul class=\"menu\">")
431 (replace-match " </th></tr>"))
432 ((looking-at "[ \t]*</ul>[ \t]*$")
433 (replace-match
434 (if open-td
435 " </td></tr>\n</table>"
436 "</table>") t t)
437 (setq done t))
439 (if (eobp)
440 (error "Parse error in %s" f))
441 (unless open-td
442 (setq done t))))
443 (forward-line 1))))
446 ;; Stuff to check new defcustoms got :version tags.
447 ;; Adapted from check-declare.el.
449 (defun cusver-find-files (root &optional old)
450 "Find .el files beneath directory ROOT that contain defcustoms.
451 If optional OLD is non-nil, also include defvars."
452 (process-lines find-program root
453 "-name" "*.el"
454 "-exec" grep-program
455 "-l" "-E" (format "^[ \\t]*\\(def%s"
456 (if old "(custom|var)"
457 "custom"
459 "{}" "+"))
461 ;; TODO if a defgroup with a version tag, apply to all customs in that
462 ;; group (eg for new files).
463 (defun cusver-scan (file &optional old)
464 "Scan FILE for `defcustom' calls.
465 Return a list with elements of the form (VAR . VER),
466 This means that FILE contains a defcustom for variable VAR, with
467 a :version tag having value VER (may be nil).
468 If optional argument OLD is non-nil, also scan for defvars."
469 (let ((m (format "Scanning %s..." file))
470 (re (format "^[ \t]*\\((def%s\\)[ \t\n]"
471 (if old "\\(?:custom\\|var\\)" "custom")))
472 alist var ver)
473 (message "%s" m)
474 (with-temp-buffer
475 (insert-file-contents file)
476 ;; FIXME we could theoretically be inside a string.
477 (while (re-search-forward re nil t)
478 (goto-char (match-beginning 1))
479 (if (and (setq form (ignore-errors (read (current-buffer))))
480 (setq var (car-safe (cdr-safe form)))
481 ;; Exclude macros, eg (defcustom ,varname ...).
482 (symbolp var))
483 (setq ver (car (cdr-safe (memq :version form)))
484 alist (cons (cons var ver) alist))
485 (if form (message "Malformed defcustom: `%s'" form)))))
486 (message "%sdone" m)
487 alist))
489 (define-button-type 'cusver-xref 'action #'cusver-goto-xref)
491 (defun cusver-goto-xref (button)
492 "Jump to a lisp file for the BUTTON at point."
493 (let ((file (button-get button 'file))
494 (var (button-get button 'var)))
495 (if (not (file-readable-p file))
496 (message "Cannot read `%s'" file)
497 (with-current-buffer (find-file-noselect file)
498 (goto-char (point-min))
499 (or (re-search-forward (format "^[ \t]*(defcustom[ \t]*%s" var) nil t)
500 (message "Unable to locate defcustom"))
501 (pop-to-buffer (current-buffer))))))
503 ;; You should probably at least do a grep over the old directory
504 ;; to check the results of this look sensible. Eg cus-start if
505 ;; something moved from C to Lisp.
506 ;; TODO handle renamed things with aliases to the old names.
507 ;; What to do about new files? Does everything in there need a :version,
508 ;; or eg just the defgroup?
509 (defun cusver-check (newdir olddir)
510 "Check that defcustoms have :version tags where needed.
511 NEWDIR is the current lisp/ directory, OLDDIR is that from the previous
512 release. A defcustom that is only in NEWDIR should have a :version
513 tag. We exclude cases where a defvar exists in OLDDIR, since
514 just converting a defvar to a defcustom does not require a :version bump.
516 Note that a :version tag should also be added if the value of a defcustom
517 changes (in a non-trivial way). This function does not check for that."
518 (interactive "DNew Lisp directory: \nDOld Lisp directory: ")
519 (or (file-directory-p (setq newdir (expand-file-name newdir)))
520 (error "Directory `%s' not found" newdir))
521 (or (file-directory-p (setq olddir (expand-file-name olddir)))
522 (error "Directory `%s' not found" olddir))
523 (let* ((newfiles (progn (message "Finding new files with defcustoms...")
524 (cusver-find-files newdir)))
525 (oldfiles (progn (message "Finding old files with defcustoms...")
526 (cusver-find-files olddir t)))
527 (newcus (progn (message "Reading new defcustoms...")
528 (mapcar
529 (lambda (file)
530 (cons file (cusver-scan file))) newfiles)))
531 oldcus result thisfile)
532 (message "Reading old defcustoms...")
533 (dolist (file oldfiles)
534 (setq oldcus (append oldcus (cusver-scan file t))))
535 ;; newcus has elements (FILE (VAR VER) ... ).
536 ;; oldcus just (VAR . VER).
537 (message "Checking for version tags...")
538 (dolist (new newcus)
539 (setq file (car new)
540 thisfile
541 (let (missing var)
542 (dolist (cons (cdr new))
543 (or (cdr cons)
544 (assq (setq var (car cons)) oldcus)
545 (push var missing)))
546 (if missing
547 (cons file missing))))
548 (if thisfile
549 (setq result (cons thisfile result))))
550 (message "Checking for version tags... done")
551 (if (not result)
552 (message "No missing :version tags")
553 (pop-to-buffer "*cusver*")
554 (erase-buffer)
555 (insert "These defcustoms might be missing :version tags:\n\n")
556 (dolist (elem result)
557 (let* ((str (file-relative-name (car elem) newdir))
558 (strlen (length str)))
559 (dolist (var (cdr elem))
560 (insert (format "%s: %s\n" str var))
561 (make-text-button (+ (line-beginning-position 0) strlen 2)
562 (line-end-position 0)
563 'file (car elem)
564 'var var
565 'help-echo "Mouse-2: visit this definition"
566 :type 'cusver-xref)))))))
568 (provide 'admin)
570 ;;; admin.el ends here