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, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
6 ;; Author: Ralph Schleicher <rs@nunatak.allgaeu.org>
7 ;; Keywords: help languages
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
30 (defgroup info-lookup nil
31 "Major mode sensitive help agent."
32 :group
'help
:group
'languages
)
34 (defvar info-lookup-mode nil
35 "Symbol of the current buffer's help mode.
36 Help is provided according to the buffer's major mode if value is nil.
37 Automatically becomes buffer local when set in any fashion.")
38 (make-variable-buffer-local 'info-lookup-mode
)
40 (defcustom info-lookup-other-window-flag t
41 "Non-nil means pop up the Info buffer in another window."
42 :group
'info-lookup
:type
'boolean
)
44 (defcustom info-lookup-highlight-face
'highlight
45 "Face for highlighting looked up help items.
46 Setting this variable to nil disables highlighting."
47 :group
'info-lookup
:type
'face
)
49 (defvar info-lookup-highlight-overlay nil
50 "Overlay object used for highlighting.")
52 (defcustom info-lookup-file-name-alist
53 '(("\\`configure\\.in\\'" . autoconf-mode
)
54 ("\\`aclocal\\.m4\\'" . autoconf-mode
)
55 ("\\`acsite\\.m4\\'" . autoconf-mode
)
56 ("\\`acinclude\\.m4\\'" . autoconf-mode
))
57 "Alist of file names handled specially.
58 List elements are cons cells of the form
62 If a file name matches REGEXP, then use help mode MODE instead of the
64 :group
'info-lookup
:type
'(repeat (cons (string :tag
"Regexp")
65 (symbol :tag
"Mode"))))
67 (defvar info-lookup-history nil
68 "History of previous input lines.")
70 (defvar info-lookup-alist nil
71 "Alist of known help topics.
72 Cons cells are of the form
74 (HELP-TOPIC . HELP-DATA)
76 HELP-TOPIC is the symbol of a help topic.
77 HELP-DATA is a HELP-TOPIC's public data set.
78 Value is an alist with elements of the form
80 (HELP-MODE REGEXP IGNORE-CASE DOC-SPEC PARSE-RULE OTHER-MODES)
82 HELP-MODE is a mode's symbol.
83 REGEXP is a regular expression matching those help items whose
84 documentation can be looked up via DOC-SPEC.
85 IGNORE-CASE is non-nil if help items are case insensitive.
86 DOC-SPEC is a list of documentation specifications of the form
88 (INFO-NODE TRANS-FUNC PREFIX SUFFIX)
90 INFO-NODE is the name (including file name part) of an Info index.
91 TRANS-FUNC is a function translating index entries into help items;
92 nil means add only those index entries matching REGEXP, a string
93 means prepend string to the first word of all index entries.
94 PREFIX and SUFFIX are parts of a regular expression. If one of
95 them is non-nil then search the help item's Info node for the
96 first occurrence of the regular expression `PREFIX ITEM SUFFIX'.
97 ITEM will be highlighted with `info-lookup-highlight-face' if this
99 PARSE-RULE is either the symbol name of a function or a regular
100 expression for guessing the default help item at point. Fuzzy
101 regular expressions like \"[_a-zA-Z0-9]+\" do a better job if
102 there are no clear delimiters; do not try to write too complex
103 expressions. PARSE-RULE defaults to REGEXP.
104 OTHER-MODES is a list of cross references to other help modes.")
106 (defsubst info-lookup-
>topic-value
(topic)
107 (cdr (assoc topic info-lookup-alist
)))
109 (defsubst info-lookup-
>mode-value
(topic mode
)
110 (assoc mode
(info-lookup->topic-value topic
)))
112 (defsubst info-lookup-
>regexp
(topic mode
)
113 (nth 1 (info-lookup->mode-value topic mode
)))
115 (defsubst info-lookup-
>ignore-case
(topic mode
)
116 (nth 2 (info-lookup->mode-value topic mode
)))
118 (defsubst info-lookup-
>doc-spec
(topic mode
)
119 (nth 3 (info-lookup->mode-value topic mode
)))
121 (defsubst info-lookup-
>parse-rule
(topic mode
)
122 (nth 4 (info-lookup->mode-value topic mode
)))
124 (defsubst info-lookup-
>other-modes
(topic mode
)
125 (nth 5 (info-lookup->mode-value topic mode
)))
128 (mapcar (lambda (keyword)
130 (set keyword keyword
)))
131 '(:topic
:mode
:regexp
:ignore-case
132 :doc-spec
:parse-rule
:other-modes
)))
134 (defun info-lookup-add-help (&rest arg
)
135 "Add or update a help specification.
136 Function arguments are one or more options of the form
140 KEYWORD is either `:topic', `:mode', `:regexp', `:ignore-case',
141 `:doc-spec', `:parse-rule', or `:other-modes'.
142 ARGUMENT has a value as explained in the documentation of the
143 variable `info-lookup-alist'.
145 If no topic or mode option has been specified, then the help topic defaults
146 to `symbol', and the help mode defaults to the current major mode."
147 (apply 'info-lookup-add-help
* nil arg
))
149 (defun info-lookup-maybe-add-help (&rest arg
)
150 "Add a help specification iff no one is defined.
151 See the documentation of the function `info-lookup-add-help'
153 (apply 'info-lookup-add-help
* t arg
))
155 (defun info-lookup-add-help* (maybe &rest arg
)
156 (let (topic mode regexp ignore-case doc-spec
157 parse-rule other-modes keyword value
)
162 (setq keyword
(car arg
))
163 (or (symbolp keyword
)
164 (error "Junk in argument list \"%S\"" arg
))
167 (error "Keyword \"%S\" is missing an argument" keyword
))
168 (setq value
(car arg
)
170 (cond ((eq keyword
:topic
)
174 ((eq keyword
:regexp
)
176 ((eq keyword
:ignore-case
)
177 (setq ignore-case value
))
178 ((eq keyword
:doc-spec
)
179 (setq doc-spec value
))
180 ((eq keyword
:parse-rule
)
181 (setq parse-rule value
))
182 ((eq keyword
:other-modes
)
183 (setq other-modes value
))
185 (error "Unknown keyword \"%S\"" keyword
))))
186 (or (and maybe
(info-lookup->mode-value topic mode
))
187 (let* ((data (list regexp ignore-case doc-spec parse-rule other-modes
))
188 (topic-cell (or (assoc topic info-lookup-alist
)
189 (car (setq info-lookup-alist
190 (cons (cons topic nil
)
191 info-lookup-alist
)))))
192 (mode-cell (assoc mode topic-cell
)))
194 (setcdr topic-cell
(cons (cons mode data
) (cdr topic-cell
)))
195 (setcdr mode-cell data
))))
198 (defvar info-lookup-cache nil
199 "Cache storing data maintained automatically by the program.
200 Value is an alist with cons cell of the form
202 (HELP-TOPIC . ((HELP-MODE INITIALIZED COMPLETIONS REFER-MODES) ...))
204 HELP-TOPIC is the symbol of a help topic.
205 HELP-MODE is a mode's symbol.
206 INITIALIZED is nil if HELP-MODE is uninitialized, t if
207 HELP-MODE is initialized, and `0' means HELP-MODE is
208 initialized but void.
209 COMPLETIONS is an alist of documented help items.
210 REFER-MODES is a list of other help modes to use.")
212 (defsubst info-lookup-
>cache
(topic)
213 (or (assoc topic info-lookup-cache
)
214 (car (setq info-lookup-cache
215 (cons (cons topic nil
)
216 info-lookup-cache
)))))
218 (defun info-lookup->topic-cache
(topic)
219 (cdr (info-lookup->cache topic
)))
221 (defun info-lookup->mode-cache
(topic mode
)
222 (assoc mode
(info-lookup->topic-cache topic
)))
224 (defun info-lookup->initialized
(topic mode
)
225 (nth 1 (info-lookup->mode-cache topic mode
)))
227 (defun info-lookup->completions
(topic mode
)
228 (or (info-lookup->initialized topic mode
)
229 (info-lookup-setup-mode topic mode
))
230 (nth 2 (info-lookup->mode-cache topic mode
)))
232 (defun info-lookup->refer-modes
(topic mode
)
233 (or (info-lookup->initialized topic mode
)
234 (info-lookup-setup-mode topic mode
))
235 (nth 3 (info-lookup->mode-cache topic mode
)))
237 (defun info-lookup->all-modes
(topic mode
)
238 (cons mode
(info-lookup->refer-modes topic mode
)))
240 (defun info-lookup-quick-all-modes (topic mode
)
241 (cons mode
(info-lookup->other-modes topic mode
)))
244 (defun info-lookup-reset ()
245 "Throw away all cached data.
246 This command is useful if the user wants to start at the beginning without
247 quitting Emacs, for example, after some Info documents were updated on the
250 (setq info-lookup-cache nil
))
253 (defun info-lookup-symbol (symbol &optional mode
)
254 "Display the definition of SYMBOL, as found in the relevant manual.
255 When this command is called interactively, it reads SYMBOL from the minibuffer.
256 In the minibuffer, use M-n to yank the default argument value
257 into the minibuffer so you can edit it.
258 The default symbol is the one found at point.
260 With prefix arg a query for the symbol help mode is offered."
262 (info-lookup-interactive-arguments 'symbol current-prefix-arg
))
263 (info-lookup 'symbol symbol mode
))
266 (defun info-lookup-file (file &optional mode
)
267 "Display the documentation of a file.
268 When this command is called interactively, it reads FILE from the minibuffer.
269 In the minibuffer, use M-n to yank the default file name
270 into the minibuffer so you can edit it.
271 The default file name is the one found at point.
273 With prefix arg a query for the file help mode is offered."
275 (info-lookup-interactive-arguments 'file current-prefix-arg
))
276 (info-lookup 'file file mode
))
278 (defun info-lookup-interactive-arguments (topic &optional query
)
279 "Read and return argument value (and help mode) for help topic TOPIC.
280 If optional argument QUERY is non-nil, query for the help mode."
281 (let* ((mode (cond (query
282 (info-lookup-change-mode topic
))
283 ((info-lookup->mode-value topic
(info-lookup-select-mode))
285 ((info-lookup-change-mode topic
))))
286 (completions (info-lookup->completions topic mode
))
287 (default (info-lookup-guess-default topic mode
))
288 (completion-ignore-case (info-lookup->ignore-case topic mode
))
289 (enable-recursive-minibuffers t
)
290 (value (completing-read
292 (format "Describe %s (default %s): " topic default
)
293 (format "Describe %s: " topic
))
294 completions nil nil nil
'info-lookup-history default
)))
295 (list (if (equal value
"") default value
) mode
)))
297 (defun info-lookup-select-mode ()
298 (when (and (not info-lookup-mode
) (buffer-file-name))
299 (let ((file-name (file-name-nondirectory (buffer-file-name)))
300 (file-name-alist info-lookup-file-name-alist
))
301 (while (and (not info-lookup-mode
) file-name-alist
)
302 (when (string-match (caar file-name-alist
) file-name
)
303 (setq info-lookup-mode
(cdar file-name-alist
)))
304 (setq file-name-alist
(cdr file-name-alist
)))))
305 (or info-lookup-mode
(setq info-lookup-mode major-mode
)))
307 (defun info-lookup-change-mode (topic)
308 (let* ((completions (mapcar (lambda (arg)
309 (cons (symbol-name (car arg
)) (car arg
)))
310 (info-lookup->topic-value topic
)))
311 (mode (completing-read
312 (format "Use %s help mode: " topic
)
313 completions nil t nil
'info-lookup-history
)))
314 (or (setq mode
(cdr (assoc mode completions
)))
315 (error "No %s help available" topic
))
316 (or (info-lookup->mode-value topic mode
)
317 (error "No %s help available for `%s'" topic mode
))
318 (setq info-lookup-mode mode
)))
320 (defun info-lookup (topic item mode
)
321 "Display the documentation of a help item."
322 (or mode
(setq mode
(info-lookup-select-mode)))
323 (or (info-lookup->mode-value topic mode
)
324 (error "No %s help available for `%s'" topic mode
))
325 (let ((entry (or (assoc (if (info-lookup->ignore-case topic mode
)
326 (downcase item
) item
)
327 (info-lookup->completions topic mode
))
328 (error "Not documented as a %s: %s" topic
(or item
""))))
329 (modes (info-lookup->all-modes topic mode
))
330 (window (selected-window))
331 found doc-spec node prefix suffix doc-found
)
332 (if (or (not info-lookup-other-window-flag
)
333 (eq (current-buffer) (get-buffer "*info*")))
336 (save-window-excursion (info))
337 ;; Determine whether or not the Info buffer is visible in
338 ;; another frame on the same display. If it is, simply raise
339 ;; that frame. Otherwise, display it in another window.
340 (let* ((window (get-buffer-window "*info*" t
))
341 (info-frame (and window
(window-frame window
))))
343 (display-multi-frame-p)
344 (memq info-frame
(frames-on-display-list)))
345 (select-frame info-frame
)
346 (switch-to-buffer-other-window "*info*")))))
347 (while (and (not found
) modes
)
348 (setq doc-spec
(info-lookup->doc-spec topic
(car modes
)))
349 (while (and (not found
) doc-spec
)
350 (setq node
(nth 0 (car doc-spec
))
351 prefix
(nth 2 (car doc-spec
))
352 suffix
(nth 3 (car doc-spec
)))
353 (when (condition-case error-data
355 (Info-goto-node node
)
358 (message "Cannot access Info node %s" node
)
363 (Info-menu (or (cdr entry
) item
))
365 (if (or prefix suffix
)
366 (let ((case-fold-search
367 (info-lookup->ignore-case topic
(car modes
)))
368 (buffer-read-only nil
))
369 (goto-char (point-min))
371 (concat prefix
(regexp-quote item
) suffix
))
372 (goto-char (match-beginning 0))
373 (and (display-color-p) info-lookup-highlight-face
374 ;; Search again for ITEM so that the first
375 ;; occurence of ITEM will be highlighted.
376 (re-search-forward (regexp-quote item
))
377 (let ((start (match-beginning 0))
379 (if (overlayp info-lookup-highlight-overlay
)
380 (move-overlay info-lookup-highlight-overlay
381 start end
(current-buffer))
382 (setq info-lookup-highlight-overlay
383 (make-overlay start end
))))
384 (overlay-put info-lookup-highlight-overlay
385 'face info-lookup-highlight-face
)))))
387 (setq doc-spec
(cdr doc-spec
)))
388 (setq modes
(cdr modes
)))
390 (error "Info documentation for lookup was not found"))
391 ;; Don't leave the Info buffer if the help item couldn't be looked up.
392 (if (and info-lookup-other-window-flag found
)
393 (select-window window
))))
395 (defun info-lookup-setup-mode (topic mode
)
396 "Initialize the internal data structure."
397 (or (info-lookup->initialized topic mode
)
398 (let (cell data
(initialized 0) completions refer-modes
)
399 (if (not (info-lookup->mode-value topic mode
))
400 (message "No %s help available for `%s'" topic mode
)
401 ;; Recursively setup cross references.
402 ;; But refer only to non-void modes.
403 (mapcar (lambda (arg)
404 (or (info-lookup->initialized topic arg
)
405 (info-lookup-setup-mode topic arg
))
406 (and (eq (info-lookup->initialized topic arg
) t
)
407 (setq refer-modes
(cons arg refer-modes
))))
408 (info-lookup->other-modes topic mode
))
409 (setq refer-modes
(nreverse refer-modes
))
410 ;; Build the full completion alist.
412 (nconc (condition-case nil
413 (info-lookup-make-completions topic mode
)
416 (mapcar (lambda (arg)
417 (info-lookup->completions topic arg
))
419 (setq initialized t
))
420 ;; Update `info-lookup-cache'.
421 (setq cell
(info-lookup->mode-cache topic mode
)
422 data
(list initialized completions refer-modes
))
424 (setcdr (info-lookup->cache topic
)
425 (cons (cons mode data
) (info-lookup->topic-cache topic
)))
429 (defun info-lookup-make-completions (topic mode
)
430 "Create a unique alist from all index entries."
431 (let ((doc-spec (info-lookup->doc-spec topic mode
))
432 (regexp (concat "^\\(" (info-lookup->regexp topic mode
)
433 "\\)\\([ \t].*\\)?$"))
434 node trans entry item prefix result doc-found
435 (buffer (get-buffer-create " temp-info-look")))
436 (with-current-buffer buffer
439 (setq node
(nth 0 (car doc-spec
))
440 trans
(cond ((eq (nth 1 (car doc-spec
)) nil
)
442 (if (string-match regexp arg
)
443 (match-string 1 arg
))))
444 ((stringp (nth 1 (car doc-spec
)))
445 (setq prefix
(nth 1 (car doc-spec
)))
447 (if (string-match "^\\([^: \t\n]+\\)" arg
)
448 (concat prefix
(match-string 1 arg
)))))
449 (t (nth 1 (car doc-spec
)))))
450 (with-current-buffer buffer
451 (message "Processing Info node `%s'..." node
)
452 (when (condition-case error-data
454 (Info-goto-node node
)
457 (message "Cannot access Info node `%s'" node
)
462 (goto-char (point-min))
463 (and (search-forward "\n* Menu:" nil t
)
464 (while (re-search-forward "\n\\* \\([^:\t\n]*\\):" nil t
)
465 (setq entry
(match-string 1)
466 item
(funcall trans entry
))
467 ;; `trans' can return nil if the regexp doesn't match.
469 ;; Sometimes there's more than one Menu:
470 (not (string= entry
"Menu")))
471 (and (info-lookup->ignore-case topic mode
)
472 (setq item
(downcase item
)))
473 (and (string-equal entry item
)
475 (and (or (assoc item result
)
476 (setq result
(cons (cons item entry
)
479 (message "Processing Info node `%s'...done" node
)
480 (setq doc-spec
(cdr doc-spec
)))
482 (error "Info documentation for lookup was not found"))
485 (defun info-lookup-guess-default (topic mode
)
486 "Return a guess for a symbol to look up, based on text around point.
487 Try all related modes applicable to TOPIC and MODE.
488 Return nil if there is nothing appropriate in the buffer near point."
489 (let ((modes (info-lookup->all-modes topic mode
))
491 (while (and (not guess
) modes
)
492 (setq guess
(info-lookup-guess-default* topic
(car modes
))
494 ;; Collapse whitespace characters.
497 (while (string-match "[ \t\n]+" guess pos
)
498 (setq pos
(1+ (match-beginning 0)))
499 (setq guess
(replace-match " " t t guess
)))))
502 (defun info-lookup-guess-default* (topic mode
)
503 (let ((case-fold-search (info-lookup->ignore-case topic mode
))
504 (rule (or (info-lookup->parse-rule topic mode
)
505 (info-lookup->regexp topic mode
)))
506 (start (point)) end regexp subexp result
)
509 (setq result
(funcall rule
))
511 (setq regexp
(car rule
)
515 ;; If at start of symbol, don't go back to end of previous one.
517 (looking-at "[ \t\n]"))
518 (skip-chars-backward " \t\n"))
520 (while (and (re-search-backward regexp nil t
)
522 (>= (match-end 0) end
))
523 (setq result
(match-string subexp
)))
527 (skip-chars-forward " \t\n")
528 (and (looking-at regexp
)
529 (setq result
(match-string subexp
)))))))
532 (defun info-lookup-guess-c-symbol ()
533 "Get the C symbol at point."
536 (skip-syntax-backward "w_")
537 (let ((start (point)) prefix name
)
538 ;; Test for a leading `struct', `union', or `enum' keyword
539 ;; but ignore names like `foo_struct'.
540 (setq prefix
(and (< (skip-chars-backward " \t\n") 0)
541 (< (skip-chars-backward "_a-zA-Z0-9") 0)
542 (looking-at "\\(struct\\|union\\|enum\\)\\s ")
543 (concat (match-string 1) " ")))
545 (and (looking-at "[_a-zA-Z][_a-zA-Z0-9]*")
546 (setq name
(match-string 0)))
547 ;; Caveat! Look forward if point is at `struct' etc.
549 (or (string-equal name
"struct")
550 (string-equal name
"union")
551 (string-equal name
"enum"))
552 (looking-at "[a-z]+\\s +\\([_a-zA-Z][_a-zA-Z0-9]*\\)")
553 (setq prefix
(concat name
" ")
554 name
(match-string 1)))
555 (and (or prefix name
)
556 (concat prefix name
))))
560 (defun info-complete-symbol (&optional mode
)
561 "Perform completion on symbol preceding point."
563 (info-complete 'symbol
565 (if (info-lookup->mode-value
566 'symbol
(info-lookup-select-mode))
568 (info-lookup-change-mode 'symbol
)))))
571 (defun info-complete-file (&optional mode
)
572 "Perform completion on file preceding point."
576 (if (info-lookup->mode-value
577 'file
(info-lookup-select-mode))
579 (info-lookup-change-mode 'file
)))))
581 (defun info-complete (topic mode
)
582 "Try to complete a help item."
583 (barf-if-buffer-read-only)
584 (or mode
(setq mode
(info-lookup-select-mode)))
585 (or (info-lookup->mode-value topic mode
)
586 (error "No %s completion available for `%s'" topic mode
))
587 (let ((modes (info-lookup-quick-all-modes topic mode
))
590 (while (and (not try
) modes
)
591 (setq mode
(car modes
)
593 try
(info-lookup-guess-default* topic mode
))
596 (error "Found no %S to complete" topic
))
597 (let ((completions (info-lookup->completions topic mode
))
598 (completion-ignore-case (info-lookup->ignore-case topic mode
))
600 (setq completion
(try-completion try completions
))
601 (cond ((not completion
)
603 (message "No match"))
604 ((stringp completion
)
605 (or (assoc completion completions
)
606 (setq completion
(completing-read
607 (format "Complete %S: " topic
)
608 completions nil t completion
609 info-lookup-history
)))
610 ;; Find the original symbol and zap it.
612 (while (and (search-backward try nil t
)
617 (message "%s is complete"
618 (capitalize (prin1-to-string topic
))))))))
621 ;;; Initialize some common modes.
623 (info-lookup-maybe-add-help
624 :mode
'c-mode
:topic
'symbol
625 :regexp
"\\(struct \\|union \\|enum \\)?[_a-zA-Z][_a-zA-Z0-9]*"
626 :doc-spec
'(("(libc)Function Index" nil
627 "^[ \t]+- \\(Function\\|Macro\\): .*\\<" "\\>")
628 ("(libc)Variable Index" nil
629 "^[ \t]+- \\(Variable\\|Macro\\): .*\\<" "\\>")
630 ("(libc)Type Index" nil
631 "^[ \t]+- Data Type: \\<" "\\>")
632 ("(termcap)Var Index" nil
634 :parse-rule
'info-lookup-guess-c-symbol
)
636 (info-lookup-maybe-add-help
637 :mode
'c-mode
:topic
'file
638 :regexp
"[_a-zA-Z0-9./+-]+"
639 :doc-spec
'(("(libc)File Index")))
641 (info-lookup-maybe-add-help
643 :regexp
"[:;|]\\|%\\([%{}]\\|[_a-z]+\\)\\|YY[_A-Z]+\\|yy[_a-z]+"
644 :doc-spec
'(("(bison)Index" nil
646 :parse-rule
"[:;|]\\|%\\([%{}]\\|[_a-zA-Z][_a-zA-Z0-9]*\\)"
647 :other-modes
'(c-mode))
649 (info-lookup-maybe-add-help
651 :regexp
"\\$[^({]\\|\\.[_A-Z]*\\|[_a-zA-Z][_a-zA-Z0-9-]*"
652 :doc-spec
'(("(make)Name Index" nil
654 :parse-rule
"\\$[^({]\\|\\.[_A-Z]*\\|[_a-zA-Z0-9-]+")
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)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-zA-Z]\\)"
733 :doc-spec
'(("(latex)Command Index" nil
734 "`" "\\({[^}]*}\\)?'")))
736 (info-lookup-maybe-add-help
737 :mode
'emacs-lisp-mode
738 :regexp
"[^()' \t\n]+"
739 :doc-spec
'(("(emacs)Command Index")
740 ("(emacs)Variable Index")
743 (let ((sym (intern-soft item
)))
745 (if (string-equal item
"nil") item
))
746 ((or (boundp sym
) (fboundp sym
))
748 "^[ \t]+- [^:]+:[ \t]*" "\\b")))
750 (info-lookup-maybe-add-help
751 :mode
'lisp-interaction-mode
752 :regexp
"[^()' \t\n]+"
754 :other-modes
'(emacs-lisp-mode))
756 (info-lookup-maybe-add-help
758 :regexp
"[^()' \t\n]+"
760 :other-modes
'(emacs-lisp-mode))
762 (info-lookup-maybe-add-help
764 :regexp
"[^()' \t\n]+"
766 ;; Aubrey Jaffer's rendition from <URL:ftp://ftp-swiss.ai.mit.edu/pub/scm>
767 :doc-spec
'(("(r5rs)Index" nil
768 "^[ \t]+- [^:]+:[ \t]*" "\\b")))
770 (info-lookup-maybe-add-help
772 :regexp
"[_a-zA-Z0-9]+"
773 :doc-spec
'(("(octave)Function Index" nil
774 "^ - [^:]+:[ ]+\\(\\[[^=]*=[ ]+\\)?" nil
)
775 ("(octave)Variable Index" nil
"^ - [^:]+:[ ]+" nil
)
776 ;; Catch lines of the form "xyz statement"
777 ("(octave)Concept Index"
780 ((string-match "^\\([A-Z]+\\) statement\\b" item
)
781 (match-string 1 item
))
783 nil
; "^ - [^:]+:[ ]+" don't think this prefix is useful here.
788 ;;; info-look.el ends here