* Re: [Emacs-diffs] master dbb29d7: Add info-lookup help for gdb-script-mode
2017-01-18 14:21 ` Stefan Monnier
@ 2017-02-05 4:50 ` Tom Tromey
2017-02-05 5:01 ` Stefan Monnier
2017-02-05 15:28 ` Eli Zaretskii
0 siblings, 2 replies; 6+ messages in thread
From: Tom Tromey @ 2017-02-05 4:50 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Tom Tromey, emacs-devel
>>>>> "Stefan" == Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> I put it there because all other calls to info-lookup-add-help and
>> info-lookup-maybe-add-help are in that file,
Stefan> Right, but that's just because that's how it started, just like
Stefan> font-lock had all the rules for C, Lisp, TeX, ... in font-lock.el.
Stefan> We should really take them out and move them to their natural home.
I took a stab at this tonight and would appreciate your feedback.
My initial patch is appended.
This seems to work ok for the bits I changed. I tried them all
interactively. In some cases I don't have the needed manual but I at
least saw the expected error.
One exception is that visiting configure.ac first, trying C-h S, then
opening a .m4 file and trying C-h S leads to the latter not working. I
didn't look into this but I will if this all looks reasonable.
As an aside, it would be fantastic if info-lookup bits were hooked to
eldoc so that I could see a summary of the construct near point while I
type.
A few notes on the patch:
* I didn't touch anything relating to cc-mode since my impression is
that this mode isn't maintained in-tree. This just means the c-mode
and awk-mode entries (not sure why c++-mode doesn't default to c-mode
for info-look...).
* I couldn't move the emacs-lisp-mode-related calls because this failed
at dumping, I guess because info-look is required but not loaded by
loadup? Based on this I didn't try to move a bunch of others, like
help-mode, Custom-mode, etc.
* Several modes mentioned in info-look.el don't exist in the Emacs
source tree: bison-mode, maxima-mode, inferior-maxima-mode. Also
cfengine-mode is referenced but cfengine.el actually defines
cfengine2-mode and cfengine3-mode.
* I didn't want to get into perl-mode/cperl-mode which seemed like maybe
a difficult dependency to handle; namely I wasn't clear if cperl-mode
could (require 'perl-mode).
Tom
diff --git a/lisp/info-look.el b/lisp/info-look.el
index 694bcb4..3b74be1 100644
--- a/lisp/info-look.el
+++ b/lisp/info-look.el
@@ -649,26 +649,6 @@ info-lookup-guess-custom-symbol
(buffer-substring-no-properties beg end)))))
(error nil)))
-(defun info-lookup-guess-gdb-script-symbol ()
- "Get symbol at point in GDB script buffers."
- (condition-case nil
- (save-excursion
- (back-to-indentation)
- ;; Try to find the current line's full command in the index;
- ;; and default to the longest subset that is found.
- (when (looking-at "[-a-z]+\\(\\s-[-a-z]+\\)*")
- (let ((str-list (split-string (match-string-no-properties 0)
- "\\s-+" t))
- (completions (info-lookup->completions 'symbol
- 'gdb-script-mode)))
- (catch 'result
- (while str-list
- (let ((str (string-join str-list " ")))
- (when (assoc str completions)
- (throw 'result str))
- (nbutlast str-list)))))))
- (error nil)))
-
;;;###autoload
(defun info-complete-symbol (&optional mode)
"Perform completion on symbol preceding point."
@@ -765,96 +745,6 @@ info-complete
:other-modes '(c-mode))
(info-lookup-maybe-add-help
- :mode 'makefile-mode
- :regexp "\\$[^({]\\|\\.[_A-Z]*\\|[_a-zA-Z][_a-zA-Z0-9-]*"
- :doc-spec '(("(make)Name Index" nil
- "^[ \t]*['`‘]" "['’]"))
- :parse-rule "\\$[^({]\\|\\.[_A-Z]*\\|[_a-zA-Z0-9-]+")
-
-(info-lookup-maybe-add-help
- :topic 'symbol
- :mode 'makefile-automake-mode
- ;; similar regexp/parse-rule as makefile-mode, but also the following
- ;; (which have index entries),
- ;; "##" special automake comment
- ;; "+=" append operator, separate from the GNU make one
- :regexp "\\$[^({]\\|\\.[_A-Z]*\\|[_a-zA-Z][_a-zA-Z0-9-]*\\|##\\|\\+="
- :parse-rule "\\$[^({]\\|\\.[_A-Z]*\\|[_a-zA-Z0-9-]+\\|##\\|\\+="
- :doc-spec '(
- ;; "(automake)Macro Index" is autoconf macros used in
- ;; configure.ac, not Makefile.am, so don't have that here.
- ("(automake)Variable Index" nil "^[ \t]*['`‘]" "['’]")
- ;; In automake 1.4 macros and variables were a combined node.
- ("(automake)Macro and Variable Index" nil "^[ \t]*['`‘]"
- "['’]")
- ;; Directives like "if" are in the "General Index".
- ;; Prefix "`" since the text for say `+=' isn't always an
- ;; @item etc and so not always at the start of a line.
- ("(automake)General Index" nil "['`‘]" "['’]")
- ;; In automake 1.3 there was just a single "Index" node.
- ("(automake)Index" nil "['`‘]" "['’]"))
- :other-modes '(makefile-mode))
-
-(info-lookup-maybe-add-help
- :mode 'texinfo-mode
- :regexp "@\\([a-zA-Z]+\\|[^a-zA-Z]\\)"
- :doc-spec '(("(texinfo)Command and Variable Index"
- ;; Ignore Emacs commands and prepend a `@'.
- (lambda (item)
- (if (string-match "^\\([a-zA-Z]+\\|[^a-zA-Z]\\)\\( .*\\)?$" item)
- (concat "@" (match-string 1 item))))
- "['`‘]" "['’ ]")))
-
-(info-lookup-maybe-add-help
- :mode 'm4-mode
- :regexp "[_a-zA-Z][_a-zA-Z0-9]*"
- :doc-spec '(("(m4)Macro index"))
- :parse-rule "[_a-zA-Z0-9]+")
-
-(info-lookup-maybe-add-help
- :mode 'autoconf-mode
- :regexp "A[CM]_[_A-Z0-9]+"
- :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\\): .*\\<" "\\>")
- ;; 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 (if needed), 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)
- ;; Autoconf 2.62 index includes some macros
- ;; (e.g., AS_HELP_STRING), so avoid prefixing.
- (string-match "^AS_" 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.
- :parse-rule 'ignore
- :other-modes '(m4-mode))
-
-(info-lookup-maybe-add-help
:mode 'awk-mode
:regexp "[_a-zA-Z]+"
:doc-spec '(("(gawk)Index"
@@ -906,17 +796,6 @@ info-complete
:regexp "[$@%][^a-zA-Z]\\|\\$\\^[A-Z]\\|[$@%]?[a-zA-Z][_a-zA-Z0-9]*"
:other-modes '(perl-mode))
-(info-lookup-maybe-add-help
- :mode 'latex-mode
- :regexp "\\\\\\([a-zA-Z]+\\|[^a-zA-Z]\\)"
- :doc-spec `((,(if (Info-find-file "latex2e" t)
- ;; From http://home.gna.org/latexrefman
- "(latex2e)Command Index"
- "(latex)Command Index")
- ;; \frac{NUM}{DEN} etc can have more than one {xx} argument.
- ;; \sqrt[ROOT]{num} and others can have square brackets.
- nil "[`'‘]" "\\({[^}]*}|\\[[^]]*\\]\\)*['’]")))
-
(info-lookup-maybe-add-help
:mode 'emacs-lisp-mode
@@ -956,31 +835,6 @@ info-complete
:other-modes '(emacs-lisp-mode))
(info-lookup-maybe-add-help
- :mode 'scheme-mode
- :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
- "^[ \t]+-+ [^:]+:[ \t]*" "\\b")))
-
-(info-lookup-maybe-add-help
- :mode 'octave-mode
- :regexp "[_a-zA-Z0-9]+\\|\\s.+\\|[-!=^|*/.\\,><~&+]\\{1,3\\}\\|[][();,\"']"
- :doc-spec '(("(octave)Function Index" nil
- "^ -+ [^:]+:[ ]+\\(\\[[^=]*=[ ]+\\)?" nil)
- ("(octave)Variable Index" nil "^ -+ [^:]+:[ ]+" nil)
- ("(octave)Operator Index" nil nil nil)
- ;; Catch lines of the form "xyz statement"
- ("(octave)Concept Index"
- (lambda (item)
- (cond
- ((string-match "^\\([A-Z]+\\) statement\\b" item)
- (match-string 1 item))
- (t nil)))
- nil; "^ -+ [^:]+:[ ]+" don't think this prefix is useful here.
- nil)))
-
-(info-lookup-maybe-add-help
:mode 'maxima-mode
:ignore-case t
:regexp "[a-zA-Z0-9_%]+"
@@ -992,59 +846,6 @@ info-complete
:regexp "[a-zA-Z0-9_%]+"
: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
-;; 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 version 8.1 has node "Concept Index" and past
- ;; versions have node "Index", look for both, whichever is
- ;; absent is quietly ignored
- ("(coreutils)Index"
- (lambda (item) (if (string-match "\\`[a-z]+\\'" item) item)))
- ("(coreutils)Concept 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"))))))
-
;; 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
@@ -1073,13 +874,6 @@ info-complete
:regexp "[^][()`'‘’,:\" \t\n]+"
:other-modes '(emacs-lisp-mode))
-(info-lookup-maybe-add-help
- :mode 'gdb-script-mode
- :ignore-case nil
- :regexp "\\([-a-z]+\\(\\s-+[-a-z]+\\)*\\)"
- :doc-spec '(("(gdb)Command and Variable Index" nil
- nil nil))
- :parse-rule 'info-lookup-guess-gdb-script-symbol)
\f
(provide 'info-look)
diff --git a/lisp/progmodes/autoconf.el b/lisp/progmodes/autoconf.el
index 6d58faa..1c279df 100644
--- a/lisp/progmodes/autoconf.el
+++ b/lisp/progmodes/autoconf.el
@@ -35,6 +35,8 @@
;;; Code:
+(require 'info-look)
+
(defvar autoconf-mode-map (make-sparse-keymap))
(defvar autoconf-mode-hook nil
@@ -73,6 +75,49 @@ autoconf-current-defun-function
t)
(match-string-no-properties 1))))
+(info-lookup-maybe-add-help
+ :mode 'autoconf-mode
+ :regexp "A[CM]_[_A-Z0-9]+"
+ :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\\): .*\\<" "\\>")
+ ;; 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 (if needed), 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)
+ ;; Autoconf 2.62 index includes some macros
+ ;; (e.g., AS_HELP_STRING), so avoid prefixing.
+ (string-match "^AS_" 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.
+ :parse-rule 'ignore
+ :other-modes '(m4-mode))
+
;;;###autoload
(define-derived-mode autoconf-mode prog-mode "Autoconf"
"Major mode for editing Autoconf configure.ac files."
diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el
index 1301758..087ed2e 100644
--- a/lisp/progmodes/gud.el
+++ b/lisp/progmodes/gud.el
@@ -3212,6 +3212,36 @@ gud-find-class
;;; GDB script mode ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+(require 'info-look)
+
+(defun info-lookup-guess-gdb-script-symbol ()
+ "Get symbol at point in GDB script buffers."
+ (condition-case nil
+ (save-excursion
+ (back-to-indentation)
+ ;; Try to find the current line's full command in the index;
+ ;; and default to the longest subset that is found.
+ (when (looking-at "[-a-z]+\\(\\s-[-a-z]+\\)*")
+ (let ((str-list (split-string (match-string-no-properties 0)
+ "\\s-+" t))
+ (completions (info-lookup->completions 'symbol
+ 'gdb-script-mode)))
+ (catch 'result
+ (while str-list
+ (let ((str (string-join str-list " ")))
+ (when (assoc str completions)
+ (throw 'result str))
+ (nbutlast str-list)))))))
+ (error nil)))
+
+(info-lookup-maybe-add-help
+ :mode 'gdb-script-mode
+ :ignore-case nil
+ :regexp "\\([-a-z]+\\(\\s-+[-a-z]+\\)*\\)"
+ :doc-spec '(("(gdb)Command and Variable Index" nil
+ nil nil))
+ :parse-rule 'info-lookup-guess-gdb-script-symbol)
+
(defvar gdb-script-mode-syntax-table
(let ((st (make-syntax-table)))
(modify-syntax-entry ?' "\"" st)
diff --git a/lisp/progmodes/m4-mode.el b/lisp/progmodes/m4-mode.el
index b48654f..9001535 100644
--- a/lisp/progmodes/m4-mode.el
+++ b/lisp/progmodes/m4-mode.el
@@ -38,6 +38,8 @@
;;; Code:
+(require 'info-look)
+
(defgroup m4 nil
"m4 code editing commands for Emacs."
:link '(custom-group-link :tag "Font Lock Faces group" font-lock-faces)
@@ -146,6 +148,12 @@ m4-current-defun-name
"^\\(\\(m4_\\)?define\\|A._DEFUN\\)(\\[?\\([A-Za-z0-9_]+\\)" nil t)
(match-string-no-properties 3))))
+(info-lookup-maybe-add-help
+ :mode 'm4-mode
+ :regexp "[_a-zA-Z][_a-zA-Z0-9]*"
+ :doc-spec '(("(m4)Macro index"))
+ :parse-rule "[_a-zA-Z0-9]+")
+
;;;###autoload
(define-derived-mode m4-mode prog-mode "m4"
"A major mode to edit m4 macro files."
diff --git a/lisp/progmodes/make-mode.el b/lisp/progmodes/make-mode.el
index 5cda7bb..11c179a 100644
--- a/lisp/progmodes/make-mode.el
+++ b/lisp/progmodes/make-mode.el
@@ -1855,6 +1855,39 @@ makefile-add-log-defun
(setq found (replace-regexp-in-string "\\`[ \t]+" "" found)))
found)))
+(require 'info-look)
+
+(info-lookup-maybe-add-help
+ :mode 'makefile-mode
+ :regexp "\\$[^({]\\|\\.[_A-Z]*\\|[_a-zA-Z][_a-zA-Z0-9-]*"
+ :doc-spec '(("(make)Name Index" nil
+ "^[ \t]*['`‘]" "['’]"))
+ :parse-rule "\\$[^({]\\|\\.[_A-Z]*\\|[_a-zA-Z0-9-]+")
+
+(info-lookup-maybe-add-help
+ :topic 'symbol
+ :mode 'makefile-automake-mode
+ ;; similar regexp/parse-rule as makefile-mode, but also the following
+ ;; (which have index entries),
+ ;; "##" special automake comment
+ ;; "+=" append operator, separate from the GNU make one
+ :regexp "\\$[^({]\\|\\.[_A-Z]*\\|[_a-zA-Z][_a-zA-Z0-9-]*\\|##\\|\\+="
+ :parse-rule "\\$[^({]\\|\\.[_A-Z]*\\|[_a-zA-Z0-9-]+\\|##\\|\\+="
+ :doc-spec '(
+ ;; "(automake)Macro Index" is autoconf macros used in
+ ;; configure.ac, not Makefile.am, so don't have that here.
+ ("(automake)Variable Index" nil "^[ \t]*['`‘]" "['’]")
+ ;; In automake 1.4 macros and variables were a combined node.
+ ("(automake)Macro and Variable Index" nil "^[ \t]*['`‘]"
+ "['’]")
+ ;; Directives like "if" are in the "General Index".
+ ;; Prefix "`" since the text for say `+=' isn't always an
+ ;; @item etc and so not always at the start of a line.
+ ("(automake)General Index" nil "['`‘]" "['’]")
+ ;; In automake 1.3 there was just a single "Index" node.
+ ("(automake)Index" nil "['`‘]" "['’]"))
+ :other-modes '(makefile-mode))
+
(provide 'make-mode)
;;; make-mode.el ends here
diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el
index ac9ba63..f798f7f 100644
--- a/lisp/progmodes/octave.el
+++ b/lisp/progmodes/octave.el
@@ -1829,5 +1829,27 @@ octave-find-definition
(find-file file)
(octave-goto-function-definition fn)))))))
+\f
+;;; info-look
+
+(require 'info-look)
+
+(info-lookup-maybe-add-help
+ :mode 'octave-mode
+ :regexp "[_a-zA-Z0-9]+\\|\\s.+\\|[-!=^|*/.\\,><~&+]\\{1,3\\}\\|[][();,\"']"
+ :doc-spec '(("(octave)Function Index" nil
+ "^ -+ [^:]+:[ ]+\\(\\[[^=]*=[ ]+\\)?" nil)
+ ("(octave)Variable Index" nil "^ -+ [^:]+:[ ]+" nil)
+ ("(octave)Operator Index" nil nil nil)
+ ;; Catch lines of the form "xyz statement"
+ ("(octave)Concept Index"
+ (lambda (item)
+ (cond
+ ((string-match "^\\([A-Z]+\\) statement\\b" item)
+ (match-string 1 item))
+ (t nil)))
+ nil; "^ -+ [^:]+:[ ]+" don't think this prefix is useful here.
+ nil)))
+
(provide 'octave)
;;; octave.el ends here
diff --git a/lisp/progmodes/scheme.el b/lisp/progmodes/scheme.el
index 0dcf9b4..fef2a9d 100644
--- a/lisp/progmodes/scheme.el
+++ b/lisp/progmodes/scheme.el
@@ -50,6 +50,7 @@
;;; Code:
\f
+(require 'info-look)
(require 'lisp-mode)
(defvar scheme-mode-syntax-table
@@ -187,6 +188,14 @@ scheme-mode-commands
(define-key map "\177" 'backward-delete-char-untabify)
(define-key map "\e\C-q" 'indent-sexp))
\f
+(info-lookup-maybe-add-help
+ :mode 'scheme-mode
+ :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
+ "^[ \t]+-+ [^:]+:[ \t]*" "\\b")))
+
;;;###autoload
(define-derived-mode scheme-mode prog-mode "Scheme"
"Major mode for editing Scheme code.
diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el
index a0bbf55..713b6c4 100644
--- a/lisp/progmodes/sh-script.el
+++ b/lisp/progmodes/sh-script.el
@@ -1562,6 +1562,64 @@ sh-send-line-or-region-and-step
(goto-char end)))
\f
+;; info-look
+
+(require 'info-look)
+
+;; 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 version 8.1 has node "Concept Index" and past
+ ;; versions have node "Index", look for both, whichever is
+ ;; absent is quietly ignored
+ ("(coreutils)Index"
+ (lambda (item) (if (string-match "\\`[a-z]+\\'" item) item)))
+ ("(coreutils)Concept 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
;; mode-command and utility functions
(defun sh-after-hack-local-variables ()
diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el
index ba6d696..86ce27b 100644
--- a/lisp/textmodes/tex-mode.el
+++ b/lisp/textmodes/tex-mode.el
@@ -39,6 +39,7 @@ font-lock-doc-face
(require 'shell)
(require 'compile)
+(require 'info-look)
(defgroup tex-file nil
"TeX files and directories."
@@ -1075,6 +1076,17 @@ plain-tex-mode
(setq-local tex-end-of-header "%\\*\\*end of header")
(setq-local tex-trailer "\\bye\n"))
+(info-lookup-maybe-add-help
+ :mode 'latex-mode
+ :regexp "\\\\\\([a-zA-Z]+\\|[^a-zA-Z]\\)"
+ :doc-spec `((,(if (Info-find-file "latex2e" t)
+ ;; From http://home.gna.org/latexrefman
+ "(latex2e)Command Index"
+ "(latex)Command Index")
+ ;; \frac{NUM}{DEN} etc can have more than one {xx} argument.
+ ;; \sqrt[ROOT]{num} and others can have square brackets.
+ nil "[`'‘]" "\\({[^}]*}|\\[[^]]*\\]\\)*['’]")))
+
;;;###autoload
(define-derived-mode latex-mode tex-mode "LaTeX"
"Major mode for editing files of input for LaTeX.
diff --git a/lisp/textmodes/texinfo.el b/lisp/textmodes/texinfo.el
index f962dec..b3a5ff0 100644
--- a/lisp/textmodes/texinfo.el
+++ b/lisp/textmodes/texinfo.el
@@ -1033,6 +1033,21 @@ texinfo-delete-from-print-queue
;; job-number"\n"))
(tex-recenter-output-buffer nil))
+\f
+;;; info-look
+
+(require 'info-look)
+
+(info-lookup-maybe-add-help
+ :mode 'texinfo-mode
+ :regexp "@\\([a-zA-Z]+\\|[^a-zA-Z]\\)"
+ :doc-spec '(("(texinfo)Command and Variable Index"
+ ;; Ignore Emacs commands and prepend a `@'.
+ (lambda (item)
+ (if (string-match "^\\([a-zA-Z]+\\|[^a-zA-Z]\\)\\( .*\\)?$" item)
+ (concat "@" (match-string 1 item))))
+ "['`‘]" "['’ ]")))
+
(provide 'texinfo)
;;; texinfo.el ends here
^ permalink raw reply related [flat|nested] 6+ messages in thread