-;; Can this be done better?
-(defun info-xref-whitespace (str)
- "In STR, convert tabs and newlines to spaces, collapse repeated spaces."
- (setq str (copy-sequence str))
- (dotimes (i (length str))
- (let ((c (elt str i)))
- (if (or (= c ?\n)
- (= c ?\t))
- (aset str i ? ))))
- (let ((dst 0)
- (prev -1))
- (dotimes (i (length str))
- (let ((c (elt str i)))
- (unless (and (= c ? )
- (= prev ? ))
- (aset str dst c)
- (setq dst (1+ dst)))
- (setq prev c)))
- (setq str (substring str 0 dst)))
- str)
+;;;###autoload
+(defun info-xref-check-all-custom ()
+ "Check info references in all customize groups and variables.
+`custom-manual' and `info-link' entries in the `custom-links' list are checked.
+
+`custom-load' autoloads for all symbols are loaded in order to get all the
+link information. This will be a lot of lisp packages loaded, and can take
+quite a while."
+
+ (interactive)
+ (pop-to-buffer info-xref-results-buffer t)
+ (erase-buffer)
+ (let ((info-xref-filename-heading ""))
+
+ ;; `custom-load-symbol' is not used, since it quietly ignores errors,
+ ;; but we want to show them (since they may mean incomplete checking).
+ ;;
+ ;; Just one pass through mapatoms is made. There shouldn't be any new
+ ;; custom-loads setup by packages loaded.
+ ;;
+ (info-xref-output "Loading custom-load autoloads ...\n")
+ (require 'cus-start)
+ (require 'cus-load)
+ (let ((viper-mode nil)) ;; tell viper.el not to ask about viperizing
+ (mapatoms
+ (lambda (symbol)
+ (dolist (load (get symbol 'custom-loads))
+ (cond ((symbolp load)
+ (condition-case cause (require load)
+ (error
+ (info-xref-output "Symbol `%s': cannot require '%s: %s\n"
+ symbol load cause))))
+ ;; skip if previously loaded
+ ((assoc load load-history))
+ ((assoc (locate-library load) load-history))
+ (t
+ (condition-case cause (load load)
+ (error
+ (info-xref-output "Symbol `%s': cannot load \"%s\": %s\n"
+ symbol load cause)))))))))
+
+ ;; Don't bother to check whether the info file exists as opposed to just
+ ;; a missing node. If you have the lisp then you should have the
+ ;; documentation, so missing node name will be the usual fault.
+ ;;
+ (info-xref-output "\nChecking custom-links references ...\n")
+ (let ((good 0)
+ (bad 0))
+ (mapatoms
+ (lambda (symbol)
+ (dolist (link (get symbol 'custom-links))
+ (when (memq (car link) '(custom-manual info-link))
+ (if (info-xref-goto-node-p (cadr link))
+ (setq good (1+ good))
+ (setq bad (1+ bad))
+ ;; symbol-file gives nil for preloaded variables, would need
+ ;; to copy what describe-variable does to show the right place
+ (info-xref-output "Symbol `%s' (in %s): cannot goto node: %s\n"
+ symbol (symbol-file symbol) (cadr link)))))))
+ (info-xref-output "%d good, %d bad\n" good bad))))