[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#18044: 24.3; `info-display-manual' should use completing input for m
From: |
Drew Adams |
Subject: |
bug#18044: 24.3; `info-display-manual' should use completing input for manual name |
Date: |
Thu, 17 Jul 2014 20:47:45 -0700 (PDT) |
> I think it would be possible to extract the necessary machinery from the
> function `Info-read-node-name' and its -1/-2 friends, but I don't grok
> completion well enough to do it myself, and one of the core
> (not-info-specific) completion functions involved isn't even documented.
Righto. info+.el has done that for a long time, with this defun:
;; REPLACE ORIGINAL in `info.el':
;;
;; Use completion for inputting the manual name.
;;
(defun info-display-manual (manual)
"Go to Info buffer that displays MANUAL, creating if it does not exist."
;; (interactive "sManual name: ")
(interactive
(let ((manuals ()))
(condition-case nil
(with-temp-buffer
(Info-mode)
(Info-directory)
(goto-char (point-min))
(re-search-forward "\\* Menu: *\n" nil t)
(let (manual)
(while (re-search-forward "\\*.*: *(\\([^)]+\\))" nil t)
(setq manual (match-string 1))
(set-text-properties 0 (length manual) nil manual)
(add-to-list 'manuals (list manual)))))
(error nil))
(list (completing-read "Display manual: " manuals))))
(let ((blist (buffer-list))
(manual-re (concat "\\(/\\|\\`\\)" manual "\\(\\.\\|\\'\\)"))
(case-fold-search t)
found)
(dolist (buffer blist)
(with-current-buffer buffer
(when (and (eq major-mode 'Info-mode)
(stringp Info-current-file)
(string-match manual-re Info-current-file))
(setq found buffer
blist ()))))
(if found
(switch-to-buffer found)
(info-initialize)
(info (Info-find-file manual)))))
http://www.emacswiki.org/InfoPlus
http://www.emacswiki.org/emacs-en/download/info%2b.el