diff options
| author | Karl Heuer | 1998-05-30 13:25:57 +0000 |
|---|---|---|
| committer | Karl Heuer | 1998-05-30 13:25:57 +0000 |
| commit | 9d37318d1cbf3432842447cf3da5e05cf6560607 (patch) | |
| tree | 880dfc54189cf6586dcb9026ec1548e0fd4332e8 /lisp | |
| parent | 17cea80917206c92bd0029bd620bd718926eae9c (diff) | |
| download | emacs-9d37318d1cbf3432842447cf3da5e05cf6560607.tar.gz emacs-9d37318d1cbf3432842447cf3da5e05cf6560607.zip | |
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.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/info-look.el | 108 |
1 files changed, 40 insertions, 68 deletions
diff --git a/lisp/info-look.el b/lisp/info-look.el index 60410041b17..10892600623 100644 --- a/lisp/info-look.el +++ b/lisp/info-look.el | |||
| @@ -57,6 +57,21 @@ Setting this variable to nil disables highlighting." | |||
| 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 | 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")))) | ||
| 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 | ||
| @@ -266,9 +281,8 @@ The default file name is the one found at point." | |||
| 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)) |
| @@ -283,6 +297,16 @@ The default file name is the one found at point." | |||
| 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))) |
| @@ -298,8 +322,7 @@ The default file name is the one found at point." | |||
| 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) |
| @@ -522,8 +545,8 @@ Return nil if there is nothing appropriate." | |||
| 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 |
| @@ -533,15 +556,14 @@ Return nil if there is nothing appropriate." | |||
| 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)) |
| @@ -574,63 +596,6 @@ Return nil if there is nothing appropriate." | |||
| 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 |
| @@ -780,6 +745,13 @@ Special commands: | |||
| 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 | ||