comparison lisp/info-look.el @ 58017:57d5e5e2e4db

(info-lookup): Allow reusing in the current buffer not only *info* buffer, but all (even renamed) Info buffers by checking for major-mode instead of *info* buffer name. (c-mode, autoconf-mode, emacs-lisp-mode, scheme-mode) (octave-mode, maxima-mode) <doc-spec>: Allow long dashes generated by Texinfo 4.7 before definitions. (texinfo-mode) <doc-spec>: Add space to suffix to find command definitions with argument separated by space.
author Juri Linkov <juri@jurta.org>
date Sun, 07 Nov 2004 20:52:51 +0000
parents 2967bbb0802b
children bcb4709c5b09 cb7f41387eb3
comparison
equal deleted inserted replaced
58016:f0ebbe5872be 58017:57d5e5e2e4db
326 (assoc-string item completions t) 326 (assoc-string item completions t)
327 (error "Not documented as a %s: %s" topic (or item "")))) 327 (error "Not documented as a %s: %s" topic (or item ""))))
328 (modes (info-lookup->all-modes topic mode)) 328 (modes (info-lookup->all-modes topic mode))
329 (window (selected-window)) 329 (window (selected-window))
330 found doc-spec node prefix suffix doc-found) 330 found doc-spec node prefix suffix doc-found)
331 (if (or (not info-lookup-other-window-flag) 331 (if (not (eq major-mode 'Info-mode))
332 (eq (current-buffer) (get-buffer "*info*"))) 332 (if (not info-lookup-other-window-flag)
333 (info) 333 (info)
334 (progn 334 (progn
335 (save-window-excursion (info)) 335 (save-window-excursion (info))
336 ;; Determine whether or not the Info buffer is visible in 336 ;; Determine whether or not the Info buffer is visible in
337 ;; another frame on the same display. If it is, simply raise 337 ;; another frame on the same display. If it is, simply raise
338 ;; that frame. Otherwise, display it in another window. 338 ;; that frame. Otherwise, display it in another window.
339 (let* ((window (get-buffer-window "*info*" t)) 339 (let* ((window (get-buffer-window "*info*" t))
340 (info-frame (and window (window-frame window)))) 340 (info-frame (and window (window-frame window))))
341 (if (and info-frame 341 (if (and info-frame
342 (display-multi-frame-p) 342 (display-multi-frame-p)
343 (memq info-frame (frames-on-display-list)) 343 (memq info-frame (frames-on-display-list))
344 (not (eq info-frame (selected-frame)))) 344 (not (eq info-frame (selected-frame))))
345 (select-frame info-frame) 345 (select-frame info-frame)
346 (switch-to-buffer-other-window "*info*"))))) 346 (switch-to-buffer-other-window "*info*"))))))
347 (while (and (not found) modes) 347 (while (and (not found) modes)
348 (setq doc-spec (info-lookup->doc-spec topic (car modes))) 348 (setq doc-spec (info-lookup->doc-spec topic (car modes)))
349 (while (and (not found) doc-spec) 349 (while (and (not found) doc-spec)
350 (setq node (nth 0 (car doc-spec)) 350 (setq node (nth 0 (car doc-spec))
351 prefix (nth 2 (car doc-spec)) 351 prefix (nth 2 (car doc-spec))
631 631
632 (info-lookup-maybe-add-help 632 (info-lookup-maybe-add-help
633 :mode 'c-mode :topic 'symbol 633 :mode 'c-mode :topic 'symbol
634 :regexp "\\(struct \\|union \\|enum \\)?[_a-zA-Z][_a-zA-Z0-9]*" 634 :regexp "\\(struct \\|union \\|enum \\)?[_a-zA-Z][_a-zA-Z0-9]*"
635 :doc-spec '(("(libc)Function Index" nil 635 :doc-spec '(("(libc)Function Index" nil
636 "^[ \t]+- \\(Function\\|Macro\\): .*\\<" "\\>") 636 "^[ \t]+-+ \\(Function\\|Macro\\): .*\\<" "\\>")
637 ("(libc)Variable Index" nil 637 ("(libc)Variable Index" nil
638 "^[ \t]+- \\(Variable\\|Macro\\): .*\\<" "\\>") 638 "^[ \t]+-+ \\(Variable\\|Macro\\): .*\\<" "\\>")
639 ("(libc)Type Index" nil 639 ("(libc)Type Index" nil
640 "^[ \t]+- Data Type: \\<" "\\>") 640 "^[ \t]+-+ Data Type: \\<" "\\>")
641 ("(termcap)Var Index" nil 641 ("(termcap)Var Index" nil
642 "^[ \t]*`" "'")) 642 "^[ \t]*`" "'"))
643 :parse-rule 'info-lookup-guess-c-symbol) 643 :parse-rule 'info-lookup-guess-c-symbol)
644 644
645 (info-lookup-maybe-add-help 645 (info-lookup-maybe-add-help
671 :doc-spec '(("(texinfo)Command and Variable Index" 671 :doc-spec '(("(texinfo)Command and Variable Index"
672 ;; Ignore Emacs commands and prepend a `@'. 672 ;; Ignore Emacs commands and prepend a `@'.
673 (lambda (item) 673 (lambda (item)
674 (if (string-match "^\\([a-zA-Z]+\\|[^a-zA-Z]\\)\\( .*\\)?$" item) 674 (if (string-match "^\\([a-zA-Z]+\\|[^a-zA-Z]\\)\\( .*\\)?$" item)
675 (concat "@" (match-string 1 item)))) 675 (concat "@" (match-string 1 item))))
676 "`" "'"))) 676 "`" "[' ]")))
677 677
678 (info-lookup-maybe-add-help 678 (info-lookup-maybe-add-help
679 :mode 'm4-mode 679 :mode 'm4-mode
680 :regexp "[_a-zA-Z][_a-zA-Z0-9]*" 680 :regexp "[_a-zA-Z][_a-zA-Z0-9]*"
681 :doc-spec '(("(m4)Macro index")) 681 :doc-spec '(("(m4)Macro index"))
688 ;; but with "AH_" or "AU_" for those. So add "AC_" if there 688 ;; but with "AH_" or "AU_" for those. So add "AC_" if there
689 ;; isn't already an "A._". 689 ;; isn't already an "A._".
690 ("(autoconf)Autoconf Macro Index" 690 ("(autoconf)Autoconf Macro Index"
691 (lambda (item) 691 (lambda (item)
692 (if (string-match "^A._" item) item (concat "AC_" item))) 692 (if (string-match "^A._" item) item (concat "AC_" item)))
693 "^[ \t]+- \\(Macro\\|Variable\\): .*\\<" "\\>") 693 "^[ \t]+-+ \\(Macro\\|Variable\\): .*\\<" "\\>")
694 ;; M4 Macro Index entries are without "AS_" prefixes, and 694 ;; M4 Macro Index entries are without "AS_" prefixes, and
695 ;; mostly without "m4_" prefixes. "dnl" is an exception, not 695 ;; mostly without "m4_" prefixes. "dnl" is an exception, not
696 ;; wanting any prefix. So AS_ is added back to upper-case 696 ;; wanting any prefix. So AS_ is added back to upper-case
697 ;; names, m4_ to others which don't already an m4_. 697 ;; names, m4_ to others which don't already an m4_.
698 ("(autoconf)M4 Macro Index" 698 ("(autoconf)M4 Macro Index"
703 item) 703 item)
704 ((string-match "^[A-Z0-9_]+$" item) 704 ((string-match "^[A-Z0-9_]+$" item)
705 (concat "AS_" item)) 705 (concat "AS_" item))
706 (t 706 (t
707 (concat "m4_" item))))) 707 (concat "m4_" item)))))
708 "^[ \t]+- Macro: .*\\<" "\\>") 708 "^[ \t]+-+ Macro: .*\\<" "\\>")
709 ;; Autotest Macro Index entries are without "AT_". 709 ;; Autotest Macro Index entries are without "AT_".
710 ("(autoconf)Autotest Macro Index" "AT_" 710 ("(autoconf)Autotest Macro Index" "AT_"
711 "^[ \t]+- Macro: .*\\<" "\\>") 711 "^[ \t]+-+ Macro: .*\\<" "\\>")
712 ;; This is for older versions (probably pre autoconf 2.5x): 712 ;; This is for older versions (probably pre autoconf 2.5x):
713 ("(autoconf)Macro Index" "AC_" 713 ("(autoconf)Macro Index" "AC_"
714 "^[ \t]+- \\(Macro\\|Variable\\): .*\\<" "\\>") 714 "^[ \t]+-+ \\(Macro\\|Variable\\): .*\\<" "\\>")
715 ;; Automake has index entries for its notes on various autoconf 715 ;; Automake has index entries for its notes on various autoconf
716 ;; macros (eg. AC_PROG_CC). Ensure this is after the autoconf 716 ;; macros (eg. AC_PROG_CC). Ensure this is after the autoconf
717 ;; index, so as to prefer the autoconf docs. 717 ;; index, so as to prefer the autoconf docs.
718 ("(automake)Macro and Variable Index" nil 718 ("(automake)Macro and Variable Index" nil
719 "^[ \t]*`" "'")) 719 "^[ \t]*`" "'"))
786 ;; those without as `M-x foo'. 786 ;; those without as `M-x foo'.
787 ("(emacs)Command Index" nil "`\\(M-x[ \t\n]+\\)?" "'") 787 ("(emacs)Command Index" nil "`\\(M-x[ \t\n]+\\)?" "'")
788 ;; Variables normally appear in nodes as just `foo'. 788 ;; Variables normally appear in nodes as just `foo'.
789 ("(emacs)Variable Index" nil "`" "'") 789 ("(emacs)Variable Index" nil "`" "'")
790 ;; Almost all functions, variables, etc appear in nodes as 790 ;; Almost all functions, variables, etc appear in nodes as
791 ;; " - Function: foo" etc. A small number of aliases and 791 ;; " -- Function: foo" etc. A small number of aliases and
792 ;; symbols appear only as `foo', and will miss out on exact 792 ;; symbols appear only as `foo', and will miss out on exact
793 ;; positions. Allowing `foo' would hit too many false matches 793 ;; positions. Allowing `foo' would hit too many false matches
794 ;; for things that should go to Function: etc, and those latter 794 ;; for things that should go to Function: etc, and those latter
795 ;; are much more important. Perhaps this could change if some 795 ;; are much more important. Perhaps this could change if some
796 ;; sort of fallback match scheme existed. 796 ;; sort of fallback match scheme existed.
797 ("(elisp)Index" nil "^ - .*: " "\\( \\|$\\)"))) 797 ("(elisp)Index" nil "^ -+ .*: " "\\( \\|$\\)")))
798 798
799 (info-lookup-maybe-add-help 799 (info-lookup-maybe-add-help
800 :mode 'lisp-interaction-mode 800 :mode 'lisp-interaction-mode
801 :regexp "[^][()'\" \t\n]+" 801 :regexp "[^][()'\" \t\n]+"
802 :parse-rule 'ignore 802 :parse-rule 'ignore
812 :mode 'scheme-mode 812 :mode 'scheme-mode
813 :regexp "[^()`',\" \t\n]+" 813 :regexp "[^()`',\" \t\n]+"
814 :ignore-case t 814 :ignore-case t
815 ;; Aubrey Jaffer's rendition from <URL:ftp://ftp-swiss.ai.mit.edu/pub/scm> 815 ;; Aubrey Jaffer's rendition from <URL:ftp://ftp-swiss.ai.mit.edu/pub/scm>
816 :doc-spec '(("(r5rs)Index" nil 816 :doc-spec '(("(r5rs)Index" nil
817 "^[ \t]+- [^:]+:[ \t]*" "\\b"))) 817 "^[ \t]+-+ [^:]+:[ \t]*" "\\b")))
818 818
819 (info-lookup-maybe-add-help 819 (info-lookup-maybe-add-help
820 :mode 'octave-mode 820 :mode 'octave-mode
821 :regexp "[_a-zA-Z0-9]+" 821 :regexp "[_a-zA-Z0-9]+"
822 :doc-spec '(("(octave)Function Index" nil 822 :doc-spec '(("(octave)Function Index" nil
823 "^ - [^:]+:[ ]+\\(\\[[^=]*=[ ]+\\)?" nil) 823 "^ -+ [^:]+:[ ]+\\(\\[[^=]*=[ ]+\\)?" nil)
824 ("(octave)Variable Index" nil "^ - [^:]+:[ ]+" nil) 824 ("(octave)Variable Index" nil "^ -+ [^:]+:[ ]+" nil)
825 ;; Catch lines of the form "xyz statement" 825 ;; Catch lines of the form "xyz statement"
826 ("(octave)Concept Index" 826 ("(octave)Concept Index"
827 (lambda (item) 827 (lambda (item)
828 (cond 828 (cond
829 ((string-match "^\\([A-Z]+\\) statement\\b" item) 829 ((string-match "^\\([A-Z]+\\) statement\\b" item)
830 (match-string 1 item)) 830 (match-string 1 item))
831 (t nil))) 831 (t nil)))
832 nil; "^ - [^:]+:[ ]+" don't think this prefix is useful here. 832 nil; "^ -+ [^:]+:[ ]+" don't think this prefix is useful here.
833 nil))) 833 nil)))
834 834
835 (info-lookup-maybe-add-help 835 (info-lookup-maybe-add-help
836 :mode 'maxima-mode 836 :mode 'maxima-mode
837 :ignore-case t 837 :ignore-case t
838 :regexp "[a-zA-Z_%]+" 838 :regexp "[a-zA-Z_%]+"
839 :doc-spec '( ("(maxima)Function and Variable Index" nil 839 :doc-spec '( ("(maxima)Function and Variable Index" nil
840 "^ - [^:]+:[ ]+\\(\\[[^=]*=[ ]+\\)?" nil))) 840 "^ -+ [^:]+:[ ]+\\(\\[[^=]*=[ ]+\\)?" nil)))
841 841
842 (info-lookup-maybe-add-help 842 (info-lookup-maybe-add-help
843 :mode 'inferior-maxima-mode 843 :mode 'inferior-maxima-mode
844 :other-modes '(maxima-mode)) 844 :other-modes '(maxima-mode))
845 845