Mercurial > emacs
comparison lisp/info-look.el @ 22281:fa2cf768a61a
Added support for Scheme.
Removed Info-lookup minor mode.
(info-lookup-file-name-alist): New variable.
(info-lookup-select-mode): New function. Select help mode
according to info-lookup-file-name-alist or fall back to the
buffer's major mode.
(info-lookup): Use info-lookup-select-mode.
(info-lookup-interactive-arguments): Likewise.
(info-complete-symbol): Likewise.
(info-complete-file): Likewise.
(info-complete): Likewise.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Sat, 30 May 1998 13:25:57 +0000 |
parents | 8b08793f2633 |
children | 4db659df7407 |
comparison
equal
deleted
inserted
replaced
22280:e179bf1418b7 | 22281:fa2cf768a61a |
---|---|
54 Setting this variable to nil disables highlighting." | 54 Setting this variable to nil disables highlighting." |
55 :group 'info-lookup :type 'face) | 55 :group 'info-lookup :type 'face) |
56 | 56 |
57 (defvar info-lookup-highlight-overlay nil | 57 (defvar info-lookup-highlight-overlay nil |
58 "Overlay object used for highlighting.") | 58 "Overlay object used for highlighting.") |
59 | |
60 (defcustom info-lookup-file-name-alist | |
61 '(("\\`configure\\.in\\'" . autoconf-mode) | |
62 ("\\`aclocal\\.m4\\'" . autoconf-mode) | |
63 ("\\`acsite\\.m4\\'" . autoconf-mode) | |
64 ("\\`acinclude\\.m4\\'" . autoconf-mode)) | |
65 "Alist of file names handled specially. | |
66 List elements are cons cells of the form | |
67 | |
68 (REGEXP . MODE) | |
69 | |
70 If a file name matches REGEXP, then use help mode MODE instead of the | |
71 buffer's major mode." | |
72 :group 'info-lookup :type '(repeat (cons (string :tag "Regexp") | |
73 (symbol :tag "Mode")))) | |
59 | 74 |
60 (defvar info-lookup-history nil | 75 (defvar info-lookup-history nil |
61 "History of previous input lines.") | 76 "History of previous input lines.") |
62 | 77 |
63 (defvar info-lookup-alist nil | 78 (defvar info-lookup-alist nil |
264 (info-lookup-interactive-arguments 'file)) | 279 (info-lookup-interactive-arguments 'file)) |
265 (info-lookup 'file file mode)) | 280 (info-lookup 'file file mode)) |
266 | 281 |
267 (defun info-lookup-interactive-arguments (topic) | 282 (defun info-lookup-interactive-arguments (topic) |
268 "Return default value and help mode for help topic TOPIC." | 283 "Return default value and help mode for help topic TOPIC." |
269 (let* ((mode (if (info-lookup->mode-value | 284 (let* ((mode (if (info-lookup->mode-value topic (info-lookup-select-mode)) |
270 topic (or info-lookup-mode major-mode)) | 285 info-lookup-mode |
271 (or info-lookup-mode major-mode) | |
272 (info-lookup-change-mode topic))) | 286 (info-lookup-change-mode topic))) |
273 (completions (info-lookup->completions topic mode)) | 287 (completions (info-lookup->completions topic mode)) |
274 (default (info-lookup-guess-default topic mode)) | 288 (default (info-lookup-guess-default topic mode)) |
275 (input (if (or current-prefix-arg (not (assoc default completions))) | 289 (input (if (or current-prefix-arg (not (assoc default completions))) |
276 default)) | 290 default)) |
281 (format "Describe %s (default %s): " topic default) | 295 (format "Describe %s (default %s): " topic default) |
282 (format "Describe %s: " topic)) | 296 (format "Describe %s: " topic)) |
283 completions nil nil input 'info-lookup-history))) | 297 completions nil nil input 'info-lookup-history))) |
284 (list (if (equal value "") default value) mode))) | 298 (list (if (equal value "") default value) mode))) |
285 | 299 |
300 (defun info-lookup-select-mode () | |
301 (when (and (not info-lookup-mode) (buffer-file-name)) | |
302 (let ((file-name (file-name-nondirectory (buffer-file-name))) | |
303 (file-name-alist info-lookup-file-name-alist)) | |
304 (while (and (not info-lookup-mode) file-name-alist) | |
305 (when (string-match (caar file-name-alist) file-name) | |
306 (setq info-lookup-mode (cdar file-name-alist))) | |
307 (setq file-name-alist (cdr file-name-alist))))) | |
308 (or info-lookup-mode (setq info-lookup-mode major-mode))) | |
309 | |
286 (defun info-lookup-change-mode (topic) | 310 (defun info-lookup-change-mode (topic) |
287 (let* ((completions (mapcar (lambda (arg) | 311 (let* ((completions (mapcar (lambda (arg) |
288 (cons (symbol-name (car arg)) (car arg))) | 312 (cons (symbol-name (car arg)) (car arg))) |
289 (info-lookup->topic-value topic))) | 313 (info-lookup->topic-value topic))) |
290 (mode (completing-read | 314 (mode (completing-read |
296 (error "No %s help available for `%s'" topic mode)) | 320 (error "No %s help available for `%s'" topic mode)) |
297 (setq info-lookup-mode mode))) | 321 (setq info-lookup-mode mode))) |
298 | 322 |
299 (defun info-lookup (topic item mode) | 323 (defun info-lookup (topic item mode) |
300 "Display the documentation of a help item." | 324 "Display the documentation of a help item." |
301 (if (not mode) | 325 (or mode (setq mode (info-lookup-select-mode))) |
302 (setq mode (or info-lookup-mode major-mode))) | |
303 (or (info-lookup->mode-value topic mode) | 326 (or (info-lookup->mode-value topic mode) |
304 (error "No %s help available for `%s'" topic mode)) | 327 (error "No %s help available for `%s'" topic mode)) |
305 (let ((entry (or (assoc (if (info-lookup->ignore-case topic mode) | 328 (let ((entry (or (assoc (if (info-lookup->ignore-case topic mode) |
306 (downcase item) item) | 329 (downcase item) item) |
307 (info-lookup->completions topic mode)) | 330 (info-lookup->completions topic mode)) |
520 "Perform completion on symbol preceding point." | 543 "Perform completion on symbol preceding point." |
521 (interactive) | 544 (interactive) |
522 (info-complete 'symbol | 545 (info-complete 'symbol |
523 (or mode | 546 (or mode |
524 (if (info-lookup->mode-value | 547 (if (info-lookup->mode-value |
525 'symbol (or info-lookup-mode major-mode)) | 548 'symbol (info-lookup-select-mode)) |
526 (or info-lookup-mode major-mode) | 549 info-lookup-mode |
527 (info-lookup-change-mode 'symbol))))) | 550 (info-lookup-change-mode 'symbol))))) |
528 | 551 |
529 ;;;###autoload | 552 ;;;###autoload |
530 (defun info-complete-file (&optional mode) | 553 (defun info-complete-file (&optional mode) |
531 "Perform completion on file preceding point." | 554 "Perform completion on file preceding point." |
532 (interactive) | 555 (interactive) |
533 (info-complete 'file | 556 (info-complete 'file |
534 (or mode | 557 (or mode |
535 (if (info-lookup->mode-value | 558 (if (info-lookup->mode-value |
536 'file (or info-lookup-mode major-mode)) | 559 'file (info-lookup-select-mode)) |
537 (or info-lookup-mode major-mode) | 560 info-lookup-mode |
538 (info-lookup-change-mode 'file))))) | 561 (info-lookup-change-mode 'file))))) |
539 | 562 |
540 (defun info-complete (topic mode) | 563 (defun info-complete (topic mode) |
541 "Try to complete a help item." | 564 "Try to complete a help item." |
542 (barf-if-buffer-read-only) | 565 (barf-if-buffer-read-only) |
543 (if (not mode) | 566 (or mode (setq mode (info-lookup-select-mode))) |
544 (setq mode (or info-lookup-mode major-mode))) | |
545 (or (info-lookup->mode-value topic mode) | 567 (or (info-lookup->mode-value topic mode) |
546 (error "No %s completion available for `%s'" topic mode)) | 568 (error "No %s completion available for `%s'" topic mode)) |
547 (let ((modes (info-lookup-quick-all-modes topic mode)) | 569 (let ((modes (info-lookup-quick-all-modes topic mode)) |
548 (start (point)) | 570 (start (point)) |
549 try) | 571 try) |
572 (t | 594 (t |
573 (message "%s is complete" | 595 (message "%s is complete" |
574 (capitalize (prin1-to-string topic)))))))) | 596 (capitalize (prin1-to-string topic)))))))) |
575 | 597 |
576 | 598 |
577 ;;; Info-lookup minor mode. | |
578 | |
579 (defvar info-lookup-minor-mode nil | |
580 "Non-`nil' enables Info-lookup mode.") | |
581 (make-variable-buffer-local 'info-lookup-minor-mode) | |
582 | |
583 (defvar info-lookup-minor-mode-string " Info" | |
584 "Indicator included in the mode line when in Info-lookup mode.") | |
585 | |
586 (or (assq 'info-lookup-minor-mode minor-mode-alist) | |
587 (setq minor-mode-alist (cons '(info-lookup-minor-mode | |
588 info-lookup-minor-mode-string) | |
589 minor-mode-alist))) | |
590 | |
591 (defvar info-lookup-minor-mode-map (make-sparse-keymap) | |
592 "Minor mode map for Info-lookup mode.") | |
593 | |
594 (or (assq 'info-lookup-minor-mode minor-mode-map-alist) | |
595 (setq minor-mode-map-alist (cons (cons 'info-lookup-minor-mode | |
596 info-lookup-minor-mode-map) | |
597 minor-mode-map-alist))) | |
598 | |
599 ;;;### autoload | |
600 (defun info-lookup-minor-mode (&optional arg) | |
601 "Minor mode for looking up the documentation of a symbol or file. | |
602 Special commands: | |
603 | |
604 \\{info-lookup-minor-mode-map}" | |
605 (interactive "P") | |
606 (setq info-lookup-minor-mode (if (null arg) | |
607 (not info-lookup-minor-mode) | |
608 (> (prefix-numeric-value arg) 0))) | |
609 (set-buffer-modified-p (buffer-modified-p))) | |
610 | |
611 (define-key info-lookup-minor-mode-map | |
612 "\C-c\C-hf" 'info-lookup-symbol) ; Describe function. | |
613 (define-key info-lookup-minor-mode-map | |
614 "\C-c\C-hv" 'info-lookup-symbol) ; Describe variable. | |
615 (define-key info-lookup-minor-mode-map | |
616 "\C-c\C-ht" 'info-lookup-symbol) ; Describe type. | |
617 (define-key info-lookup-minor-mode-map | |
618 "\C-c\C-hp" 'info-lookup-file) ; Describe program. | |
619 (define-key info-lookup-minor-mode-map | |
620 "\C-c\C-if" 'info-complete-symbol) ; Complete function. | |
621 (define-key info-lookup-minor-mode-map | |
622 "\C-c\C-iv" 'info-complete-symbol) ; Complete variable. | |
623 (define-key info-lookup-minor-mode-map | |
624 "\C-c\C-it" 'info-complete-symbol) ; Complete type. | |
625 (define-key info-lookup-minor-mode-map | |
626 "\C-c\C-ip" 'info-complete-file) ; Complete program. | |
627 | |
628 ;;;### autoload | |
629 (defun turn-on-info-lookup () | |
630 "Unconditionally turn on Info-lookup mode." | |
631 (info-lookup-minor-mode 1)) | |
632 | |
633 | |
634 ;;; Initialize some common modes. | 599 ;;; Initialize some common modes. |
635 | 600 |
636 (info-lookup-maybe-add-help | 601 (info-lookup-maybe-add-help |
637 :mode 'c-mode :topic 'symbol | 602 :mode 'c-mode :topic 'symbol |
638 :regexp "\\(struct \\|union \\|enum \\)?[_a-zA-Z][_a-zA-Z0-9]*" | 603 :regexp "\\(struct \\|union \\|enum \\)?[_a-zA-Z][_a-zA-Z0-9]*" |
778 :mode 'lisp-mode | 743 :mode 'lisp-mode |
779 :regexp "[^()' \t\n]+" | 744 :regexp "[^()' \t\n]+" |
780 :parse-rule 'ignore | 745 :parse-rule 'ignore |
781 :other-modes '(emacs-lisp-mode)) | 746 :other-modes '(emacs-lisp-mode)) |
782 | 747 |
748 (info-lookup-maybe-add-help | |
749 :mode 'scheme-mode | |
750 :regexp "[^()' \t\n]+" | |
751 :ignore-case t | |
752 :doc-spec '(("(r5rs)Index" nil | |
753 "^[ \t]+- [^:]+:[ \t]*" "\\b"))) | |
754 | |
783 | 755 |
784 (provide 'info-look) | 756 (provide 'info-look) |
785 | 757 |
786 ;;; info-look.el ends here | 758 ;;; info-look.el ends here |