international/mule-conf.el (compound-text-with-extensions): Add :mime-charset propert...
[bpt/emacs.git] / admin / admin.el
1 ;;; admin.el --- utilities for Emacs administration
2
3 ;; Copyright (C) 2001-2012 Free Software Foundation, Inc.
4
5 ;; This file is part of GNU Emacs.
6
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.
11
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.
16
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/>.
19
20 ;;; Commentary:
21
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.
26
27 ;;; Code:
28
29 (defvar add-log-time-format) ; in add-log
30
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)))))
50
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))
57
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"))))
144
145
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")))
176
177 ;;; Various bits of magic for generating the web manuals
178
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)))
228
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")
232
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")
239
240 (defconst manual-style-string "<style type=\"text/css\">
241 @import url('/style.css');\n</style>\n")
242
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))))
248
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)))
267
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))))))
303
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"))))
309
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))
313
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))
321
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))))
338
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)))))
352
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")))
361
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))
422 (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))))
428
429 \f
430 ;; Stuff to check new defcustoms got :version tags.
431 ;; Adapted from check-declare.el.
432
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"
442 ))
443 "{}" "+"))
444
445 ;; TODO if a defgroup with a version tag, apply to all customs in that
446 ;; group (eg for new files).
447 (defun cusver-scan (file &optional old)
448 "Scan FILE for `defcustom' calls.
449 Return a list with elements of the form (VAR . VER),
450 This means that FILE contains a defcustom for variable VAR, with
451 a :version tag having value VER (may be nil).
452 If optional argument OLD is non-nil, also scan for defvars."
453 (let ((m (format "Scanning %s..." file))
454 (re (format "^[ \t]*\\((def%s\\)[ \t\n]"
455 (if old "\\(?:custom\\|var\\)" "custom")))
456 alist var ver form)
457 (message "%s" m)
458 (with-temp-buffer
459 (insert-file-contents file)
460 ;; FIXME we could theoretically be inside a string.
461 (while (re-search-forward re nil t)
462 (goto-char (match-beginning 1))
463 (if (and (setq form (ignore-errors (read (current-buffer))))
464 (setq var (car-safe (cdr-safe form)))
465 ;; Exclude macros, eg (defcustom ,varname ...).
466 (symbolp var))
467 (setq ver (car (cdr-safe (memq :version form)))
468 alist (cons (cons var ver) alist))
469 (if form (message "Malformed defcustom: `%s'" form)))))
470 (message "%sdone" m)
471 alist))
472
473 (define-button-type 'cusver-xref 'action #'cusver-goto-xref)
474
475 (defun cusver-goto-xref (button)
476 "Jump to a lisp file for the BUTTON at point."
477 (let ((file (button-get button 'file))
478 (var (button-get button 'var)))
479 (if (not (file-readable-p file))
480 (message "Cannot read `%s'" file)
481 (with-current-buffer (find-file-noselect file)
482 (goto-char (point-min))
483 (or (re-search-forward (format "^[ \t]*(defcustom[ \t]*%s" var) nil t)
484 (message "Unable to locate defcustom"))
485 (pop-to-buffer (current-buffer))))))
486
487 ;; You should probably at least do a grep over the old directory
488 ;; to check the results of this look sensible. Eg cus-start if
489 ;; something moved from C to Lisp.
490 ;; TODO handle renamed things with aliases to the old names.
491 ;; What to do about new files? Does everything in there need a :version,
492 ;; or eg just the defgroup?
493 (defun cusver-check (newdir olddir)
494 "Check that defcustoms have :version tags where needed.
495 NEWDIR is the current lisp/ directory, OLDDIR is that from the previous
496 release. A defcustom that is only in NEWDIR should have a :version
497 tag. We exclude cases where a defvar exists in OLDDIR, since
498 just converting a defvar to a defcustom does not require a :version bump.
499
500 Note that a :version tag should also be added if the value of a defcustom
501 changes (in a non-trivial way). This function does not check for that."
502 (interactive "DNew Lisp directory: \nDOld Lisp directory: ")
503 (or (file-directory-p (setq newdir (expand-file-name newdir)))
504 (error "Directory `%s' not found" newdir))
505 (or (file-directory-p (setq olddir (expand-file-name olddir)))
506 (error "Directory `%s' not found" olddir))
507 (let* ((newfiles (progn (message "Finding new files with defcustoms...")
508 (cusver-find-files newdir)))
509 (oldfiles (progn (message "Finding old files with defcustoms...")
510 (cusver-find-files olddir t)))
511 (newcus (progn (message "Reading new defcustoms...")
512 (mapcar
513 (lambda (file)
514 (cons file (cusver-scan file))) newfiles)))
515 oldcus result thisfile file)
516 (message "Reading old defcustoms...")
517 (dolist (file oldfiles)
518 (setq oldcus (append oldcus (cusver-scan file t))))
519 ;; newcus has elements (FILE (VAR VER) ... ).
520 ;; oldcus just (VAR . VER).
521 (message "Checking for version tags...")
522 (dolist (new newcus)
523 (setq file (car new)
524 thisfile
525 (let (missing var)
526 (dolist (cons (cdr new))
527 (or (cdr cons)
528 (assq (setq var (car cons)) oldcus)
529 (push var missing)))
530 (if missing
531 (cons file missing))))
532 (if thisfile
533 (setq result (cons thisfile result))))
534 (message "Checking for version tags... done")
535 (if (not result)
536 (message "No missing :version tags")
537 (pop-to-buffer "*cusver*")
538 (erase-buffer)
539 (insert "These defcustoms might be missing :version tags:\n\n")
540 (dolist (elem result)
541 (let* ((str (file-relative-name (car elem) newdir))
542 (strlen (length str)))
543 (dolist (var (cdr elem))
544 (insert (format "%s: %s\n" str var))
545 (make-text-button (+ (line-beginning-position 0) strlen 2)
546 (line-end-position 0)
547 'file (car elem)
548 'var var
549 'help-echo "Mouse-2: visit this definition"
550 :type 'cusver-xref)))))))
551
552 (provide 'admin)
553
554 ;;; admin.el ends here