]> code.delx.au - gnu-emacs/blobdiff - lisp/info-look.el
*** empty log message ***
[gnu-emacs] / lisp / info-look.el
index 1de84d3e4216b7d59367f791e7a8318fc480b574..e81d33e65f2f65c5f9b3c012f876b3b0675620b7 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,2003  Free Software Foundation, Inc.
 
 ;; Author: Ralph Schleicher <rs@nunatak.allgaeu.org>
 ;;         (did not show signs of life (Nov 2001)  -stef)
@@ -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.
@@ -756,9 +756,19 @@ Return nil if there is nothing appropriate in the buffer near point."
 (info-lookup-maybe-add-help
  :mode 'emacs-lisp-mode
  :regexp "[^][()'\" \t\n]+"
- :doc-spec '(("(emacs)Command Index")
-            ("(emacs)Variable Index")
-            ("(elisp)Index")))
+ :doc-spec '(;; Commands with key sequences appear in nodes as `foo' and
+             ;; those without as `M-x foo'.
+             ("(emacs)Command Index"  nil "`\\(M-x[ \t\n]+\\)?" "'")
+             ;; Variables normally appear in nodes as just `foo'.
+             ("(emacs)Variable Index" nil "`" "'")
+             ;; Almost all functions, variables, etc appear in nodes as
+             ;; " - Function: foo" etc.  A small number of aliases and
+             ;; symbols appear only as `foo', and will miss out on exact
+             ;; positions.  Allowing `foo' would hit too many false matches
+             ;; for things that should go to Function: etc, and those latter
+             ;; are much more important.  Perhaps this could change if some
+             ;; sort of fallback match scheme existed.
+             ("(elisp)Index"          nil "^ - .*: " "\\( \\|$\\)")))
 
 (info-lookup-maybe-add-help
  :mode 'lisp-interaction-mode
@@ -783,7 +793,7 @@ Return nil if there is nothing appropriate in the buffer near point."
 (info-lookup-maybe-add-help
  :mode 'octave-mode
  :regexp "[_a-zA-Z0-9]+"
- :doc-spec '(("(octave)Function Index" nil 
+ :doc-spec '(("(octave)Function Index" nil
              "^ - [^:]+:[ ]+\\(\\[[^=]*=[ ]+\\)?" nil)
             ("(octave)Variable Index" nil "^ - [^:]+:[ ]+" nil)
             ;; Catch lines of the form "xyz statement"
@@ -795,6 +805,52 @@ Return nil if there is nothing appropriate in the buffer near point."
                 (t nil)))
              nil; "^ - [^:]+:[ ]+" don't think this prefix is useful here.
              nil)))
+
+;; 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
+;; builtins will be what's normally run.
+;;
+;; Maybe special variables like $? should be matched as $?, not just ?.
+;; This would avoid a clash between variable $! and negation !, or variable
+;; $# and comment # (though comment # is not currently indexed in bash).
+;; Unfortunately if $? etc is the symbol, then we wouldn't be taken to the
+;; exact spot in the relevant node, since the bash manual has just `?' etc
+;; there.  Maybe an extension to the prefix/suffix scheme could help this.
+
+(info-lookup-maybe-add-help
+ :mode 'sh-mode :topic 'symbol
+ ;; bash has "." and ":" in its index, but those chars will probably never
+ ;; work in info, so don't bother matching them in the regexp.
+ :regexp "\\([a-zA-Z0-9_-]+\\|[!{}@*#?$]\\|\\[\\[?\\|]]?\\)"
+ :doc-spec '(("(bash)Builtin Index"       nil "^`" "[ .']")
+             ("(bash)Reserved Word Index" nil "^`" "[ .']")
+             ("(bash)Variable Index"      nil "^`" "[ .']")
+             ;; coreutils (version 4.5.10) doesn't have a separate program
+             ;; index, so exclude extraneous stuff (most of it) by demanding
+             ;; "[a-z]+" in the trans-func.
+             ("(coreutils)Index"
+              (lambda (item) (if (string-match "\\`[a-z]+\\'" item) item)))
+             ;; diff (version 2.8.1) has only a few programs, index entries
+             ;; are things like "foo invocation".
+             ("(diff)Index"
+              (lambda (item)
+               (if (string-match "\\`\\([a-z]+\\) invocation\\'" item)
+                    (match-string 1 item))))
+             ;; there's no plain "sed" index entry as such, mung another
+             ;; hopefully unique one to get to the invocation section
+             ("(sed)Concept Index"
+              (lambda (item)
+                (if (string-equal item "Standard input, processing as input")
+                    "sed")))
+             ;; there's no plain "awk" or "gawk" index entries, mung other
+             ;; hopefully unique ones to get to the command line options
+             ("(gawk)Index"
+              (lambda (item)
+                (cond ((string-equal item "gawk, extensions, disabling")
+                       "awk")
+                      ((string-equal item "gawk, versions of, information about, printing")
+                       "gawk"))))))
 \f
 (provide 'info-look)