Mercurial > emacs
comparison lisp/info-look.el @ 21334:66b3b9fe3e3c
(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.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 02 Apr 1998 04:36:00 +0000 |
parents | b7e7f7c9685a |
children | 8b08793f2633 |
comparison
equal
deleted
inserted
replaced
21333:a6119c0748e9 | 21334:66b3b9fe3e3c |
---|---|
206 (or (assoc topic info-lookup-cache) | 206 (or (assoc topic info-lookup-cache) |
207 (car (setq info-lookup-cache | 207 (car (setq info-lookup-cache |
208 (cons (cons topic nil) | 208 (cons (cons topic nil) |
209 info-lookup-cache))))) | 209 info-lookup-cache))))) |
210 | 210 |
211 (defsubst info-lookup->topic-cache (topic) | 211 (defun info-lookup->topic-cache (topic) |
212 (cdr (info-lookup->cache topic))) | 212 (cdr (info-lookup->cache topic))) |
213 | 213 |
214 (defsubst info-lookup->mode-cache (topic mode) | 214 (defun info-lookup->mode-cache (topic mode) |
215 (assoc mode (info-lookup->topic-cache topic))) | 215 (assoc mode (info-lookup->topic-cache topic))) |
216 | 216 |
217 (defsubst info-lookup->initialized (topic mode) | 217 (defun info-lookup->initialized (topic mode) |
218 (nth 1 (info-lookup->mode-cache topic mode))) | 218 (nth 1 (info-lookup->mode-cache topic mode))) |
219 | 219 |
220 (defsubst info-lookup->completions (topic mode) | 220 (defun info-lookup->completions (topic mode) |
221 (or (info-lookup->initialized topic mode) | 221 (or (info-lookup->initialized topic mode) |
222 (info-lookup-setup-mode topic mode)) | 222 (info-lookup-setup-mode topic mode)) |
223 (nth 2 (info-lookup->mode-cache topic mode))) | 223 (nth 2 (info-lookup->mode-cache topic mode))) |
224 | 224 |
225 (defsubst info-lookup->refer-modes (topic mode) | 225 (defun info-lookup->refer-modes (topic mode) |
226 (or (info-lookup->initialized topic mode) | 226 (or (info-lookup->initialized topic mode) |
227 (info-lookup-setup-mode topic mode)) | 227 (info-lookup-setup-mode topic mode)) |
228 (nth 3 (info-lookup->mode-cache topic mode))) | 228 (nth 3 (info-lookup->mode-cache topic mode))) |
229 | 229 |
230 (defsubst info-lookup->all-modes (topic mode) | 230 (defun info-lookup->all-modes (topic mode) |
231 (cons mode (info-lookup->refer-modes topic mode))) | 231 (cons mode (info-lookup->refer-modes topic mode))) |
232 | |
233 (defun info-lookup-quick-all-modes (topic mode) | |
234 (cons mode (info-lookup->other-modes topic mode))) | |
232 | 235 |
233 ;;;###autoload | 236 ;;;###autoload |
234 (defun info-lookup-reset () | 237 (defun info-lookup-reset () |
235 "Throw away all cached data. | 238 "Throw away all cached data. |
236 This command is useful if the user wants to start at the beginning without | 239 This command is useful if the user wants to start at the beginning without |
539 (barf-if-buffer-read-only) | 542 (barf-if-buffer-read-only) |
540 (if (not mode) | 543 (if (not mode) |
541 (setq mode (or info-lookup-mode major-mode))) | 544 (setq mode (or info-lookup-mode major-mode))) |
542 (or (info-lookup->mode-value topic mode) | 545 (or (info-lookup->mode-value topic mode) |
543 (error "No %s completion available for `%s'" topic mode)) | 546 (error "No %s completion available for `%s'" topic mode)) |
544 (let ((modes (info-lookup->all-modes topic mode)) | 547 (let ((modes (info-lookup-quick-all-modes topic mode)) |
545 (completions (info-lookup->completions topic mode)) | 548 (start (point)) |
546 (completion-ignore-case (info-lookup->ignore-case topic mode)) | 549 try) |
547 (start (point)) try completion) | |
548 (while (and (not try) modes) | 550 (while (and (not try) modes) |
549 (setq mode (car modes) | 551 (setq mode (car modes) |
550 modes (cdr modes) | 552 modes (cdr modes) |
551 try (info-lookup-guess-default* topic mode)) | 553 try (info-lookup-guess-default* topic mode)) |
552 (goto-char start)) | 554 (goto-char start)) |
553 (and (not try) | 555 (and (not try) |
554 (error "Found no %S to complete" topic)) | 556 (error "Found no %S to complete" topic)) |
555 (setq completion (try-completion try completions)) | 557 (let ((completions (info-lookup->completions topic mode)) |
556 (cond ((not completion) | 558 (completion-ignore-case (info-lookup->ignore-case topic mode)) |
557 (ding) | 559 completion) |
558 (message "No match")) | 560 (setq completion (try-completion try completions)) |
559 ((stringp completion) | 561 (cond ((not completion) |
560 (or (assoc completion completions) | 562 (ding) |
561 (setq completion (completing-read | 563 (message "No match")) |
562 (format "Complete %S: " topic) | 564 ((stringp completion) |
563 completions nil t completion | 565 (or (assoc completion completions) |
564 info-lookup-history))) | 566 (setq completion (completing-read |
565 (delete-region (- start (length try)) start) | 567 (format "Complete %S: " topic) |
566 (insert completion)) | 568 completions nil t completion |
567 (t | 569 info-lookup-history))) |
568 (message "%s is complete" (capitalize (prin1-to-string topic))))))) | 570 (delete-region (- start (length try)) start) |
571 (insert completion)) | |
572 (t | |
573 (message "%s is complete" | |
574 (capitalize (prin1-to-string topic)))))))) | |
569 | 575 |
570 | 576 |
571 ;;; Info-lookup minor mode. | 577 ;;; Info-lookup minor mode. |
572 | 578 |
573 (defvar info-lookup-minor-mode nil | 579 (defvar info-lookup-minor-mode nil |
758 :mode 'lisp-interaction-mode | 764 :mode 'lisp-interaction-mode |
759 :regexp "[^()' \t\n]+" | 765 :regexp "[^()' \t\n]+" |
760 :parse-rule 'ignore | 766 :parse-rule 'ignore |
761 :other-modes '(emacs-lisp-mode)) | 767 :other-modes '(emacs-lisp-mode)) |
762 | 768 |
769 (info-lookup-maybe-add-help | |
770 :mode 'lisp-mode | |
771 :regexp "[^()' \t\n]+" | |
772 :parse-rule 'ignore | |
773 :other-modes '(emacs-lisp-mode)) | |
774 | |
763 | 775 |
764 (provide 'info-look) | 776 (provide 'info-look) |
765 | 777 |
766 ;;; info-look.el ends here | 778 ;;; info-look.el ends here |