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