diff options
| author | Juri Linkov | 2004-03-25 10:32:33 +0000 |
|---|---|---|
| committer | Juri Linkov | 2004-03-25 10:32:33 +0000 |
| commit | 0332a905d8809b9b3361abe9373d19c3e911fd5c (patch) | |
| tree | 5d3e9fc1037b8c155cd46ca6c28f7a1f2ce6745e | |
| parent | e09cd94fd28aa2335a3d6baf8d3532e94982e8a6 (diff) | |
| download | emacs-0332a905d8809b9b3361abe9373d19c3e911fd5c.tar.gz emacs-0332a905d8809b9b3361abe9373d19c3e911fd5c.zip | |
(info-xref-check-buffer): Report empty filename parts.
Remove spurious node duplicate suppression, doesn't work, not wanted.
(info-xref-output): Take format style args, add "sit-for 0" to let
user see the results as they progress.
(info-xref-check-all-custom): New function.
| -rw-r--r-- | lisp/info-xref.el | 103 |
1 files changed, 87 insertions, 16 deletions
diff --git a/lisp/info-xref.el b/lisp/info-xref.el index 91c78e2a5c5..9f856d1deac 100644 --- a/lisp/info-xref.el +++ b/lisp/info-xref.el | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | ;;; info-xref.el --- check external references in an Info document. | 1 | ;;; info-xref.el --- check external references in an Info document. |
| 2 | 2 | ||
| 3 | ;; Copyright 2003 Free Software Foundation, Inc | 3 | ;; Copyright 2003, 2004 Free Software Foundation, Inc |
| 4 | ;; | 4 | ;; |
| 5 | ;; Author: Kevin Ryde <user42@zip.com.au> | 5 | ;; Author: Kevin Ryde <user42@zip.com.au> |
| 6 | ;; Keywords: docs | 6 | ;; Keywords: docs |
| @@ -59,6 +59,11 @@ | |||
| 59 | ;; this is that if for instance there's a source code directory in | 59 | ;; this is that if for instance there's a source code directory in |
| 60 | ;; `Info-directory-list' then a lot of extraneous files might be read, which | 60 | ;; `Info-directory-list' then a lot of extraneous files might be read, which |
| 61 | ;; will be time consuming but should be harmless. | 61 | ;; will be time consuming but should be harmless. |
| 62 | ;; | ||
| 63 | ;; | ||
| 64 | ;; `M-x info-xref-check-all-custom' is a related command, it goes through | ||
| 65 | ;; all info document references in customizable variables, checking them | ||
| 66 | ;; like info file cross references. | ||
| 62 | 67 | ||
| 63 | 68 | ||
| 64 | ;;; Install: | 69 | ;;; Install: |
| @@ -204,32 +209,37 @@ should open up the purported top file and see what subfiles it says." | |||
| 204 | This should be the raw file contents, not `Info-mode'." | 209 | This should be the raw file contents, not `Info-mode'." |
| 205 | (goto-char (point-min)) | 210 | (goto-char (point-min)) |
| 206 | (while (re-search-forward | 211 | (while (re-search-forward |
| 207 | "\\*[Nn]ote[ \n\t]+[^:]*:[ \n\t]+\\(\\(([^)]+)\\)[^.,]+\\)[.,]" | 212 | "\\*[Nn]ote[ \n\t]+[^:]*:[ \n\t]+\\(\\(([^)]*)\\)[^.,]+\\)[.,]" |
| 208 | nil t) | 213 | nil t) |
| 209 | (let* ((file (match-string 2)) | 214 | (let* ((file (match-string 2)) |
| 210 | (node ;; Canonicalize spaces: we could use "[\t\n ]+" but | 215 | (node ;; Canonicalize spaces: we could use "[\t\n ]+" but |
| 211 | ;; we try to avoid uselessly replacing " " with " ". | 216 | ;; we try to avoid uselessly replacing " " with " ". |
| 212 | (replace-regexp-in-string "[\t\n][\t\n ]*\\| [\t\n ]+" " " | 217 | (replace-regexp-in-string "[\t\n][\t\n ]*\\| [\t\n ]+" " " |
| 213 | (match-string 1) t t))) | 218 | (match-string 1) t t))) |
| 214 | ;; see if the file exists, if we haven't tried it before | 219 | (if (string-equal "()" file) |
| 215 | (unless (assoc file info-xref-xfile-alist) | 220 | (info-xref-output "Empty filename part: %s\n" node) |
| 216 | (let ((found (info-xref-goto-node-p file))) | 221 | ;; see if the file exists, if we haven't tried it before |
| 217 | (push (cons file found) info-xref-xfile-alist) | 222 | (unless (assoc file info-xref-xfile-alist) |
| 218 | (unless found | 223 | (let ((found (info-xref-goto-node-p file))) |
| 219 | (info-xref-output (format "Not available to check: %s\n" file))))) | 224 | (push (cons file found) info-xref-xfile-alist) |
| 220 | ;; if the file exists, try the node, if we haven't before | 225 | (unless found |
| 221 | (when (cdr (assoc file info-xref-xfile-alist)) | 226 | (info-xref-output "Not available to check: %s\n" file)))) |
| 222 | (unless (assoc node info-xref-xfile-alist) | 227 | ;; if the file exists, try the node |
| 228 | (when (cdr (assoc file info-xref-xfile-alist)) | ||
| 223 | (if (info-xref-goto-node-p node) | 229 | (if (info-xref-goto-node-p node) |
| 224 | (setq info-xref-good (1+ info-xref-good)) | 230 | (setq info-xref-good (1+ info-xref-good)) |
| 225 | (setq info-xref-bad (1+ info-xref-bad)) | 231 | (setq info-xref-bad (1+ info-xref-bad)) |
| 226 | (info-xref-output (format "No such node: %s\n" node)))))))) | 232 | (info-xref-output "No such node: %s\n" node))))))) |
| 227 | 233 | ||
| 228 | (defun info-xref-output (str) | 234 | (defun info-xref-output (str &rest args) |
| 229 | "Emit STR as an info-xref result message." | 235 | "Emit a `format'-ed message STR+ARGS to the info-xref output buffer." |
| 230 | (with-current-buffer info-xref-results-buffer | 236 | (with-current-buffer info-xref-results-buffer |
| 231 | (insert info-xref-filename-heading str) | 237 | (insert info-xref-filename-heading |
| 232 | (setq info-xref-filename-heading ""))) | 238 | (apply 'format str args)) |
| 239 | (setq info-xref-filename-heading "") | ||
| 240 | ;; all this info-xref can be pretty slow, display now so the user can | ||
| 241 | ;; see some progress | ||
| 242 | (sit-for 0))) | ||
| 233 | 243 | ||
| 234 | ;; When asking Info-goto-node to fork, *info* needs to be the current | 244 | ;; When asking Info-goto-node to fork, *info* needs to be the current |
| 235 | ;; buffer, otherwise it seems to clone the current buffer but then do the | 245 | ;; buffer, otherwise it seems to clone the current buffer but then do the |
| @@ -259,6 +269,67 @@ This should be the raw file contents, not `Info-mode'." | |||
| 259 | (unless (equal (current-buffer) oldbuf) | 269 | (unless (equal (current-buffer) oldbuf) |
| 260 | (kill-buffer (current-buffer)))))))) | 270 | (kill-buffer (current-buffer)))))))) |
| 261 | 271 | ||
| 272 | ;;;###autoload | ||
| 273 | (defun info-xref-check-all-custom () | ||
| 274 | "Check info references in all customize groups and variables. | ||
| 275 | `custom-manual' and `info-link' entries in the `custom-links' list are checked. | ||
| 276 | |||
| 277 | `custom-load' autoloads for all symbols are loaded in order to get all the | ||
| 278 | link information. This will be a lot of lisp packages loaded, and can take | ||
| 279 | quite a while." | ||
| 280 | |||
| 281 | (interactive) | ||
| 282 | (pop-to-buffer info-xref-results-buffer t) | ||
| 283 | (erase-buffer) | ||
| 284 | (let ((info-xref-filename-heading "")) | ||
| 285 | |||
| 286 | ;; `custom-load-symbol' is not used, since it quietly ignores errors, | ||
| 287 | ;; but we want to show them (since they may mean incomplete checking). | ||
| 288 | ;; | ||
| 289 | ;; Just one pass through mapatoms is made. There shouldn't be any new | ||
| 290 | ;; custom-loads setup by packages loaded. | ||
| 291 | ;; | ||
| 292 | (info-xref-output "Loading custom-load autoloads ...\n") | ||
| 293 | (require 'cus-start) | ||
| 294 | (require 'cus-load) | ||
| 295 | (let ((viper-mode nil)) ;; tell viper.el not to ask about viperizing | ||
| 296 | (mapatoms | ||
| 297 | (lambda (symbol) | ||
| 298 | (dolist (load (get symbol 'custom-loads)) | ||
| 299 | (cond ((symbolp load) | ||
| 300 | (condition-case cause (require load) | ||
| 301 | (error | ||
| 302 | (info-xref-output "Symbol `%s': cannot require '%s: %s\n" | ||
| 303 | symbol load cause)))) | ||
| 304 | ;; skip if previously loaded | ||
| 305 | ((assoc load load-history)) | ||
| 306 | ((assoc (locate-library load) load-history)) | ||
| 307 | (t | ||
| 308 | (condition-case cause (load load) | ||
| 309 | (error | ||
| 310 | (info-xref-output "Symbol `%s': cannot load \"%s\": %s\n" | ||
| 311 | symbol load cause))))))))) | ||
| 312 | |||
| 313 | ;; Don't bother to check whether the info file exists as opposed to just | ||
| 314 | ;; a missing node. If you have the lisp then you should have the | ||
| 315 | ;; documentation, so missing node name will be the usual fault. | ||
| 316 | ;; | ||
| 317 | (info-xref-output "\nChecking custom-links references ...\n") | ||
| 318 | (let ((good 0) | ||
| 319 | (bad 0)) | ||
| 320 | (mapatoms | ||
| 321 | (lambda (symbol) | ||
| 322 | (dolist (link (get symbol 'custom-links)) | ||
| 323 | (when (memq (car link) '(custom-manual info-link)) | ||
| 324 | (if (info-xref-goto-node-p (cadr link)) | ||
| 325 | (setq good (1+ good)) | ||
| 326 | (setq bad (1+ bad)) | ||
| 327 | ;; symbol-file gives nil for preloaded variables, would need | ||
| 328 | ;; to copy what describe-variable does to show the right place | ||
| 329 | (info-xref-output "Symbol `%s' (in %s): cannot goto node: %s\n" | ||
| 330 | symbol (symbol-file symbol) (cadr link))))))) | ||
| 331 | (info-xref-output "%d good, %d bad\n" good bad)))) | ||
| 332 | |||
| 262 | (provide 'info-xref) | 333 | (provide 'info-xref) |
| 263 | 334 | ||
| 264 | ;;; arch-tag: 69d4d528-69ed-4cc2-8eb4-c666a0c1d5ac | 335 | ;;; arch-tag: 69d4d528-69ed-4cc2-8eb4-c666a0c1d5ac |