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