1 ;;; info-look.el --- major-mode-sensitive Info index lookup facility
2 ;; An older version of this was known as libc.el.
4 ;; Copyright (C) 1995,96,97,98,99,2001 Free Software Foundation, Inc.
6 ;; Author: Ralph Schleicher <rs@nunatak.allgaeu.org>
7 ;; (did not show signs of life (Nov 2001) -stef)
8 ;; Keywords: help languages
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
29 ;; Really cool code to lookup info indexes.
30 ;; Try especially info-lookup-symbol (aka C-h TAB).
36 (defgroup info-lookup nil
37 "Major mode sensitive help agent."
38 :group
'help
:group
'languages
)
40 (defvar info-lookup-mode nil
41 "Symbol of the current buffer's help mode.
42 Help is provided according to the buffer's major mode if value is nil.
43 Automatically becomes buffer local when set in any fashion.")
44 (make-variable-buffer-local 'info-lookup-mode
)
46 (defcustom info-lookup-other-window-flag t
47 "Non-nil means pop up the Info buffer in another window."
48 :group
'info-lookup
:type
'boolean
)
50 (defcustom info-lookup-highlight-face
'highlight
51 "Face for highlighting looked up help items.
52 Setting this variable to nil disables highlighting."
53 :group
'info-lookup
:type
'face
)
55 (defvar info-lookup-highlight-overlay nil
56 "Overlay object used for highlighting.")
58 (defcustom info-lookup-file-name-alist
59 '(("\\`configure\\.in\\'" . autoconf-mode
) ;already covered by auto-mode-alist
60 ("\\`ac\\(local\\|site\\|include\\)\\.m4\\'" . autoconf-mode
))
61 "Alist of file names handled specially.
62 List elements are cons cells of the form
66 If a file name matches REGEXP, then use help mode MODE instead of the
68 :group
'info-lookup
:type
'(repeat (cons (string :tag
"Regexp")
69 (symbol :tag
"Mode"))))
71 (defvar info-lookup-history nil
72 "History of previous input lines.")
74 (defvar info-lookup-alist nil
75 "Alist of known help topics.
76 Cons cells are of the form
78 (HELP-TOPIC . HELP-DATA)
80 HELP-TOPIC is the symbol of a help topic.
81 HELP-DATA is a HELP-TOPIC's public data set.
82 Value is an alist with elements of the form
84 (HELP-MODE REGEXP IGNORE-CASE DOC-SPEC PARSE-RULE OTHER-MODES)
86 HELP-MODE is a mode's symbol.
87 REGEXP is a regular expression matching those help items whose
88 documentation can be looked up via DOC-SPEC.
89 IGNORE-CASE is non-nil if help items are case insensitive.
90 DOC-SPEC is a list of documentation specifications of the form
92 (INFO-NODE TRANS-FUNC PREFIX SUFFIX)
94 INFO-NODE is the name (including file name part) of an Info index.
95 TRANS-FUNC is a function translating index entries into help items;
96 nil means add only those index entries matching REGEXP, a string
97 means prepend string to the first word of all index entries.
98 PREFIX and SUFFIX are parts of a regular expression. If one of
99 them is non-nil then search the help item's Info node for the
100 first occurrence of the regular expression `PREFIX ITEM SUFFIX'.
101 ITEM will be highlighted with `info-lookup-highlight-face' if this
103 PARSE-RULE is either the symbol name of a function or a regular
104 expression for guessing the default help item at point. Fuzzy
105 regular expressions like \"[_a-zA-Z0-9]+\" do a better job if
106 there are no clear delimiters; do not try to write too complex
107 expressions. PARSE-RULE defaults to REGEXP.
108 OTHER-MODES is a list of cross references to other help modes.")
110 (defsubst info-lookup-
>topic-value
(topic)
111 (cdr (assoc topic info-lookup-alist
)))
113 (defsubst info-lookup-
>mode-value
(topic mode
)
114 (assoc mode
(info-lookup->topic-value topic
)))
116 (defsubst info-lookup-
>regexp
(topic mode
)
117 (nth 1 (info-lookup->mode-value topic mode
)))
119 (defsubst info-lookup-
>ignore-case
(topic mode
)
120 (nth 2 (info-lookup->mode-value topic mode
)))
122 (defsubst info-lookup-
>doc-spec
(topic mode
)
123 (nth 3 (info-lookup->mode-value topic mode
)))
125 (defsubst info-lookup-
>parse-rule
(topic mode
)
126 (nth 4 (info-lookup->mode-value topic mode
)))
128 (defsubst info-lookup-
>other-modes
(topic mode
)
129 (nth 5 (info-lookup->mode-value topic mode
)))
131 (defun info-lookup-add-help (&rest arg
)
132 "Add or update a help specification.
133 Function arguments are one or more options of the form
137 KEYWORD is either `:topic', `:mode', `:regexp', `:ignore-case',
138 `:doc-spec', `:parse-rule', or `:other-modes'.
139 ARGUMENT has a value as explained in the documentation of the
140 variable `info-lookup-alist'.
142 If no topic or mode option has been specified, then the help topic defaults
143 to `symbol', and the help mode defaults to the current major mode."
144 (apply 'info-lookup-add-help
* nil arg
))
146 (defun info-lookup-maybe-add-help (&rest arg
)
147 "Add a help specification iff none is defined.
148 See the documentation of the function `info-lookup-add-help'
150 (apply 'info-lookup-add-help
* t arg
))
152 (defun info-lookup-add-help* (maybe &rest arg
)
153 (let (topic mode regexp ignore-case doc-spec
154 parse-rule other-modes keyword value
)
159 (setq keyword
(car arg
))
160 (or (symbolp keyword
)
161 (error "Junk in argument list \"%S\"" arg
))
164 (error "Keyword \"%S\" is missing an argument" keyword
))
165 (setq value
(car arg
)
167 (cond ((eq keyword
:topic
)
171 ((eq keyword
:regexp
)
173 ((eq keyword
:ignore-case
)
174 (setq ignore-case value
))
175 ((eq keyword
:doc-spec
)
176 (setq doc-spec value
))
177 ((eq keyword
:parse-rule
)
178 (setq parse-rule value
))
179 ((eq keyword
:other-modes
)
180 (setq other-modes value
))
182 (error "Unknown keyword \"%S\"" keyword
))))
183 (or (and maybe
(info-lookup->mode-value topic mode
))
184 (let* ((data (list regexp ignore-case doc-spec parse-rule other-modes
))
185 (topic-cell (or (assoc topic info-lookup-alist
)
186 (car (setq info-lookup-alist
187 (cons (cons topic nil
)
188 info-lookup-alist
)))))
189 (mode-cell (assoc mode topic-cell
)))
191 (setcdr topic-cell
(cons (cons mode data
) (cdr topic-cell
)))
192 (setcdr mode-cell data
))))
195 (defvar info-lookup-cache nil
196 "Cache storing data maintained automatically by the program.
197 Value is an alist with cons cell of the form
199 (HELP-TOPIC . ((HELP-MODE INITIALIZED COMPLETIONS REFER-MODES) ...))
201 HELP-TOPIC is the symbol of a help topic.
202 HELP-MODE is a mode's symbol.
203 INITIALIZED is nil if HELP-MODE is uninitialized, t if
204 HELP-MODE is initialized, and `0' means HELP-MODE is
205 initialized but void.
206 COMPLETIONS is an alist of documented help items.
207 REFER-MODES is a list of other help modes to use.")
209 (defsubst info-lookup-
>cache
(topic)
210 (or (assoc topic info-lookup-cache
)
211 (car (setq info-lookup-cache
212 (cons (cons topic nil
)
213 info-lookup-cache
)))))
215 (defun info-lookup->topic-cache
(topic)
216 (cdr (info-lookup->cache topic
)))
218 (defun info-lookup->mode-cache
(topic mode
)
219 (assoc mode
(info-lookup->topic-cache topic
)))
221 (defun info-lookup->initialized
(topic mode
)
222 (nth 1 (info-lookup->mode-cache topic mode
)))
224 (defun info-lookup->completions
(topic mode
)
225 (or (info-lookup->initialized topic mode
)
226 (info-lookup-setup-mode topic mode
))
227 (nth 2 (info-lookup->mode-cache topic mode
)))
229 (defun info-lookup->refer-modes
(topic mode
)
230 (or (info-lookup->initialized topic mode
)
231 (info-lookup-setup-mode topic mode
))
232 (nth 3 (info-lookup->mode-cache topic mode
)))
234 (defun info-lookup->all-modes
(topic mode
)
235 (cons mode
(info-lookup->refer-modes topic mode
)))
237 (defun info-lookup-quick-all-modes (topic mode
)
238 (cons mode
(info-lookup->other-modes topic mode
)))
241 (defun info-lookup-reset ()
242 "Throw away all cached data.
243 This command is useful if the user wants to start at the beginning without
244 quitting Emacs, for example, after some Info documents were updated on the
247 (setq info-lookup-cache nil
))
250 (defun info-lookup-symbol (symbol &optional mode
)
251 "Display the definition of SYMBOL, as found in the relevant manual.
252 When this command is called interactively, it reads SYMBOL from the minibuffer.
253 In the minibuffer, use M-n to yank the default argument value
254 into the minibuffer so you can edit it.
255 The default symbol is the one found at point.
257 With prefix arg a query for the symbol help mode is offered."
259 (info-lookup-interactive-arguments 'symbol current-prefix-arg
))
260 (info-lookup 'symbol symbol mode
))
263 (defun info-lookup-file (file &optional mode
)
264 "Display the documentation of a file.
265 When this command is called interactively, it reads FILE from the minibuffer.
266 In the minibuffer, use M-n to yank the default file name
267 into the minibuffer so you can edit it.
268 The default file name is the one found at point.
270 With prefix arg a query for the file help mode is offered."
272 (info-lookup-interactive-arguments 'file current-prefix-arg
))
273 (info-lookup 'file file mode
))
275 (defun info-lookup-interactive-arguments (topic &optional query
)
276 "Read and return argument value (and help mode) for help topic TOPIC.
277 If optional argument QUERY is non-nil, query for the help mode."
278 (let* ((mode (cond (query
279 (info-lookup-change-mode topic
))
280 ((info-lookup->mode-value topic
(info-lookup-select-mode))
282 ((info-lookup-change-mode topic
))))
283 (completions (info-lookup->completions topic mode
))
284 (default (info-lookup-guess-default topic mode
))
285 (completion-ignore-case (info-lookup->ignore-case topic mode
))
286 (enable-recursive-minibuffers t
)
287 (value (completing-read
289 (format "Describe %s (default %s): " topic default
)
290 (format "Describe %s: " topic
))
291 completions nil nil nil
'info-lookup-history default
)))
292 (list (if (equal value
"") default value
) mode
)))
294 (defun info-lookup-select-mode ()
295 (when (and (not info-lookup-mode
) (buffer-file-name))
296 (let ((file-name (file-name-nondirectory (buffer-file-name)))
297 (file-name-alist info-lookup-file-name-alist
))
298 (while (and (not info-lookup-mode
) file-name-alist
)
299 (when (string-match (caar file-name-alist
) file-name
)
300 (setq info-lookup-mode
(cdar file-name-alist
)))
301 (setq file-name-alist
(cdr file-name-alist
)))))
302 (or info-lookup-mode
(setq info-lookup-mode major-mode
)))
304 (defun info-lookup-change-mode (topic)
305 (let* ((completions (mapcar (lambda (arg)
306 (cons (symbol-name (car arg
)) (car arg
)))
307 (info-lookup->topic-value topic
)))
308 (mode (completing-read
309 (format "Use %s help mode: " topic
)
310 completions nil t nil
'info-lookup-history
)))
311 (or (setq mode
(cdr (assoc mode completions
)))
312 (error "No %s help available" topic
))
313 (or (info-lookup->mode-value topic mode
)
314 (error "No %s help available for `%s'" topic mode
))
315 (setq info-lookup-mode mode
)))
317 (defun info-lookup (topic item mode
)
318 "Display the documentation of a help item."
319 (or mode
(setq mode
(info-lookup-select-mode)))
320 (or (info-lookup->mode-value topic mode
)
321 (error "No %s help available for `%s'" topic mode
))
322 (let ((entry (or (assoc (if (info-lookup->ignore-case topic mode
)
323 (downcase item
) item
)
324 (info-lookup->completions topic mode
))
325 (error "Not documented as a %s: %s" topic
(or item
""))))
326 (modes (info-lookup->all-modes topic mode
))
327 (window (selected-window))
328 found doc-spec node prefix suffix doc-found
)
329 (if (or (not info-lookup-other-window-flag
)
330 (eq (current-buffer) (get-buffer "*info*")))
333 (save-window-excursion (info))
334 ;; Determine whether or not the Info buffer is visible in
335 ;; another frame on the same display. If it is, simply raise
336 ;; that frame. Otherwise, display it in another window.
337 (let* ((window (get-buffer-window "*info*" t
))
338 (info-frame (and window
(window-frame window
))))
340 (display-multi-frame-p)
341 (memq info-frame
(frames-on-display-list)))
342 (select-frame info-frame
)
343 (switch-to-buffer-other-window "*info*")))))
344 (while (and (not found
) modes
)
345 (setq doc-spec
(info-lookup->doc-spec topic
(car modes
)))
346 (while (and (not found
) doc-spec
)
347 (setq node
(nth 0 (car doc-spec
))
348 prefix
(nth 2 (car doc-spec
))
349 suffix
(nth 3 (car doc-spec
)))
350 (when (condition-case error-data
352 (Info-goto-node node
)
355 (message "Cannot access Info node %s" node
)
360 (Info-menu (or (cdr entry
) item
))
362 (if (or prefix suffix
)
363 (let ((case-fold-search
364 (info-lookup->ignore-case topic
(car modes
)))
365 (buffer-read-only nil
))
366 (goto-char (point-min))
368 (concat prefix
(regexp-quote item
) suffix
))
369 (goto-char (match-beginning 0))
370 (and (display-color-p) info-lookup-highlight-face
371 ;; Search again for ITEM so that the first
372 ;; occurrence of ITEM will be highlighted.
373 (re-search-forward (regexp-quote item
))
374 (let ((start (match-beginning 0))
376 (if (overlayp info-lookup-highlight-overlay
)
377 (move-overlay info-lookup-highlight-overlay
378 start end
(current-buffer))
379 (setq info-lookup-highlight-overlay
380 (make-overlay start end
))))
381 (overlay-put info-lookup-highlight-overlay
382 'face info-lookup-highlight-face
)))))
384 (setq doc-spec
(cdr doc-spec
)))
385 (setq modes
(cdr modes
)))
387 (error "Info documentation for lookup was not found"))
388 ;; Don't leave the Info buffer if the help item couldn't be looked up.
389 (if (and info-lookup-other-window-flag found
)
390 (select-window window
))))
392 (defun info-lookup-setup-mode (topic mode
)
393 "Initialize the internal data structure."
394 (or (info-lookup->initialized topic mode
)
395 (let (cell data
(initialized 0) completions refer-modes
)
396 (if (not (info-lookup->mode-value topic mode
))
397 (message "No %s help available for `%s'" topic mode
)
398 ;; Recursively setup cross references.
399 ;; But refer only to non-void modes.
400 (mapcar (lambda (arg)
401 (or (info-lookup->initialized topic arg
)
402 (info-lookup-setup-mode topic arg
))
403 (and (eq (info-lookup->initialized topic arg
) t
)
404 (setq refer-modes
(cons arg refer-modes
))))
405 (info-lookup->other-modes topic mode
))
406 (setq refer-modes
(nreverse refer-modes
))
407 ;; Build the full completion alist.
409 (nconc (condition-case nil
410 (info-lookup-make-completions topic mode
)
413 (mapcar (lambda (arg)
414 (info-lookup->completions topic arg
))
416 (setq initialized t
))
417 ;; Update `info-lookup-cache'.
418 (setq cell
(info-lookup->mode-cache topic mode
)
419 data
(list initialized completions refer-modes
))
421 (setcdr (info-lookup->cache topic
)
422 (cons (cons mode data
) (info-lookup->topic-cache topic
)))
426 (defun info-lookup-make-completions (topic mode
)
427 "Create a unique alist from all index entries."
428 (let ((doc-spec (info-lookup->doc-spec topic mode
))
429 (regexp (concat "^\\(" (info-lookup->regexp topic mode
)
430 "\\)\\([ \t].*\\)?$"))
431 node trans entry item prefix result doc-found
432 (buffer (get-buffer-create " temp-info-look")))
433 (with-current-buffer buffer
436 (setq node
(nth 0 (car doc-spec
))
437 trans
(cond ((eq (nth 1 (car doc-spec
)) nil
)
439 (if (string-match regexp arg
)
440 (match-string 1 arg
))))
441 ((stringp (nth 1 (car doc-spec
)))
442 (setq prefix
(nth 1 (car doc-spec
)))
444 (if (string-match "^\\([^: \t\n]+\\)" arg
)
445 (concat prefix
(match-string 1 arg
)))))
446 (t (nth 1 (car doc-spec
)))))
447 (with-current-buffer buffer
448 (message "Processing Info node `%s'..." node
)
449 (when (condition-case error-data
451 (Info-goto-node node
)
454 (message "Cannot access Info node `%s'" node
)
459 (goto-char (point-min))
460 (and (search-forward "\n* Menu:" nil t
)
461 (while (re-search-forward "\n\\* \\([^:\t\n]*\\):" nil t
)
462 (setq entry
(match-string 1)
463 item
(funcall trans entry
))
464 ;; `trans' can return nil if the regexp doesn't match.
466 ;; Sometimes there's more than one Menu:
467 (not (string= entry
"Menu")))
468 (and (info-lookup->ignore-case topic mode
)
469 (setq item
(downcase item
)))
470 (and (string-equal entry item
)
472 (and (or (assoc item result
)
473 (setq result
(cons (cons item entry
)
476 (message "Processing Info node `%s'...done" node
)
477 (setq doc-spec
(cdr doc-spec
)))
479 (error "Info documentation for lookup was not found"))
482 (defun info-lookup-guess-default (topic mode
)
483 "Return a guess for a symbol to look up, based on text around point.
484 Try all related modes applicable to TOPIC and MODE.
485 Return nil if there is nothing appropriate in the buffer near point."
486 (let ((modes (info-lookup->all-modes topic mode
))
488 (while (and (not guess
) modes
)
489 (setq guess
(info-lookup-guess-default* topic
(car modes
))
491 ;; Collapse whitespace characters.
494 (while (string-match "[ \t\n]+" guess pos
)
495 (setq pos
(1+ (match-beginning 0)))
496 (setq guess
(replace-match " " t t guess
)))))
499 (defun info-lookup-guess-default* (topic mode
)
500 (let ((case-fold-search (info-lookup->ignore-case topic mode
))
501 (rule (or (info-lookup->parse-rule topic mode
)
502 (info-lookup->regexp topic mode
)))
503 (start (point)) end regexp subexp result
)
506 (setq result
(funcall rule
))
508 (setq regexp
(car rule
)
512 ;; If at start of symbol, don't go back to end of previous one.
514 (looking-at "[ \t\n]"))
515 (skip-chars-backward " \t\n"))
517 (while (and (re-search-backward regexp nil t
)
519 (>= (match-end 0) end
))
520 (setq result
(match-string subexp
)))
524 (skip-chars-forward " \t\n")
525 (and (looking-at regexp
)
526 (setq result
(match-string subexp
)))))))
529 (defun info-lookup-guess-c-symbol ()
530 "Get the C symbol at point."
533 (skip-syntax-backward "w_")
534 (let ((start (point)) prefix name
)
535 ;; Test for a leading `struct', `union', or `enum' keyword
536 ;; but ignore names like `foo_struct'.
537 (setq prefix
(and (< (skip-chars-backward " \t\n") 0)
538 (< (skip-chars-backward "_a-zA-Z0-9") 0)
539 (looking-at "\\(struct\\|union\\|enum\\)\\s ")
540 (concat (match-string 1) " ")))
542 (and (looking-at "[_a-zA-Z][_a-zA-Z0-9]*")
543 (setq name
(match-string 0)))
544 ;; Caveat! Look forward if point is at `struct' etc.
546 (or (string-equal name
"struct")
547 (string-equal name
"union")
548 (string-equal name
"enum"))
549 (looking-at "[a-z]+\\s +\\([_a-zA-Z][_a-zA-Z0-9]*\\)")
550 (setq prefix
(concat name
" ")
551 name
(match-string 1)))
552 (and (or prefix name
)
553 (concat prefix name
))))
557 (defun info-complete-symbol (&optional mode
)
558 "Perform completion on symbol preceding point."
560 (info-complete 'symbol
562 (if (info-lookup->mode-value
563 'symbol
(info-lookup-select-mode))
565 (info-lookup-change-mode 'symbol
)))))
568 (defun info-complete-file (&optional mode
)
569 "Perform completion on file preceding point."
573 (if (info-lookup->mode-value
574 'file
(info-lookup-select-mode))
576 (info-lookup-change-mode 'file
)))))
578 (defun info-complete (topic mode
)
579 "Try to complete a help item."
580 (barf-if-buffer-read-only)
581 (or mode
(setq mode
(info-lookup-select-mode)))
582 (or (info-lookup->mode-value topic mode
)
583 (error "No %s completion available for `%s'" topic mode
))
584 (let ((modes (info-lookup-quick-all-modes topic mode
))
587 (while (and (not try
) modes
)
588 (setq mode
(car modes
)
590 try
(info-lookup-guess-default* topic mode
))
593 (error "Found no %S to complete" topic
))
594 (let ((completions (info-lookup->completions topic mode
))
595 (completion-ignore-case (info-lookup->ignore-case topic mode
))
597 (setq completion
(try-completion try completions
))
598 (cond ((not completion
)
600 (message "No match"))
601 ((stringp completion
)
602 (or (assoc completion completions
)
603 (setq completion
(completing-read
604 (format "Complete %S: " topic
)
605 completions nil t completion
606 info-lookup-history
)))
607 ;; Find the original symbol and zap it.
609 (while (and (search-backward try nil t
)
614 (message "%s is complete"
615 (capitalize (prin1-to-string topic
))))))))
618 ;;; Initialize some common modes.
620 (info-lookup-maybe-add-help
621 :mode
'c-mode
:topic
'symbol
622 :regexp
"\\(struct \\|union \\|enum \\)?[_a-zA-Z][_a-zA-Z0-9]*"
623 :doc-spec
'(("(libc)Function Index" nil
624 "^[ \t]+- \\(Function\\|Macro\\): .*\\<" "\\>")
625 ("(libc)Variable Index" nil
626 "^[ \t]+- \\(Variable\\|Macro\\): .*\\<" "\\>")
627 ("(libc)Type Index" nil
628 "^[ \t]+- Data Type: \\<" "\\>")
629 ("(termcap)Var Index" nil
631 :parse-rule
'info-lookup-guess-c-symbol
)
633 (info-lookup-maybe-add-help
634 :mode
'c-mode
:topic
'file
635 :regexp
"[_a-zA-Z0-9./+-]+"
636 :doc-spec
'(("(libc)File Index")))
638 (info-lookup-maybe-add-help
640 :regexp
"[:;|]\\|%\\([%{}]\\|[_a-z]+\\)\\|YY[_A-Z]+\\|yy[_a-z]+"
641 :doc-spec
'(("(bison)Index" nil
643 :parse-rule
"[:;|]\\|%\\([%{}]\\|[_a-zA-Z][_a-zA-Z0-9]*\\)"
644 :other-modes
'(c-mode))
646 (info-lookup-maybe-add-help
648 :regexp
"\\$[^({]\\|\\.[_A-Z]*\\|[_a-zA-Z][_a-zA-Z0-9-]*"
649 :doc-spec
'(("(make)Name Index" nil
651 ("(automake)Macro and Variable Index" nil
653 :parse-rule
"\\$[^({]\\|\\.[_A-Z]*\\|[_a-zA-Z0-9-]+"
654 :other-modes
'(automake-mode))
656 (info-lookup-maybe-add-help
658 :regexp
"@\\([a-zA-Z]+\\|[^a-zA-Z]\\)"
659 :doc-spec
'(("(texinfo)Command and Variable Index"
660 ;; Ignore Emacs commands and prepend a `@'.
662 (if (string-match "^\\([a-zA-Z]+\\|[^a-zA-Z]\\)\\( .*\\)?$" item
)
663 (concat "@" (match-string 1 item
))))
666 (info-lookup-maybe-add-help
668 :regexp
"[_a-zA-Z][_a-zA-Z0-9]*"
669 :doc-spec
'(("(m4)Macro index"))
670 :parse-rule
"[_a-zA-Z0-9]+")
672 (info-lookup-maybe-add-help
674 :regexp
"A[CM]_[_A-Z0-9]+"
675 :doc-spec
'(("(autoconf)Macro Index" "AC_"
676 "^[ \t]+- \\(Macro\\|Variable\\): .*\\<" "\\>")
677 ("(automake)Macro and Variable Index" nil
679 ;; Autoconf symbols are M4 macros. Thus use M4's parser.
681 :other-modes
'(m4-mode))
683 (info-lookup-maybe-add-help
686 :doc-spec
'(("(gawk)Index"
688 (let ((case-fold-search nil
))
690 ;; `BEGIN' and `END'.
691 ((string-match "^\\([A-Z]+\\) special pattern\\b" item
)
692 (match-string 1 item
))
693 ;; `if', `while', `do', ...
694 ((string-match "^\\([a-z]+\\) statement\\b" item
)
695 (if (not (string-equal (match-string 1 item
) "control"))
696 (match-string 1 item
)))
698 ((string-match "^[A-Z]+$" item
)
700 ;; Built-in functions (matches to many entries).
701 ((string-match "^[a-z]+$" item
)
703 "`" "\\([ \t]*([^)]*)\\)?'")))
705 (info-lookup-maybe-add-help
707 :regexp
"[$@%][^a-zA-Z]\\|\\$\\^[A-Z]\\|[$@%]?[a-zA-Z][_a-zA-Z0-9]*"
708 :doc-spec
'(("(perl5)Function Index"
710 (if (string-match "^\\([a-zA-Z0-9]+\\)" item
)
711 (match-string 1 item
)))
713 ("(perl5)Variable Index"
715 ;; Work around bad formatted array variables.
716 (let ((sym (cond ((or (string-match "^\\$\\(.\\|@@\\)$" item
)
717 (string-match "^\\$\\^[A-Z]$" item
))
720 "^\\([$%@]\\|@@\\)?[_a-zA-Z0-9]+" item
)
721 (match-string 0 item
))
723 (if (string-match "@@" sym
)
724 (setq sym
(concat (substring sym
0 (match-beginning 0))
725 (substring sym
(1- (match-end 0))))))
726 (if (string-equal sym
"") nil sym
)))
728 :parse-rule
"[$@%]?\\([_a-zA-Z0-9]+\\|[^a-zA-Z]\\)")
730 (info-lookup-maybe-add-help
732 :regexp
"[$@%][^a-zA-Z]\\|\\$\\^[A-Z]\\|[$@%]?[a-zA-Z][_a-zA-Z0-9]*"
733 :other-modes
'(perl-mode))
735 (info-lookup-maybe-add-help
737 :regexp
"\\\\\\([a-zA-Z]+\\|[^a-zA-Z]\\)"
738 :doc-spec
'(("(latex)Command Index" nil
739 "`" "\\({[^}]*}\\)?'")))
741 (info-lookup-maybe-add-help
742 :mode
'emacs-lisp-mode
743 :regexp
"[^][()'\" \t\n]+"
744 :doc-spec
'(("(emacs)Command Index")
745 ("(emacs)Variable Index")
748 (info-lookup-maybe-add-help
749 :mode
'lisp-interaction-mode
750 :regexp
"[^][()'\" \t\n]+"
752 :other-modes
'(emacs-lisp-mode))
754 (info-lookup-maybe-add-help
756 :regexp
"[^()'\" \t\n]+"
758 :other-modes
'(emacs-lisp-mode))
760 (info-lookup-maybe-add-help
762 :regexp
"[^()'\" \t\n]+"
764 ;; Aubrey Jaffer's rendition from <URL:ftp://ftp-swiss.ai.mit.edu/pub/scm>
765 :doc-spec
'(("(r5rs)Index" nil
766 "^[ \t]+- [^:]+:[ \t]*" "\\b")))
768 (info-lookup-maybe-add-help
770 :regexp
"[_a-zA-Z0-9]+"
771 :doc-spec
'(("(octave)Function Index" nil
772 "^ - [^:]+:[ ]+\\(\\[[^=]*=[ ]+\\)?" nil
)
773 ("(octave)Variable Index" nil
"^ - [^:]+:[ ]+" nil
)
774 ;; Catch lines of the form "xyz statement"
775 ("(octave)Concept Index"
778 ((string-match "^\\([A-Z]+\\) statement\\b" item
)
779 (match-string 1 item
))
781 nil
; "^ - [^:]+:[ ]+" don't think this prefix is useful here.
786 ;;; info-look.el ends here