(cfengine-mode): Accept a terminal ().
[bpt/emacs.git] / lisp / info-look.el
index b4a8d3b..644ee3d 100644 (file)
@@ -1,7 +1,7 @@
 ;;; info-look.el --- major-mode-sensitive Info index lookup facility
 ;; An older version of this was known as libc.el.
 
-;; Copyright (C) 1995,96,97,98,99,2001  Free Software Foundation, Inc.
+;; Copyright (C) 1995,96,97,98,99,2001,03,04  Free Software Foundation, Inc.
 
 ;; Author: Ralph Schleicher <rs@nunatak.allgaeu.org>
 ;;         (did not show signs of life (Nov 2001)  -stef)
@@ -27,7 +27,7 @@
 ;;; Commentary:
 
 ;; Really cool code to lookup info indexes.
-;; Try especially info-lookup-symbol (aka C-h TAB).
+;; Try especially info-lookup-symbol (aka C-h S).
 
 ;;; Code:
 
@@ -321,7 +321,7 @@ If optional argument QUERY is non-nil, query for the help mode."
   (let* ((completions (info-lookup->completions topic mode))
          (ignore-case (info-lookup->ignore-case topic mode))
          (entry (or (assoc (if ignore-case (downcase item) item) completions)
-                    (assoc-ignore-case item completions)
+                    (assoc-string item completions t)
                     (error "Not documented as a %s: %s" topic (or item ""))))
          (modes (info-lookup->all-modes topic mode))
          (window (selected-window))
@@ -338,7 +338,8 @@ If optional argument QUERY is non-nil, query for the help mode."
               (info-frame (and window (window-frame window))))
          (if (and info-frame
                   (display-multi-frame-p)
-                  (memq info-frame (frames-on-display-list)))
+                  (memq info-frame (frames-on-display-list))
+                  (not (eq info-frame (selected-frame))))
            (select-frame info-frame)
          (switch-to-buffer-other-window "*info*")))))
     (while (and (not found) modes)
@@ -407,12 +408,11 @@ If optional argument QUERY is non-nil, query for the help mode."
            (message "No %s help available for `%s'" topic mode)
          ;; Recursively setup cross references.
          ;; But refer only to non-void modes.
-         (mapcar (lambda (arg)
-                   (or (info-lookup->initialized topic arg)
-                       (info-lookup-setup-mode topic arg))
-                   (and (eq (info-lookup->initialized topic arg) t)
-                        (setq refer-modes (cons arg refer-modes))))
-                 (info-lookup->other-modes topic mode))
+         (dolist (arg (info-lookup->other-modes topic mode))
+           (or (info-lookup->initialized topic arg)
+               (info-lookup-setup-mode topic arg))
+           (and (eq (info-lookup->initialized topic arg) t)
+                (setq refer-modes (cons arg refer-modes))))
          (setq refer-modes (nreverse refer-modes))
          ;; Build the full completion alist.
          (setq completions
@@ -468,7 +468,7 @@ If optional argument QUERY is non-nil, query for the help mode."
              (progn
                (goto-char (point-min))
                (and (search-forward "\n* Menu:" nil t)
-                    (while (re-search-forward "\n\\* \\([^:\t\n]*\\):" nil t)
+                    (while (re-search-forward "\n\\* \\(.*\\): " nil t)
                       (setq entry (match-string 1)
                             item (funcall trans entry))
                       ;; `trans' can return nil if the regexp doesn't match.
@@ -682,13 +682,37 @@ Return nil if there is nothing appropriate in the buffer near point."
 (info-lookup-maybe-add-help
  :mode 'autoconf-mode
  :regexp "A[CM]_[_A-Z0-9]+"
- :doc-spec '(("(autoconf)Autoconf Macro Index" "AC_"
+ :doc-spec '(;; Autoconf Macro Index entries are without an "AC_" prefix,
+            ;; but with "AH_" or "AU_" for those.  So add "AC_" if there
+            ;; isn't already an "A._".
+             ("(autoconf)Autoconf Macro Index"
+              (lambda (item)
+                (if (string-match "^A._" item) item (concat "AC_" item)))
              "^[ \t]+- \\(Macro\\|Variable\\): .*\\<" "\\>")
-            ("(automake)Macro and Variable Index" nil
-             "^[ \t]*`" "'")
-            ;; These are for older versions (probably pre autoconf 2.5x):
+             ;; M4 Macro Index entries are without "AS_" prefixes, and
+             ;; mostly without "m4_" prefixes.  "dnl" is an exception, not
+             ;; wanting any prefix.  So AS_ is added back to upper-case
+             ;; names, m4_ to others which don't already an m4_.
+             ("(autoconf)M4 Macro Index"
+              (lambda (item)
+                (let ((case-fold-search nil))
+                  (cond ((or (string-equal item "dnl")
+                             (string-match "^m4_" item))
+                         item)
+                        ((string-match "^[A-Z0-9_]+$" item)
+                         (concat "AS_" item))
+                        (t
+                         (concat "m4_" item)))))
+             "^[ \t]+- Macro: .*\\<" "\\>")
+             ;; Autotest Macro Index entries are without "AT_".
+             ("(autoconf)Autotest Macro Index" "AT_"
+             "^[ \t]+- Macro: .*\\<" "\\>")
+            ;; This is for older versions (probably pre autoconf 2.5x):
             ("(autoconf)Macro Index" "AC_"
              "^[ \t]+- \\(Macro\\|Variable\\): .*\\<" "\\>")
+            ;; Automake has index entries for its notes on various autoconf
+            ;; macros (eg. AC_PROG_CC).  Ensure this is after the autoconf
+            ;; index, so as to prefer the autoconf docs.
             ("(automake)Macro and Variable Index" nil
              "^[ \t]*`" "'"))
  ;; Autoconf symbols are M4 macros.  Thus use M4's parser.
@@ -784,7 +808,7 @@ Return nil if there is nothing appropriate in the buffer near point."
 
 (info-lookup-maybe-add-help
  :mode 'scheme-mode
- :regexp "[^()'\" \t\n]+"
+ :regexp "[^()`',\" \t\n]+"
  :ignore-case t
  ;; Aubrey Jaffer's rendition from <URL:ftp://ftp-swiss.ai.mit.edu/pub/scm>
  :doc-spec '(("(r5rs)Index" nil
@@ -806,6 +830,17 @@ Return nil if there is nothing appropriate in the buffer near point."
              nil; "^ - [^:]+:[ ]+" don't think this prefix is useful here.
              nil)))
 
+(info-lookup-maybe-add-help
+ :mode 'maxima-mode
+ :ignore-case t
+ :regexp "[a-zA-Z_%]+"
+ :doc-spec '( ("(maxima)Function and Variable Index" nil 
+              "^ - [^:]+:[ ]+\\(\\[[^=]*=[ ]+\\)?" nil)))
+
+(info-lookup-maybe-add-help
+ :mode 'inferior-maxima-mode
+ :other-modes '(maxima-mode))
+
 ;; coreutils and bash builtins overlap in places, eg. printf, so there's a
 ;; question which should come first.  Some of the coreutils descriptions are
 ;; more detailed, but if bash is usually /bin/sh on a GNU system then the
@@ -851,7 +886,24 @@ Return nil if there is nothing appropriate in the buffer near point."
                        "awk")
                       ((string-equal item "gawk, versions of, information about, printing")
                        "gawk"))))))
+
+;; This misses some things which occur as node names but not in the
+;; index.  Unfortunately it also picks up the wrong one of multiple
+;; entries for the same term in some cases.  --fx
+(info-lookup-maybe-add-help
+ :mode 'cfengine-mode
+ :regexp "[[:alnum:]_]+\\(:?()\\)?"
+ :doc-spec '(("(cfengine-Reference)Variable Index"
+             (lambda (item)
+               ;; Index entries may be like `IsPlain()'
+               (if (string-match "\\([[:alnum:]_]+\\)()" item)
+                   (match-string 1 item)
+                 item))
+             ;; This gets functions in evaluated classes.  Other
+             ;; possible patterns don't seem to work too well.
+             "`" "(")))
 \f
 (provide 'info-look)
 
+;;; arch-tag: 0f1e3ea3-32a2-4461-bbab-3cff93539a74
 ;;; info-look.el ends here