annotate lisp/info-xref.el @ 82547:5695072a15a4

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