Mercurial > emacs
annotate lisp/info-xref.el @ 112448:9e4388bac77b
* etc/images/README: Add 2011 to copyright years for (un)checked.xpm.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Sun, 23 Jan 2011 17:30:35 -0800 |
parents | db24da5a1cc0 |
children |
rev | line source |
---|---|
54544 | 1 ;;; info-xref.el --- check external references in an Info document |
49698 | 2 |
112218
376148b31b5e
Add 2011 to FSF/AIST copyright years.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
3 ;; Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 |
100908 | 4 ;; Free Software Foundation, Inc. |
54544 | 5 |
49698 | 6 ;; Author: Kevin Ryde <user42@zip.com.au> |
7 ;; Keywords: docs | |
112281 | 8 ;; Version: 3 |
54544 | 9 |
10 ;; This file is part of GNU Emacs. | |
11 | |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
12 ;; GNU Emacs is free software: you can redistribute it and/or modify |
54544 | 13 ;; it under the terms of the GNU General Public License as published by |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
14 ;; the Free Software Foundation, either version 3 of the License, or |
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
15 ;; (at your option) any later version. |
54544 | 16 |
17 ;; GNU Emacs is distributed in the hope that it will be useful, | |
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 ;; GNU General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
49698 | 24 |
25 ;;; Commentary: | |
26 | |
112281 | 27 ;; This is some simple checking of external cross references in info files, |
28 ;; docstrings and custom-links by attempting to visit the nodes specified. | |
49698 | 29 ;; |
112281 | 30 ;; `M-x info-xref-check' checks a single info file. See the docstring for |
31 ;; details. | |
49698 | 32 ;; |
112281 | 33 ;; `M-x info-xref-check-all' checks all info files in Info-directory-list. |
34 ;; This is a good way to check the consistency of the whole system. | |
49698 | 35 ;; |
112281 | 36 ;; `M-x info-xref-check-all-custom' loads up all defcustom variables and |
37 ;; checks any info references in them. | |
49698 | 38 ;; |
112281 | 39 ;; `M-x info-xref-docstrings' checks docstring "Info node ..." hyperlinks in |
40 ;; source files (and other files). | |
41 | |
42 ;;; History: | |
43 | |
44 ;; Version 3 - new M-x info-xref-docstrings, use compilation-mode | |
49698 | 45 |
46 ;;; Code: | |
47 | |
48 (require 'info) | |
112281 | 49 (eval-when-compile |
50 (require 'cl)) ;; for `incf' | |
49698 | 51 |
112281 | 52 ;;----------------------------------------------------------------------------- |
53 ;; vaguely generic | |
49698 | 54 |
112281 | 55 (defun info-xref-lock-file-p (filename) |
56 "Return non-nil if FILENAME is an Emacs lock file. | |
57 A lock file is \".#foo.txt\" etc per `lock-buffer'." | |
58 (string-match "\\(\\`\\|\\/\\)\\.#" filename)) | |
49698 | 59 |
60 (defun info-xref-subfile-p (filename) | |
61 "Return t if FILENAME is an info subfile. | |
112281 | 62 If removing the last \"-<NUM>\" from the filename gives a file |
63 which exists, then consider FILENAME a subfile. This is an | |
64 imperfect test, probably ought to open up the purported top file | |
65 and see what subfiles it says." | |
49698 | 66 (and (string-match "\\`\\(\\([^-]*-\\)*[^-]*\\)-[0-9]+\\(.*\\)\\'" filename) |
67 (file-exists-p (concat (match-string 1 filename) | |
68 (match-string 3 filename))))) | |
69 | |
112281 | 70 (defmacro info-xref-with-file (filename &rest body) |
71 ;; checkdoc-params: (filename body) | |
72 "Evaluate BODY in a buffer containing the contents of FILENAME. | |
73 If FILENAME is already in a buffer then that's used, otherwise a | |
74 temporary buffer. | |
49698 | 75 |
112281 | 76 The current implementation uses `insert-file-contents' rather |
77 than `find-file-noselect' so as not to be held up by queries | |
78 about local variables or possible weirdness in a major mode. | |
79 `lm-with-file' does a similar thing, but it sets | |
80 `emacs-lisp-mode' which is not wanted here." | |
81 | |
82 (declare (debug t) (indent 1)) | |
83 `(let* ((info-xref-with-file--filename ,filename) | |
84 (info-xref-with-file--body (lambda () ,@body)) | |
85 (info-xref-with-file--existing | |
86 (find-buffer-visiting info-xref-with-file--filename))) | |
87 (if info-xref-with-file--existing | |
88 (with-current-buffer info-xref-with-file--existing | |
89 (save-excursion | |
90 (funcall info-xref-with-file--body))) | |
91 (with-temp-buffer | |
92 (insert-file-contents ,filename) | |
93 (funcall info-xref-with-file--body))))) | |
94 | |
95 | |
96 ;;----------------------------------------------------------------------------- | |
97 ;; output buffer | |
98 | |
99 (defconst info-xref-output-buffer "*info-xref results*" | |
100 "Name of the buffer for info-xref results.") | |
101 | |
102 (defvar info-xref-good 0 | |
103 "Count of good cross references, during info-xref processing.") | |
104 (defvar info-xref-bad 0 | |
105 "Count of bad cross references, during info-xref processing.") | |
106 (defvar info-xref-unavail 0 | |
107 "Count of unavailable cross references, during info-xref processing.") | |
108 | |
109 (defvar info-xref-output-heading "" | |
110 "A heading string, during info-xref processing. | |
111 This is shown if there's an error, but not if successful.") | |
112 | |
113 (defvar info-xref-filename nil | |
114 "The current buffer's filename, during info-xref processing. | |
115 When looking at file contents in a temp buffer there's no | |
116 `buffer-file-name', hence this variable.") | |
117 | |
118 (defvar info-xref-xfile-alist nil | |
119 "Info files found or not found, during info-xref processing. | |
120 Key is \"(foo)\" etc and value nil or t according to whether info | |
121 manual \"(foo)\" exists or not. This is used to suppress | |
122 duplicate messages about foo not being available. (Duplicates | |
123 within one top-level file that is.)") | |
49698 | 124 |
112281 | 125 (defvar info-xref-in-progress nil) |
126 (defmacro info-xref-with-output (&rest body) | |
127 "Run BODY with an info-xref output buffer. | |
128 This is meant to nest, so you can wrap it around a set of | |
129 different info-xref checks and have them write to the one output | |
130 buffer created by the outermost `info-xref-with-output', with an | |
131 overall good/bad count summary inserted at the very end." | |
132 | |
133 (declare (debug t)) | |
134 `(save-excursion | |
135 (unless info-xref-in-progress | |
136 (display-buffer (get-buffer-create info-xref-output-buffer)) | |
137 (set-buffer info-xref-output-buffer) | |
138 (setq buffer-read-only nil) | |
139 (fundamental-mode) | |
140 (erase-buffer) | |
141 (insert ";; info-xref output -*- mode: compilation -*-\n\n") | |
142 (compilation-mode) | |
143 (setq info-xref-good 0 | |
144 info-xref-bad 0 | |
145 info-xref-unavail 0 | |
146 info-xref-xfile-alist nil)) | |
147 | |
148 (let ((info-xref-in-progress t) | |
149 (info-xref-output-heading "")) | |
150 ,@body) | |
49698 | 151 |
112281 | 152 (unless info-xref-in-progress |
153 (info-xref-output "done, %d good, %d bad, %d unavailable" | |
154 info-xref-good info-xref-bad info-xref-unavail)))) | |
155 | |
156 (defun info-xref-output (fmt &rest args) | |
157 "Emit a `format'-ed message FMT+ARGS to the `info-xref-output-buffer'." | |
158 (with-current-buffer info-xref-output-buffer | |
159 (save-excursion | |
160 (goto-char (point-max)) | |
161 (let ((inhibit-read-only t)) | |
162 (insert info-xref-output-heading | |
163 (apply 'format fmt args) | |
164 "\n"))) | |
165 (setq info-xref-output-heading "") | |
166 ;; all this info-xref can be pretty slow, display now so the user sees | |
167 ;; some progress | |
168 (sit-for 0))) | |
169 (put 'info-xref-output 'byte-compile-format-like t) | |
49698 | 170 |
112281 | 171 (defun info-xref-output-error (fmt &rest args) |
172 "Emit a `format'-ed error FMT+ARGS to the `info-xref-output-buffer'. | |
173 The error is attributed to `info-xref-filename' and the current | |
174 buffer's line and column of point." | |
175 (apply 'info-xref-output | |
176 (concat "%s:%s:%s: " fmt) | |
177 info-xref-filename | |
178 (1+ (count-lines (point-min) (line-beginning-position))) | |
179 (1+ (current-column)) | |
180 args)) | |
181 (put 'info-xref-output-error 'byte-compile-format-like t) | |
182 | |
183 | |
184 ;;----------------------------------------------------------------------------- | |
185 ;; node checking | |
49698 | 186 |
187 ;; When asking Info-goto-node to fork, *info* needs to be the current | |
188 ;; buffer, otherwise it seems to clone the current buffer but then do the | |
189 ;; goto-node in plain *info*. | |
190 ;; | |
112281 | 191 ;; We only fork if *info* already exists, if it doesn't then can create and |
192 ;; destroy just that instead of a new name. | |
49698 | 193 ;; |
194 ;; If Info-goto-node can't find the file, then no new buffer is created. If | |
195 ;; it finds the file but not the node, then a buffer is created. Handle | |
196 ;; this difference by checking before killing. | |
197 ;; | |
198 (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
|
199 "Return t if it's possible to go to the given NODE." |
49698 | 200 (let ((oldbuf (current-buffer))) |
201 (save-excursion | |
202 (save-window-excursion | |
203 (prog1 | |
204 (condition-case err | |
205 (progn | |
206 (Info-goto-node node | |
207 (when (get-buffer "*info*") | |
208 (set-buffer "*info*") | |
209 "xref - temporary")) | |
210 t) | |
211 (error nil)) | |
212 (unless (equal (current-buffer) oldbuf) | |
112281 | 213 (kill-buffer))))))) |
214 | |
215 (defun info-xref-check-node (node) | |
216 | |
217 ;; Collapse spaces as per info.el and `help-make-xrefs'. | |
218 ;; Note defcustom :info-link nodes don't get this whitespace collapsing, | |
219 ;; they should be the exact node name ready to visit. | |
220 ;; `info-xref-check-all-custom' uses `info-xref-goto-node-p' and so | |
221 ;; doesn't come through here. | |
222 ;; | |
223 ;; Could use "[\t\n ]+" but try to avoid uselessly replacing " " with " ". | |
224 (setq node (replace-regexp-in-string "[\t\n][\t\n ]*\\| [\t\n ]+" " " | |
225 node t t)) | |
226 | |
227 (if (not (string-match "\\`([^)]*)" node)) | |
228 (info-xref-output-error "no `(file)' part at start of node: %s\n" node) | |
229 (let ((file (match-string 0 node))) | |
230 | |
231 (if (string-equal "()" file) | |
232 (info-xref-output-error "empty filename part: %s" node) | |
233 | |
234 ;; see if the file exists, if haven't looked before | |
235 (unless (assoc file info-xref-xfile-alist) | |
236 (let ((found (info-xref-goto-node-p file))) | |
237 (push (cons file found) info-xref-xfile-alist) | |
238 (unless found | |
239 (info-xref-output-error "not available to check: %s\n (this reported once per file)" file)))) | |
240 | |
241 ;; if the file exists, try the node | |
242 (cond ((not (cdr (assoc file info-xref-xfile-alist))) | |
243 (incf info-xref-unavail)) | |
244 ((info-xref-goto-node-p node) | |
245 (incf info-xref-good)) | |
246 (t | |
247 (incf info-xref-bad) | |
248 (info-xref-output-error "no such node: %s" node))))))) | |
249 | |
250 | |
251 ;;----------------------------------------------------------------------------- | |
252 | |
253 ;;;###autoload | |
254 (defun info-xref-check (filename) | |
255 "Check external references in FILENAME, an info document. | |
256 Interactively from an `Info-mode' or `texinfo-mode' buffer the | |
257 current info file is the default. | |
258 | |
259 Results are shown in a `compilation-mode' buffer. The format is | |
260 a bit rough, but there shouldn't be many problems normally. The | |
261 file:line:column: is the info document, but of course normally | |
262 any correction should be made in the original .texi file. | |
263 Finding the right place in the .texi is a manual process. | |
264 | |
265 When a target info file doesn't exist there's obviously no way to | |
266 validate node references within it. A message is given for | |
267 missing target files once per source document. It could be | |
268 simply that you don't have the target installed, or it could be a | |
269 mistake in the reference. | |
270 | |
271 Indirect info files are understood, just pass the top-level | |
272 foo.info to `info-xref-check' and it traverses all sub-files. | |
273 Compressed info files are accepted too as usual for `Info-mode'. | |
274 | |
275 \"makeinfo\" checks references internal to an info document, but | |
276 not external references, which makes it rather easy for mistakes | |
277 to creep in or node name changes to go unnoticed. | |
278 `Info-validate' doesn't check external references either." | |
279 | |
280 (interactive | |
281 (list | |
282 (let* ((default-filename | |
283 (cond ((eq major-mode 'Info-mode) | |
284 Info-current-file) | |
285 ((eq major-mode 'texinfo-mode) | |
286 ;; look for @setfilename like makeinfo.el does | |
287 (save-excursion | |
288 (goto-char (point-min)) | |
289 (if (re-search-forward | |
290 "^@setfilename[ \t]+\\([^ \t\n]+\\)[ \t]*" | |
291 (line-beginning-position 100) t) | |
292 (expand-file-name (match-string 1))))))) | |
293 (prompt (if default-filename | |
294 (format "Info file (%s): " default-filename) | |
295 "Info file: "))) | |
296 (read-file-name prompt nil default-filename t)))) | |
297 | |
298 (info-xref-check-list (list filename))) | |
299 | |
300 ;;;###autoload | |
301 (defun info-xref-check-all () | |
302 "Check external references in all info documents in the info path. | |
303 `Info-directory-list' and `Info-additional-directory-list' are | |
304 the info paths. See `info-xref-check' for how each file is | |
305 checked. | |
306 | |
307 The search for \"all\" info files is rather permissive, since | |
308 info files don't necessarily have a \".info\" extension and in | |
309 particular the Emacs manuals normally don't. If you have a | |
310 source code directory in `Info-directory-list' then a lot of | |
311 extraneous files might be read. This will be time consuming but | |
312 should be harmless." | |
313 | |
314 (interactive) | |
315 (info-xref-check-list (info-xref-all-info-files))) | |
316 | |
317 ;; An alternative for geting only top-level files here would be to simply | |
318 ;; return all files and have info-xref-check-list not follow "Indirect:". | |
319 ;; The current way seems better because it (potentially) gets the proper | |
320 ;; top-level filename into the error messages, and suppresses duplicate "not | |
321 ;; available" messages for all subfiles of a single document. | |
322 | |
323 (defun info-xref-all-info-files () | |
324 "Return a list of all available info files. | |
325 Only top level files are returned, subfiles are excluded. | |
326 | |
327 Since info files don't have to have a .info suffix, all files in | |
328 the relevant directories are considered, which might mean a lot | |
329 of extraneous things if for instance a source code directory is | |
330 in the path." | |
331 | |
332 (info-initialize) ;; establish Info-directory-list | |
333 (apply 'nconc | |
334 (mapcar | |
335 (lambda (dir) | |
336 (let ((result nil)) | |
337 (dolist (name (directory-files | |
338 dir | |
339 t ;; absolute filenames | |
340 "\\`[^.]")) ;; not dotfiles, nor .# lockfiles | |
341 (when (and (file-exists-p name) ;; ignore broken symlinks | |
342 (not (string-match "\\.te?xi\\'" name)) ;; not .texi | |
343 (not (backup-file-name-p name)) | |
344 (not (file-directory-p name)) | |
345 (not (info-xref-subfile-p name))) | |
346 (push name result))) | |
347 (nreverse result))) | |
348 (append Info-directory-list Info-additional-directory-list)))) | |
349 | |
350 (defun info-xref-check-list (filename-list) | |
351 "Check external references in info documents in FILENAME-LIST." | |
352 (info-xref-with-output | |
353 (dolist (info-xref-filename filename-list) | |
354 (setq info-xref-xfile-alist nil) | |
355 (let ((info-xref-output-heading | |
356 (format "Info file %s\n" info-xref-filename))) | |
357 (with-temp-message (format "Looking at %s" info-xref-filename) | |
358 (with-temp-buffer | |
359 (info-insert-file-contents info-xref-filename) | |
360 (goto-char (point-min)) | |
361 (if (search-forward "\^_\nIndirect:\n" nil t) | |
362 (let ((dir (file-name-directory info-xref-filename))) | |
363 (while (looking-at "\\(.*\\): [0-9]+\n") | |
364 (let ((info-xref-filename | |
365 (expand-file-name (match-string 1) dir))) | |
366 (with-temp-buffer | |
367 (info-insert-file-contents info-xref-filename) | |
368 (info-xref-check-buffer))) | |
369 (forward-line))) | |
370 (info-xref-check-buffer)))))))) | |
371 | |
372 (defun info-xref-check-buffer () | |
373 "Check external references in the info file in the current buffer. | |
374 This should be the raw file contents, not `Info-mode'." | |
375 (goto-char (point-min)) | |
376 (while (re-search-forward | |
377 "\\*[Nn]ote[ \n\t]+[^:]*:[ \n\t]+\\(\\(([^)]*)\\)[^.,]+\\)[.,]" | |
378 nil t) | |
379 (save-excursion | |
380 (goto-char (match-beginning 1)) ;; start of nodename as error position | |
381 (info-xref-check-node (match-string 1))))) | |
382 | |
383 (defvar viper-mode) ;; quieten the byte compiler | |
384 (defvar gnus-registry-install) | |
49698 | 385 |
54543
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
386 ;;;###autoload |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
387 (defun info-xref-check-all-custom () |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
388 "Check info references in all customize groups and variables. |
112281 | 389 Info references can be in `custom-manual' or `info-link' entries |
390 of the `custom-links' for a variable. | |
54543
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
391 |
112281 | 392 Any `custom-load' autoloads in variables are loaded in order to |
393 get full link information. This will be a lot of Lisp packages | |
394 and can take a long time." | |
54543
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
395 |
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
396 (interactive) |
112281 | 397 (info-xref-with-output |
398 | |
399 ;; `custom-load-symbol' is not used, since it quietly ignores errors, but | |
400 ;; we want to show them since they mean incomplete checking. | |
401 ;; | |
402 ;; Just one pass through mapatoms is made. There shouldn't be any new | |
403 ;; custom-loads setup by packages loaded. | |
404 ;; | |
405 (info-xref-output "Loading custom-load autoloads ...") | |
406 (require 'cus-start) | |
407 (require 'cus-load) | |
408 | |
409 ;; These are `setq' rather than `let' since a let would unbind the | |
410 ;; variables after viper.el/gnus-registry.el have loaded, defeating the | |
411 ;; defvars in those files. Of course it'd be better if those files | |
412 ;; didn't make interactive queries on loading at all, to allow for | |
413 ;; programmatic loading like here. | |
414 (unless (boundp 'viper-mode) | |
415 (setq viper-mode nil)) ;; avoid viper.el ask about viperizing | |
416 (unless (boundp 'gnus-registry-install) | |
417 (setq gnus-registry-install nil)) ;; avoid gnus-registery.el querying | |
418 | |
419 (mapatoms | |
420 (lambda (symbol) | |
421 (dolist (load (get symbol 'custom-loads)) | |
422 (cond ((symbolp load) | |
423 (condition-case cause (require load) | |
424 (error | |
425 (info-xref-output "Symbol `%s': cannot require '%s: %s" | |
426 symbol load cause)))) | |
427 ;; skip if previously loaded | |
428 ((assoc load load-history)) | |
429 ((assoc (locate-library load) load-history)) | |
430 (t | |
431 (condition-case err | |
432 (load load) | |
433 (error | |
434 (info-xref-output "Symbol `%s': cannot load \"%s\": %s" | |
435 symbol load | |
436 (error-message-string err))))))))) | |
437 | |
438 ;; Don't bother to check whether the info file exists as opposed to just | |
439 ;; a missing node. If you have the code then you should have the | |
440 ;; documentation, so a wrong node name will be the usual fault. | |
441 ;; | |
442 (info-xref-output "\nChecking custom-links references ...") | |
443 (mapatoms | |
444 (lambda (symbol) | |
445 (dolist (link (get symbol 'custom-links)) | |
446 (when (memq (car link) '(custom-manual info-link)) | |
447 ;; skip :tag part of (custom-manual :tag "Foo" "(foo)Node") | |
448 (if (eq :tag (cadr link)) | |
449 (setq link (cddr link))) | |
450 (if (info-xref-goto-node-p (cadr link)) | |
451 (incf info-xref-good) | |
452 (incf info-xref-bad) | |
453 ;; symbol-file gives nil for preloaded variables, would need | |
454 ;; to copy what describe-variable does to show the right place | |
455 (info-xref-output "Symbol `%s' (file %s): cannot goto node: %s" | |
456 symbol | |
457 (symbol-file symbol 'defvar) | |
458 (cadr link))))))))) | |
54543
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
459 |
112281 | 460 ;;;###autoload |
461 (defun info-xref-docstrings (filename-list) | |
462 ;; checkdoc-params: (filename-list) | |
463 "Check docstring info node references in source files. | |
464 The given files are searched for docstring hyperlinks like | |
465 | |
466 Info node `(elisp)Documentation Tips' | |
467 | |
468 and those links checked by attempting to visit the target nodes | |
469 as per `info-xref-check' does. | |
470 | |
471 Interactively filenames are read as a wildcard pattern like | |
472 \"foo*.el\", with the current file as a default. Usually this | |
473 will be lisp sources, but anything with such hyperlinks can be | |
474 checked, including the Emacs .c sources (or the etc/DOC file of | |
475 all builtins). | |
476 | |
477 Because info node hyperlinks are found by a simple regexp search | |
478 in the files, the Lisp code checked doesn't have to be loaded, | |
479 and links can be in the file commentary or elsewhere too. Even | |
480 .elc files can usually be checked successfully if you don't have | |
481 the sources handy." | |
482 (interactive | |
112282
bcf4b132f3d5
* lisp/info-xref.el (info-xref-docstrings): Replace cl function.
Glenn Morris <rgm@gnu.org>
parents:
112281
diff
changeset
|
483 (let* ((default (and buffer-file-name |
112281 | 484 (file-relative-name buffer-file-name))) |
112282
bcf4b132f3d5
* lisp/info-xref.el (info-xref-docstrings): Replace cl function.
Glenn Morris <rgm@gnu.org>
parents:
112281
diff
changeset
|
485 (prompt (if default |
bcf4b132f3d5
* lisp/info-xref.el (info-xref-docstrings): Replace cl function.
Glenn Morris <rgm@gnu.org>
parents:
112281
diff
changeset
|
486 (format "Filename with wildcards (%s): " |
bcf4b132f3d5
* lisp/info-xref.el (info-xref-docstrings): Replace cl function.
Glenn Morris <rgm@gnu.org>
parents:
112281
diff
changeset
|
487 default) |
bcf4b132f3d5
* lisp/info-xref.el (info-xref-docstrings): Replace cl function.
Glenn Morris <rgm@gnu.org>
parents:
112281
diff
changeset
|
488 "Filename with wildcards: ")) |
bcf4b132f3d5
* lisp/info-xref.el (info-xref-docstrings): Replace cl function.
Glenn Morris <rgm@gnu.org>
parents:
112281
diff
changeset
|
489 (pattern (read-file-name prompt nil default)) |
bcf4b132f3d5
* lisp/info-xref.el (info-xref-docstrings): Replace cl function.
Glenn Morris <rgm@gnu.org>
parents:
112281
diff
changeset
|
490 ;; absolute filenames |
bcf4b132f3d5
* lisp/info-xref.el (info-xref-docstrings): Replace cl function.
Glenn Morris <rgm@gnu.org>
parents:
112281
diff
changeset
|
491 (filename-list (file-expand-wildcards pattern t)) |
bcf4b132f3d5
* lisp/info-xref.el (info-xref-docstrings): Replace cl function.
Glenn Morris <rgm@gnu.org>
parents:
112281
diff
changeset
|
492 newlist) |
bcf4b132f3d5
* lisp/info-xref.el (info-xref-docstrings): Replace cl function.
Glenn Morris <rgm@gnu.org>
parents:
112281
diff
changeset
|
493 (setq filename-list |
bcf4b132f3d5
* lisp/info-xref.el (info-xref-docstrings): Replace cl function.
Glenn Morris <rgm@gnu.org>
parents:
112281
diff
changeset
|
494 (dolist (file filename-list (nreverse newlist)) |
bcf4b132f3d5
* lisp/info-xref.el (info-xref-docstrings): Replace cl function.
Glenn Morris <rgm@gnu.org>
parents:
112281
diff
changeset
|
495 (or (info-xref-lock-file-p file) |
112285
db24da5a1cc0
* lisp/info-xref.el (info-xref-docstrings): Also skip directories.
Glenn Morris <rgm@gnu.org>
parents:
112282
diff
changeset
|
496 (file-directory-p file) |
112282
bcf4b132f3d5
* lisp/info-xref.el (info-xref-docstrings): Replace cl function.
Glenn Morris <rgm@gnu.org>
parents:
112281
diff
changeset
|
497 (push file newlist)))) |
112281 | 498 (unless filename-list |
499 (error "No files: %S" pattern)) | |
500 (list filename-list))) | |
501 | |
502 (eval-and-compile | |
503 (require 'help-mode)) ;; for `help-xref-info-regexp' | |
504 | |
505 (info-xref-with-output | |
506 (dolist (info-xref-filename filename-list) | |
507 (setq info-xref-xfile-alist nil) ;; "not found"s once per file | |
508 | |
509 (info-xref-with-file info-xref-filename | |
510 (goto-char (point-min)) | |
511 (while (re-search-forward help-xref-info-regexp nil t) | |
512 (let ((node (match-string 2))) | |
513 (save-excursion | |
514 (goto-char (match-beginning 2)) ;; start of node as error position | |
515 | |
516 ;; skip nodes with "%" as probably `format' strings such as in | |
517 ;; info-look.el | |
518 (unless (string-match "%" node) | |
519 | |
520 ;; "(emacs)" is the default manual for docstring hyperlinks, | |
521 ;; per `help-make-xrefs' | |
522 (unless (string-match "\\`(" node) | |
523 (setq node (concat "(emacs)" node))) | |
524 | |
525 (info-xref-check-node node))))))))) | |
526 | |
54543
5766a12d96ac
(info-xref-check-buffer): Report empty filename parts.
Juri Linkov <juri@jurta.org>
parents:
52401
diff
changeset
|
527 |
49698 | 528 (provide 'info-xref) |
529 | |
530 ;;; info-xref.el ends here |