Mercurial > emacs
annotate lisp/info-xref.el @ 54543:5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Remove spurious node duplicate suppression, doesn't work, not wanted.
(info-xref-output): Take format style args, add "sit-for 0" to let
user see the results as they progress.
(info-xref-check-all-custom): New function.
author | Juri Linkov <juri@jurta.org> |
---|---|
date | Thu, 25 Mar 2004 10:32:33 +0000 |
parents | 695cf19ef79e |
children | 81243b364a79 |
rev | line source |
---|---|
49698 | 1 ;;; info-xref.el --- check external references in an Info document. |
2 | |
54543
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
3 ;; Copyright 2003, 2004 Free Software Foundation, Inc |
49698 | 4 ;; |
5 ;; Author: Kevin Ryde <user42@zip.com.au> | |
6 ;; Keywords: docs | |
7 ;; | |
8 ;; info-xref.el is free software; you can redistribute it and/or modify | |
9 ;; it under the terms of the GNU General Public License as published by the | |
10 ;; Free Software Foundation; either version 2, or (at your option) any later | |
11 ;; version. | |
12 ;; | |
13 ;; info-xref.el is distributed in the hope that it will be useful, but | |
14 ;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | |
16 ;; Public License for more details. | |
17 ;; | |
18 ;; You can get a copy of the GNU General Public License online at | |
19 ;; http://www.gnu.org/licenses/gpl.txt, or you should have one in the file | |
20 ;; COPYING which comes with GNU Emacs and other GNU programs. Failing that, | |
21 ;; write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
22 ;; Boston, MA 02111-1307, USA. | |
23 | |
24 | |
25 ;;; Commentary: | |
26 | |
27 ;; This file implements some simple checking of external cross references in | |
28 ;; info files, by attempting to visit the nodes specified. | |
29 ;; | |
30 ;; "makeinfo" checks references internal to a document, but not external | |
31 ;; references, which makes it rather easy for mistakes to creep in or node | |
32 ;; name changes to go unnoticed. `Info-validate' doesn't check external | |
33 ;; references either. | |
34 ;; | |
35 ;; `M-x info-xref-check' checks one file. When invoked from an Info-mode or | |
36 ;; texinfo-mode buffer, the current info file is the default at the prompt. | |
37 ;; | |
38 ;; `M-x info-xref-check-all' looks at everything in the normal info path. | |
39 ;; This might be a lot of files but it's a good way to check the consistency | |
40 ;; of the whole system. | |
41 ;; | |
42 ;; Results are shown in a buffer. The format is a bit rough, but hopefully | |
43 ;; there won't be too many problems normally, and correcting them is a | |
44 ;; manual process anyway, a case of finding the right spot in the original | |
45 ;; .texi and finding what node it ought to point to. | |
46 ;; | |
47 ;; When a target info file doesn't exist there's clearly no way to validate | |
48 ;; node references within it. A message is given for missing target files | |
49 ;; (once per source document), it could be simply that the target hasn't | |
50 ;; been installed, or it could be a mistake in the reference. | |
51 ;; | |
52 ;; Indirect info files are understood, just pass the top-level foo.info to | |
53 ;; `info-xref-check' and it traverses all sub-files. Compressed info files | |
54 ;; are accepted too, as usual for `Info-mode'. | |
55 ;; | |
56 ;; `info-xref-check-all' is rather permissive in what it considers an info | |
57 ;; file. It has to be since info files don't necessarily have a ".info" | |
58 ;; suffix (eg. this is usual for the emacs manuals). One consequence of | |
59 ;; this is that if for instance there's a source code directory in | |
60 ;; `Info-directory-list' then a lot of extraneous files might be read, which | |
61 ;; will be time consuming but should be harmless. | |
54543
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
62 ;; |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
63 ;; |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
64 ;; `M-x info-xref-check-all-custom' is a related command, it goes through |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
65 ;; all info document references in customizable variables, checking them |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
66 ;; like info file cross references. |
49698 | 67 |
68 | |
69 ;;; Install: | |
70 | |
71 ;; Put info-xref.el somewhere in your `load-path', and in your .emacs put | |
72 ;; | |
73 ;; (autoload 'info-xref-check "info-xref" nil t) | |
74 ;; (autoload 'info-xref-check-all "info-xref" nil t) | |
75 ;; | |
76 ;; then | |
77 ;; | |
78 ;; M-x info-xref-check | |
79 ;; | |
80 ;; and enter an info file name. | |
81 | |
82 | |
83 ;;; Emacsen: | |
84 | |
85 ;; Designed for use with GNU Emacs 21. | |
86 | |
87 | |
88 ;;; History: | |
89 | |
90 ;; Version 1 - the first version. | |
91 | |
92 | |
93 ;;; Code: | |
94 | |
95 (require 'info) | |
96 | |
97 (defconst info-xref-results-buffer "*info-xref results*" | |
98 "Name of the buffer for info-xref results.") | |
99 | |
100 ;;;###autoload | |
101 (defun info-xref-check (filename) | |
102 "Check external references in FILENAME, an info document." | |
103 (interactive | |
104 (list | |
105 (let* ((default-filename | |
106 (cond ((eq major-mode 'Info-mode) | |
107 Info-current-file) | |
108 ((eq major-mode 'texinfo-mode) | |
109 ;; look for @setfilename like makeinfo.el does | |
110 (save-excursion | |
111 (goto-char (point-min)) | |
112 (if (re-search-forward | |
113 "^@setfilename[ \t]+\\([^ \t\n]+\\)[ \t]*" | |
49729
f3c2ee28113b
(info-xref-check): Use line-beginning-position.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49717
diff
changeset
|
114 (line-beginning-position 100) t) |
49698 | 115 (expand-file-name (match-string 1))))))) |
116 (prompt (if default-filename | |
117 (format "Info file (%s): " default-filename) | |
118 "Info file: "))) | |
49729
f3c2ee28113b
(info-xref-check): Use line-beginning-position.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49717
diff
changeset
|
119 (read-file-name prompt nil default-filename t)))) |
49698 | 120 (info-xref-check-list (list filename))) |
121 | |
122 ;;;###autoload | |
123 (defun info-xref-check-all () | |
124 "Check external references in all info documents in the usual path. | |
125 The usual path is `Info-directory-list' and `Info-additional-directory-list'." | |
126 (interactive) | |
127 (info-xref-check-list (info-xref-all-info-files))) | |
128 | |
129 ;; An alternative to trying to get only top-level files here would be to | |
130 ;; simply return all files, and have info-xref-check-list not follow | |
131 ;; Indirect:. The current way seems a bit nicer though, because it gets the | |
132 ;; proper top-level filename into the error messages, and suppresses | |
133 ;; duplicate "not available" messages for all subfiles of a single document. | |
134 | |
135 (defun info-xref-all-info-files () | |
136 "Return a list of all available info files. | |
137 Only top-level files are returned, subfiles are excluded. | |
138 | |
139 Since info files don't have to have a .info suffix, all files in the | |
140 relevant directories are considered, which might mean a lot of extraneous | |
141 things are returned if for instance a source code directory is in the path." | |
142 | |
143 (info-initialize) ;; establish Info-directory-list | |
49729
f3c2ee28113b
(info-xref-check): Use line-beginning-position.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49717
diff
changeset
|
144 (apply 'nconc |
49698 | 145 (mapcar |
146 (lambda (dir) | |
147 (let ((result nil)) | |
148 (dolist (name (directory-files dir t)) | |
49729
f3c2ee28113b
(info-xref-check): Use line-beginning-position.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49717
diff
changeset
|
149 (unless (or (file-directory-p name) (info-xref-subfile-p name)) |
f3c2ee28113b
(info-xref-check): Use line-beginning-position.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49717
diff
changeset
|
150 (push name result))) |
f3c2ee28113b
(info-xref-check): Use line-beginning-position.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49717
diff
changeset
|
151 (nreverse result))) |
49698 | 152 (append Info-directory-list Info-additional-directory-list)))) |
153 | |
154 (defun info-xref-subfile-p (filename) | |
155 "Return t if FILENAME is an info subfile. | |
156 If removing the last \"-<NUM>\" from the filename gives a file that exists, | |
157 then consider FILENAME a subfile. This is an imperfect test, we probably | |
158 should open up the purported top file and see what subfiles it says." | |
159 (and (string-match "\\`\\(\\([^-]*-\\)*[^-]*\\)-[0-9]+\\(.*\\)\\'" filename) | |
160 (file-exists-p (concat (match-string 1 filename) | |
161 (match-string 3 filename))))) | |
162 | |
163 | |
164 ;; Some dynamic variables are used to share information with sub-functions | |
165 ;; below. | |
166 ;; | |
167 ;; info-xref-filename - current top-level filename, eg. /usr/info/foo.info.gz | |
168 ;; | |
169 ;; info-xref-filename-header - a heading message for the current top-level | |
170 ;; filename, or "" when it's been printed. | |
171 ;; | |
172 ;; info-xref-good - count of good cross references. | |
173 ;; | |
174 ;; info-xref-bad - count of bad cross references. | |
175 ;; | |
176 ;; info-xref-xfile-alist - indexed by "(foo)" with value nil or t according | |
177 ;; to whether "(foo)" exists or not. This is used to suppress duplicate | |
178 ;; messages about foo not being available. (Duplicates within one | |
179 ;; top-level file that is.) | |
180 | |
181 (defun info-xref-check-list (filename-list) | |
182 "Check external references in info documents in FILENAME-LIST." | |
183 (pop-to-buffer info-xref-results-buffer t) | |
184 (erase-buffer) | |
185 (let ((info-xref-good 0) | |
186 (info-xref-bad 0)) | |
187 (dolist (info-xref-filename filename-list) | |
188 (let ((info-xref-filename-heading | |
189 (format "In file %s:\n" info-xref-filename)) | |
190 (info-xref-xfile-alist nil)) | |
191 (with-temp-message (format "Looking at %s" info-xref-filename) | |
192 (with-temp-buffer | |
193 (info-insert-file-contents info-xref-filename) | |
194 (goto-char (point-min)) | |
195 (if (re-search-forward "\^_\nIndirect:\n" nil t) | |
196 (let ((dir (file-name-directory info-xref-filename))) | |
197 (while (looking-at "\\(.*\\): [0-9]+\n") | |
198 (let ((subfile (match-string 1))) | |
199 (with-temp-buffer | |
200 (info-insert-file-contents | |
201 (expand-file-name subfile dir)) | |
202 (info-xref-check-buffer))) | |
203 (forward-line))) | |
204 (info-xref-check-buffer)))))) | |
205 (insert (format "done, %d good, %d bad\n" info-xref-good info-xref-bad)))) | |
206 | |
207 (defun info-xref-check-buffer () | |
208 "Check external references in the info file in the current buffer. | |
49717
ecb17cef5c44
(info-xref-check-buffer): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
49698
diff
changeset
|
209 This should be the raw file contents, not `Info-mode'." |
49698 | 210 (goto-char (point-min)) |
211 (while (re-search-forward | |
54543
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
212 "\\*[Nn]ote[ \n\t]+[^:]*:[ \n\t]+\\(\\(([^)]*)\\)[^.,]+\\)[.,]" |
49698 | 213 nil t) |
214 (let* ((file (match-string 2)) | |
49729
f3c2ee28113b
(info-xref-check): Use line-beginning-position.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49717
diff
changeset
|
215 (node ;; Canonicalize spaces: we could use "[\t\n ]+" but |
f3c2ee28113b
(info-xref-check): Use line-beginning-position.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49717
diff
changeset
|
216 ;; we try to avoid uselessly replacing " " with " ". |
f3c2ee28113b
(info-xref-check): Use line-beginning-position.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49717
diff
changeset
|
217 (replace-regexp-in-string "[\t\n][\t\n ]*\\| [\t\n ]+" " " |
f3c2ee28113b
(info-xref-check): Use line-beginning-position.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49717
diff
changeset
|
218 (match-string 1) t t))) |
54543
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
219 (if (string-equal "()" file) |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
220 (info-xref-output "Empty filename part: %s\n" node) |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
221 ;; see if the file exists, if we haven't tried it before |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
222 (unless (assoc file info-xref-xfile-alist) |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
223 (let ((found (info-xref-goto-node-p file))) |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
224 (push (cons file found) info-xref-xfile-alist) |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
225 (unless found |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
226 (info-xref-output "Not available to check: %s\n" file)))) |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
227 ;; if the file exists, try the node |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
228 (when (cdr (assoc file info-xref-xfile-alist)) |
49698 | 229 (if (info-xref-goto-node-p node) |
230 (setq info-xref-good (1+ info-xref-good)) | |
231 (setq info-xref-bad (1+ info-xref-bad)) | |
54543
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
232 (info-xref-output "No such node: %s\n" node))))))) |
49698 | 233 |
54543
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
234 (defun info-xref-output (str &rest args) |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
235 "Emit a `format'-ed message STR+ARGS to the info-xref output buffer." |
49698 | 236 (with-current-buffer info-xref-results-buffer |
54543
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
237 (insert info-xref-filename-heading |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
238 (apply 'format str args)) |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
239 (setq info-xref-filename-heading "") |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
240 ;; all this info-xref can be pretty slow, display now so the user can |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
241 ;; see some progress |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
242 (sit-for 0))) |
49698 | 243 |
244 ;; When asking Info-goto-node to fork, *info* needs to be the current | |
245 ;; buffer, otherwise it seems to clone the current buffer but then do the | |
246 ;; goto-node in plain *info*. | |
247 ;; | |
248 ;; We only fork if *info* already exists, if it doesn't then we can create | |
249 ;; and destroy just that instead of a new name. | |
250 ;; | |
251 ;; If Info-goto-node can't find the file, then no new buffer is created. If | |
252 ;; it finds the file but not the node, then a buffer is created. Handle | |
253 ;; this difference by checking before killing. | |
254 ;; | |
255 (defun info-xref-goto-node-p (node) | |
49729
f3c2ee28113b
(info-xref-check): Use line-beginning-position.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49717
diff
changeset
|
256 "Return t if it's possible to go to the given NODE." |
49698 | 257 (let ((oldbuf (current-buffer))) |
258 (save-excursion | |
259 (save-window-excursion | |
260 (prog1 | |
261 (condition-case err | |
262 (progn | |
263 (Info-goto-node node | |
264 (when (get-buffer "*info*") | |
265 (set-buffer "*info*") | |
266 "xref - temporary")) | |
267 t) | |
268 (error nil)) | |
269 (unless (equal (current-buffer) oldbuf) | |
270 (kill-buffer (current-buffer)))))))) | |
271 | |
54543
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
272 ;;;###autoload |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
273 (defun info-xref-check-all-custom () |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
274 "Check info references in all customize groups and variables. |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
275 `custom-manual' and `info-link' entries in the `custom-links' list are checked. |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
276 |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
277 `custom-load' autoloads for all symbols are loaded in order to get all the |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
278 link information. This will be a lot of lisp packages loaded, and can take |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
279 quite a while." |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
280 |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
281 (interactive) |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
282 (pop-to-buffer info-xref-results-buffer t) |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
283 (erase-buffer) |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
284 (let ((info-xref-filename-heading "")) |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
285 |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
286 ;; `custom-load-symbol' is not used, since it quietly ignores errors, |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
287 ;; but we want to show them (since they may mean incomplete checking). |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
288 ;; |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
289 ;; Just one pass through mapatoms is made. There shouldn't be any new |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
290 ;; custom-loads setup by packages loaded. |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
291 ;; |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
292 (info-xref-output "Loading custom-load autoloads ...\n") |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
293 (require 'cus-start) |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
294 (require 'cus-load) |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
295 (let ((viper-mode nil)) ;; tell viper.el not to ask about viperizing |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
296 (mapatoms |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
297 (lambda (symbol) |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
298 (dolist (load (get symbol 'custom-loads)) |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
299 (cond ((symbolp load) |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
300 (condition-case cause (require load) |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
301 (error |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
302 (info-xref-output "Symbol `%s': cannot require '%s: %s\n" |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
303 symbol load cause)))) |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
304 ;; skip if previously loaded |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
305 ((assoc load load-history)) |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
306 ((assoc (locate-library load) load-history)) |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
307 (t |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
308 (condition-case cause (load load) |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
309 (error |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
310 (info-xref-output "Symbol `%s': cannot load \"%s\": %s\n" |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
311 symbol load cause))))))))) |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
312 |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
313 ;; Don't bother to check whether the info file exists as opposed to just |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
314 ;; a missing node. If you have the lisp then you should have the |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
315 ;; documentation, so missing node name will be the usual fault. |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
316 ;; |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
317 (info-xref-output "\nChecking custom-links references ...\n") |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
318 (let ((good 0) |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
319 (bad 0)) |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
320 (mapatoms |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
321 (lambda (symbol) |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
322 (dolist (link (get symbol 'custom-links)) |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
323 (when (memq (car link) '(custom-manual info-link)) |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
324 (if (info-xref-goto-node-p (cadr link)) |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
325 (setq good (1+ good)) |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
326 (setq bad (1+ bad)) |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
327 ;; symbol-file gives nil for preloaded variables, would need |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
328 ;; to copy what describe-variable does to show the right place |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
329 (info-xref-output "Symbol `%s' (in %s): cannot goto node: %s\n" |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
330 symbol (symbol-file symbol) (cadr link))))))) |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
331 (info-xref-output "%d good, %d bad\n" good bad)))) |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
332 |
49698 | 333 (provide 'info-xref) |
334 | |
52401 | 335 ;;; arch-tag: 69d4d528-69ed-4cc2-8eb4-c666a0c1d5ac |
49698 | 336 ;;; info-xref.el ends here |