Commit 0c10ee28 authored by Richard M. Stallman's avatar Richard M. Stallman
Browse files

(info-lookup->topic-cache): Use defun, not defsubst.

(info-lookup->mode-cache, info-lookup->initialized): Likewise.
(info-lookup->completions, info-lookup->refer-modes): Likewise.
(info-lookup->all-modes): Likewise.

(info-lookup-quick-all-modes): New function.
(info-complete): Find the symbol to complete first,
then compute list of completions.

(lisp-mode): Add info-lookup-maybe-add-help for it.
parent ff753438
......@@ -208,28 +208,31 @@ REFER-MODES is a list of other help modes to use.")
(cons (cons topic nil)
info-lookup-cache)))))
(defsubst info-lookup->topic-cache (topic)
(defun info-lookup->topic-cache (topic)
(cdr (info-lookup->cache topic)))
(defsubst info-lookup->mode-cache (topic mode)
(defun info-lookup->mode-cache (topic mode)
(assoc mode (info-lookup->topic-cache topic)))
(defsubst info-lookup->initialized (topic mode)
(defun info-lookup->initialized (topic mode)
(nth 1 (info-lookup->mode-cache topic mode)))
(defsubst info-lookup->completions (topic mode)
(defun info-lookup->completions (topic mode)
(or (info-lookup->initialized topic mode)
(info-lookup-setup-mode topic mode))
(nth 2 (info-lookup->mode-cache topic mode)))
(defsubst info-lookup->refer-modes (topic mode)
(defun info-lookup->refer-modes (topic mode)
(or (info-lookup->initialized topic mode)
(info-lookup-setup-mode topic mode))
(nth 3 (info-lookup->mode-cache topic mode)))
(defsubst info-lookup->all-modes (topic mode)
(defun info-lookup->all-modes (topic mode)
(cons mode (info-lookup->refer-modes topic mode)))
(defun info-lookup-quick-all-modes (topic mode)
(cons mode (info-lookup->other-modes topic mode)))
;;;###autoload
(defun info-lookup-reset ()
"Throw away all cached data.
......@@ -541,10 +544,9 @@ Return nil if there is nothing appropriate."
(setq mode (or info-lookup-mode major-mode)))
(or (info-lookup->mode-value topic mode)
(error "No %s completion available for `%s'" topic mode))
(let ((modes (info-lookup->all-modes topic mode))
(completions (info-lookup->completions topic mode))
(completion-ignore-case (info-lookup->ignore-case topic mode))
(start (point)) try completion)
(let ((modes (info-lookup-quick-all-modes topic mode))
(start (point))
try)
(while (and (not try) modes)
(setq mode (car modes)
modes (cdr modes)
......@@ -552,20 +554,24 @@ Return nil if there is nothing appropriate."
(goto-char start))
(and (not try)
(error "Found no %S to complete" topic))
(setq completion (try-completion try completions))
(cond ((not completion)
(ding)
(message "No match"))
((stringp completion)
(or (assoc completion completions)
(setq completion (completing-read
(format "Complete %S: " topic)
completions nil t completion
info-lookup-history)))
(delete-region (- start (length try)) start)
(insert completion))
(t
(message "%s is complete" (capitalize (prin1-to-string topic)))))))
(let ((completions (info-lookup->completions topic mode))
(completion-ignore-case (info-lookup->ignore-case topic mode))
completion)
(setq completion (try-completion try completions))
(cond ((not completion)
(ding)
(message "No match"))
((stringp completion)
(or (assoc completion completions)
(setq completion (completing-read
(format "Complete %S: " topic)
completions nil t completion
info-lookup-history)))
(delete-region (- start (length try)) start)
(insert completion))
(t
(message "%s is complete"
(capitalize (prin1-to-string topic))))))))
;;; Info-lookup minor mode.
......@@ -760,6 +766,12 @@ Special commands:
:parse-rule 'ignore
:other-modes '(emacs-lisp-mode))
(info-lookup-maybe-add-help
:mode 'lisp-mode
:regexp "[^()' \t\n]+"
:parse-rule 'ignore
:other-modes '(emacs-lisp-mode))
(provide 'info-look)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment