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 Free Software Foundation, Inc.
6 ;; Author: Ralph Schleicher <rs@purple.UL.BaWue.DE>
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.
33 (defmacro defgroup
(&rest arg
)
35 (defmacro defcustom
(symbol value doc
&rest arg
)
36 `(defvar ,symbol
,value
,doc
,@arg
)))))
38 (defgroup info-lookup nil
39 "Major mode sensitive help agent."
40 :group
'help
:group
'languages
)
42 (defvar info-lookup-mode nil
43 "Symbol of the current buffer's help mode.
44 Help is provided according to the buffer's major mode if value is nil.
45 Automatically becomes buffer local when set in any fashion.")
46 (make-variable-buffer-local 'info-lookup-mode
)
48 (defcustom info-lookup-other-window-flag t
49 "Non-nil means pop up the Info buffer in another window."
50 :group
'info-lookup
:type
'boolean
)
52 (defcustom info-lookup-highlight-face
'highlight
53 "Face for highlighting looked up help items.
54 Setting this variable to nil disables highlighting."
55 :group
'info-lookup
:type
'face
)
57 (defvar info-lookup-highlight-overlay nil
58 "Overlay object used for highlighting.")
60 (defcustom info-lookup-file-name-alist
61 '(("\\`configure\\.in\\'" . autoconf-mode
)
62 ("\\`aclocal\\.m4\\'" . autoconf-mode
)
63 ("\\`acsite\\.m4\\'" . autoconf-mode
)
64 ("\\`acinclude\\.m4\\'" . autoconf-mode
))
65 "Alist of file names handled specially.
66 List elements are cons cells of the form
70 If a file name matches REGEXP, then use help mode MODE instead of the
72 :group
'info-lookup
:type
'(repeat (cons (string :tag
"Regexp")
73 (symbol :tag
"Mode"))))
75 (defvar info-lookup-history nil
76 "History of previous input lines.")
78 (defvar info-lookup-alist nil
79 "Alist of known help topics.
80 Cons cells are of the form
82 (HELP-TOPIC . HELP-DATA)
84 HELP-TOPIC is the symbol of a help topic.
85 HELP-DATA is a HELP-TOPIC's public data set.
86 Value is an alist with elements of the form
88 (HELP-MODE REGEXP IGNORE-CASE DOC-SPEC PARSE-RULE OTHER-MODES)
90 HELP-MODE is a mode's symbol.
91 REGEXP is a regular expression matching those help items whose
92 documentation can be looked up via DOC-SPEC.
93 IGNORE-CASE is non-nil if help items are case insensitive.
94 DOC-SPEC is a list of documentation specifications of the form
96 (INFO-NODE TRANS-FUNC PREFIX SUFFIX)
98 INFO-NODE is the name (including file name part) of an Info index.
99 TRANS-FUNC is a function translating index entries into help items;
100 nil means add only those index entries matching REGEXP, a string
101 means prepend string to the first word of all index entries.
102 PREFIX and SUFFIX are parts of a regular expression. If one of
103 them is non-nil then search the help item's Info node for the
104 first occurrence of the regular expression `PREFIX ITEM SUFFIX'.
105 ITEM will be highlighted with `info-lookup-highlight-face' if this
107 PARSE-RULE is either the symbol name of a function or a regular
108 expression for guessing the default help item at point. Fuzzy
109 regular expressions like \"[_a-zA-Z0-9]+\" do a better job if
110 there are no clear delimiters; do not try to write too complex
111 expressions. PARSE-RULE defaults to REGEXP.
112 OTHER-MODES is a list of cross references to other help modes.")
114 (defsubst info-lookup-
>topic-value
(topic)
115 (cdr (assoc topic info-lookup-alist
)))
117 (defsubst info-lookup-
>mode-value
(topic mode
)
118 (assoc mode
(info-lookup->topic-value topic
)))
120 (defsubst info-lookup-
>regexp
(topic mode
)
121 (nth 1 (info-lookup->mode-value topic mode
)))
123 (defsubst info-lookup-
>ignore-case
(topic mode
)
124 (nth 2 (info-lookup->mode-value topic mode
)))
126 (defsubst info-lookup-
>doc-spec
(topic mode
)
127 (nth 3 (info-lookup->mode-value topic mode
)))
129 (defsubst info-lookup-
>parse-rule
(topic mode
)
130 (nth 4 (info-lookup->mode-value topic mode
)))
132 (defsubst info-lookup-
>other-modes
(topic mode
)
133 (nth 5 (info-lookup->mode-value topic mode
)))
136 (mapcar (lambda (keyword)
138 (set keyword keyword
)))
139 '(:topic
:mode
:regexp
:ignore-case
140 :doc-spec
:parse-rule
:other-modes
)))
142 (defun info-lookup-add-help (&rest arg
)
143 "Add or update a help specification.
144 Function arguments are one or more options of the form
148 KEYWORD is either `:topic', `:mode', `:regexp', `:ignore-case',
149 `:doc-spec', `:parse-rule', or `:other-modes'.
150 ARGUMENT has a value as explained in the documentation of the
151 variable `info-lookup-alist'.
153 If no topic or mode option has been specified, then the help topic defaults
154 to `symbol', and the help mode defaults to the current major mode."
155 (apply 'info-lookup-add-help
* nil arg
))
157 (defun info-lookup-maybe-add-help (&rest arg
)
158 "Add a help specification iff no one is defined.
159 See the documentation of the function `info-lookup-add-help'
161 (apply 'info-lookup-add-help
* t arg
))
163 (defun info-lookup-add-help* (maybe &rest arg
)
164 (let (topic mode regexp ignore-case doc-spec
165 parse-rule other-modes keyword value
)
170 (setq keyword
(car arg
))
171 (or (symbolp keyword
)
172 (error "Junk in argument list \"%S\"" arg
))
175 (error "Keyword \"%S\" is missing an argument" keyword
))
176 (setq value
(car arg
)
178 (cond ((eq keyword
:topic
)
182 ((eq keyword
:regexp
)
184 ((eq keyword
:ignore-case
)
185 (setq ignore-case value
))
186 ((eq keyword
:doc-spec
)
187 (setq doc-spec value
))
188 ((eq keyword
:parse-rule
)
189 (setq parse-rule value
))
190 ((eq keyword
:other-modes
)
191 (setq other-modes value
))
193 (error "Unknown keyword \"%S\"" keyword
))))
194 (or (and maybe
(info-lookup->mode-value topic mode
))
195 (let* ((data (list regexp ignore-case doc-spec parse-rule other-modes
))
196 (topic-cell (or (assoc topic info-lookup-alist
)
197 (car (setq info-lookup-alist
198 (cons (cons topic nil
)
199 info-lookup-alist
)))))
200 (mode-cell (assoc mode topic-cell
)))
202 (setcdr topic-cell
(cons (cons mode data
) (cdr topic-cell
)))
203 (setcdr mode-cell data
))))
206 (defvar info-lookup-cache nil
207 "Cache storing data maintained automatically by the program.
208 Value is an alist with cons cell of the form
210 (HELP-TOPIC . ((HELP-MODE INITIALIZED COMPLETIONS REFER-MODES) ...))
212 HELP-TOPIC is the symbol of a help topic.
213 HELP-MODE is a mode's symbol.
214 INITIALIZED is nil if HELP-MODE is uninitialized, t if
215 HELP-MODE is initialized, and `0' means HELP-MODE is
216 initialized but void.
217 COMPLETIONS is an alist of documented help items.
218 REFER-MODES is a list of other help modes to use.")
220 (defsubst info-lookup-
>cache
(topic)
221 (or (assoc topic info-lookup-cache
)
222 (car (setq info-lookup-cache
223 (cons (cons topic nil
)
224 info-lookup-cache
)))))
226 (defun info-lookup->topic-cache
(topic)
227 (cdr (info-lookup->cache topic
)))
229 (defun info-lookup->mode-cache
(topic mode
)
230 (assoc mode
(info-lookup->topic-cache topic
)))
232 (defun info-lookup->initialized
(topic mode
)
233 (nth 1 (info-lookup->mode-cache topic mode
)))
235 (defun info-lookup->completions
(topic mode
)
236 (or (info-lookup->initialized topic mode
)
237 (info-lookup-setup-mode topic mode
))
238 (nth 2 (info-lookup->mode-cache topic mode
)))
240 (defun info-lookup->refer-modes
(topic mode
)
241 (or (info-lookup->initialized topic mode
)
242 (info-lookup-setup-mode topic mode
))
243 (nth 3 (info-lookup->mode-cache topic mode
)))
245 (defun info-lookup->all-modes
(topic mode
)
246 (cons mode
(info-lookup->refer-modes topic mode
)))
248 (defun info-lookup-quick-all-modes (topic mode
)
249 (cons mode
(info-lookup->other-modes topic mode
)))
252 (defun info-lookup-reset ()
253 "Throw away all cached data.
254 This command is useful if the user wants to start at the beginning without
255 quitting Emacs, for example, after some Info documents were updated on the
258 (setq info-lookup-cache nil
))
261 (defun info-lookup-symbol (symbol &optional mode
)
262 "Display the documentation of a symbol.
263 If called interactively, SYMBOL will be read from the mini-buffer.
264 Prefix argument means unconditionally insert the default symbol name
265 into the mini-buffer so that it can be edited.
266 The default symbol is the one found at point."
268 (info-lookup-interactive-arguments 'symbol
))
269 (info-lookup 'symbol symbol mode
))
272 (defun info-lookup-file (file &optional mode
)
273 "Display the documentation of a file.
274 If called interactively, FILE will be read from the mini-buffer.
275 Prefix argument means unconditionally insert the default file name
276 into the mini-buffer so that it can be edited.
277 The default file name is the one found at point."
279 (info-lookup-interactive-arguments 'file
))
280 (info-lookup 'file file mode
))
282 (defun info-lookup-interactive-arguments (topic)
283 "Return default value and help mode for help topic TOPIC."
284 (let* ((mode (if (info-lookup->mode-value topic
(info-lookup-select-mode))
286 (info-lookup-change-mode topic
)))
287 (completions (info-lookup->completions topic mode
))
288 (default (info-lookup-guess-default topic mode
))
289 (input (if (or current-prefix-arg
(not (assoc default completions
)))
291 (completion-ignore-case (info-lookup->ignore-case topic mode
))
292 (enable-recursive-minibuffers t
)
293 (value (completing-read
294 (if (and default
(not input
))
295 (format "Describe %s (default %s): " topic default
)
296 (format "Describe %s: " topic
))
297 completions nil nil input
'info-lookup-history
)))
298 (list (if (equal value
"") default value
) mode
)))
300 (defun info-lookup-select-mode ()
301 (when (and (not info-lookup-mode
) (buffer-file-name))
302 (let ((file-name (file-name-nondirectory (buffer-file-name)))
303 (file-name-alist info-lookup-file-name-alist
))
304 (while (and (not info-lookup-mode
) file-name-alist
)
305 (when (string-match (caar file-name-alist
) file-name
)
306 (setq info-lookup-mode
(cdar file-name-alist
)))
307 (setq file-name-alist
(cdr file-name-alist
)))))
308 (or info-lookup-mode
(setq info-lookup-mode major-mode
)))
310 (defun info-lookup-change-mode (topic)
311 (let* ((completions (mapcar (lambda (arg)
312 (cons (symbol-name (car arg
)) (car arg
)))
313 (info-lookup->topic-value topic
)))
314 (mode (completing-read
315 (format "Use %s help mode: " topic
)
316 completions nil t nil
'info-lookup-history
)))
317 (or (setq mode
(cdr (assoc mode completions
)))
318 (error "No %s help available" topic
))
319 (or (info-lookup->mode-value topic mode
)
320 (error "No %s help available for `%s'" topic mode
))
321 (setq info-lookup-mode mode
)))
323 (defun info-lookup (topic item mode
)
324 "Display the documentation of a help item."
325 (or mode
(setq mode
(info-lookup-select-mode)))
326 (or (info-lookup->mode-value topic mode
)
327 (error "No %s help available for `%s'" topic mode
))
328 (let ((entry (or (assoc (if (info-lookup->ignore-case topic mode
)
329 (downcase item
) item
)
330 (info-lookup->completions topic mode
))
331 (error "Not documented as a %s: %s" topic
(or item
""))))
332 (modes (info-lookup->all-modes topic mode
))
333 (window (selected-window))
334 found doc-spec node prefix suffix doc-found
)
335 (if (not info-lookup-other-window-flag
)
337 (save-window-excursion (info))
338 (switch-to-buffer-other-window "*info*"))
339 (while (and (not found
) modes
)
340 (setq doc-spec
(info-lookup->doc-spec topic
(car modes
)))
341 (while (and (not found
) doc-spec
)
342 (setq node
(nth 0 (car doc-spec
))
343 prefix
(nth 2 (car doc-spec
))
344 suffix
(nth 3 (car doc-spec
)))
345 (when (condition-case error-data
347 (Info-goto-node node
)
350 (message "Cannot access Info node %s" node
)
355 (Info-menu (or (cdr entry
) item
))
357 (if (or prefix suffix
)
358 (let ((case-fold-search
359 (info-lookup->ignore-case topic
(car modes
)))
360 (buffer-read-only nil
))
361 (goto-char (point-min))
363 (concat prefix
(regexp-quote item
) suffix
))
364 (goto-char (match-beginning 0))
365 (and window-system info-lookup-highlight-face
366 ;; Search again for ITEM so that the first
367 ;; occurence of ITEM will be highlighted.
368 (re-search-forward (regexp-quote item
))
369 (let ((start (match-beginning 0))
371 (if (overlayp info-lookup-highlight-overlay
)
372 (move-overlay info-lookup-highlight-overlay
373 start end
(current-buffer))
374 (setq info-lookup-highlight-overlay
375 (make-overlay start end
))))
376 (overlay-put info-lookup-highlight-overlay
377 'face info-lookup-highlight-face
)))))
379 (setq doc-spec
(cdr doc-spec
)))
380 (setq modes
(cdr modes
)))
382 (error "Info documentation for lookup was not found"))
383 ;; Don't leave the Info buffer if the help item couldn't be looked up.
384 (if (and info-lookup-other-window-flag found
)
385 (select-window window
))))
387 (defun info-lookup-setup-mode (topic mode
)
388 "Initialize the internal data structure."
389 (or (info-lookup->initialized topic mode
)
390 (let (cell data
(initialized 0) completions refer-modes
)
391 (if (not (info-lookup->mode-value topic mode
))
392 (message "No %s help available for `%s'" topic mode
)
393 ;; Recursively setup cross references.
394 ;; But refer only to non-void modes.
395 (mapcar (lambda (arg)
396 (or (info-lookup->initialized topic arg
)
397 (info-lookup-setup-mode topic arg
))
398 (and (eq (info-lookup->initialized topic arg
) t
)
399 (setq refer-modes
(cons arg refer-modes
))))
400 (info-lookup->other-modes topic mode
))
401 (setq refer-modes
(nreverse refer-modes
))
402 ;; Build the full completion alist.
404 (nconc (info-lookup-make-completions topic mode
)
406 (mapcar (lambda (arg)
407 (info-lookup->completions topic arg
))
409 (setq initialized t
))
410 ;; Update `info-lookup-cache'.
411 (setq cell
(info-lookup->mode-cache topic mode
)
412 data
(list initialized completions refer-modes
))
414 (setcdr (info-lookup->cache topic
)
415 (cons (cons mode data
) (info-lookup->topic-cache topic
)))
419 (defun info-lookup-make-completions (topic mode
)
420 "Create a unique alist from all index entries."
421 (let ((doc-spec (info-lookup->doc-spec topic mode
))
422 (regexp (concat "^\\(" (info-lookup->regexp topic mode
)
423 "\\)\\([ \t].*\\)?$"))
424 node trans entry item prefix result doc-found
425 (buffer (get-buffer-create " temp-info-look")))
426 (with-current-buffer buffer
429 (setq node
(nth 0 (car doc-spec
))
430 trans
(cond ((eq (nth 1 (car doc-spec
)) nil
)
432 (if (string-match regexp arg
)
433 (match-string 1 arg
))))
434 ((stringp (nth 1 (car doc-spec
)))
435 (setq prefix
(nth 1 (car doc-spec
)))
437 (if (string-match "^\\([^: \t\n]+\\)" arg
)
438 (concat prefix
(match-string 1 arg
)))))
439 (t (nth 1 (car doc-spec
)))))
440 (with-current-buffer buffer
441 (message "Processing Info node `%s'..." node
)
442 (when (condition-case error-data
444 (Info-goto-node node
)
447 (message "Cannot access Info node `%s'" node
)
452 (goto-char (point-min))
453 (and (search-forward "\n* Menu:" nil t
)
454 (while (re-search-forward "\n\\* \\([^:\t\n]*\\):" nil t
)
455 (setq entry
(match-string 1)
456 item
(funcall trans entry
))
457 (and (info-lookup->ignore-case topic mode
)
458 (setq item
(downcase item
)))
459 (and (string-equal entry item
)
461 (or (assoc item result
)
462 (setq result
(cons (cons item entry
) result
))))))
464 (message "Processing Info node `%s'...done" node
)
465 (setq doc-spec
(cdr doc-spec
)))
467 (error "Info documentation for lookup was not found"))
470 (defun info-lookup-guess-default (topic mode
)
471 "Pick up default item at point (with favor to look back).
472 Return nil if there is nothing appropriate."
473 (let ((modes (info-lookup->all-modes topic mode
))
474 (start (point)) guess whitespace
)
475 (while (and (not guess
) modes
)
476 (setq guess
(info-lookup-guess-default* topic
(car modes
))
479 ;; Collapse whitespace characters.
480 (and guess
(concat (delete nil
(mapcar (lambda (ch)
481 (if (or (char-equal ch ?
)
485 (setq whitespace ?
))
486 (setq whitespace nil
) ch
))
489 (defun info-lookup-guess-default* (topic mode
)
490 (let ((case-fold-search (info-lookup->ignore-case topic mode
))
491 (rule (or (info-lookup->parse-rule topic mode
)
492 (info-lookup->regexp topic mode
)))
493 (start (point)) end regexp subexp result
)
495 (setq result
(funcall rule
))
497 (setq regexp
(car rule
)
501 (skip-chars-backward " \t\n") (setq end
(point))
502 (while (and (re-search-backward regexp nil t
)
504 (>= (match-end 0) end
))
505 (setq result
(match-string subexp
)))
509 (skip-chars-forward " \t\n")
510 (and (looking-at regexp
)
511 (setq result
(match-string subexp
))))))
514 (defun info-lookup-guess-c-symbol ()
515 "Get the C symbol at point."
519 (let ((start (point)) prefix name
)
520 ;; Test for a leading `struct', `union', or `enum' keyword
521 ;; but ignore names like `foo_struct'.
522 (setq prefix
(and (< (skip-chars-backward " \t\n") 0)
523 (< (skip-chars-backward "_a-zA-Z0-9") 0)
524 (looking-at "\\(struct\\|union\\|enum\\)\\s ")
525 (concat (match-string 1) " ")))
527 (and (looking-at "[_a-zA-Z][_a-zA-Z0-9]*")
528 (setq name
(match-string 0)))
529 ;; Caveat! Look forward if point is at `struct' etc.
531 (or (string-equal name
"struct")
532 (string-equal name
"union")
533 (string-equal name
"enum"))
534 (looking-at "[a-z]+\\s +\\([_a-zA-Z][_a-zA-Z0-9]*\\)")
535 (setq prefix
(concat name
" ")
536 name
(match-string 1)))
537 (and (or prefix name
)
538 (concat prefix name
))))
542 (defun info-complete-symbol (&optional mode
)
543 "Perform completion on symbol preceding point."
545 (info-complete 'symbol
547 (if (info-lookup->mode-value
548 'symbol
(info-lookup-select-mode))
550 (info-lookup-change-mode 'symbol
)))))
553 (defun info-complete-file (&optional mode
)
554 "Perform completion on file preceding point."
558 (if (info-lookup->mode-value
559 'file
(info-lookup-select-mode))
561 (info-lookup-change-mode 'file
)))))
563 (defun info-complete (topic mode
)
564 "Try to complete a help item."
565 (barf-if-buffer-read-only)
566 (or mode
(setq mode
(info-lookup-select-mode)))
567 (or (info-lookup->mode-value topic mode
)
568 (error "No %s completion available for `%s'" topic mode
))
569 (let ((modes (info-lookup-quick-all-modes topic mode
))
572 (while (and (not try
) modes
)
573 (setq mode
(car modes
)
575 try
(info-lookup-guess-default* topic mode
))
578 (error "Found no %S to complete" topic
))
579 (let ((completions (info-lookup->completions topic mode
))
580 (completion-ignore-case (info-lookup->ignore-case topic mode
))
582 (setq completion
(try-completion try completions
))
583 (cond ((not completion
)
585 (message "No match"))
586 ((stringp completion
)
587 (or (assoc completion completions
)
588 (setq completion
(completing-read
589 (format "Complete %S: " topic
)
590 completions nil t completion
591 info-lookup-history
)))
592 (delete-region (- start
(length try
)) start
)
595 (message "%s is complete"
596 (capitalize (prin1-to-string topic
))))))))
599 ;;; Initialize some common modes.
601 (info-lookup-maybe-add-help
602 :mode
'c-mode
:topic
'symbol
603 :regexp
"\\(struct \\|union \\|enum \\)?[_a-zA-Z][_a-zA-Z0-9]*"
604 :doc-spec
'(("(libc)Function Index" nil
605 "^[ \t]+- \\(Function\\|Macro\\): .*\\<" "\\>")
606 ("(libc)Variable Index" nil
607 "^[ \t]+- \\(Variable\\|Macro\\): .*\\<" "\\>")
608 ("(libc)Type Index" nil
609 "^[ \t]+- Data Type: \\<" "\\>")
610 ("(termcap)Var Index" nil
612 :parse-rule
'info-lookup-guess-c-symbol
)
614 (info-lookup-maybe-add-help
615 :mode
'c-mode
:topic
'file
616 :regexp
"[_a-zA-Z0-9./+-]+"
617 :doc-spec
'(("(libc)File Index")))
619 (info-lookup-maybe-add-help
621 :regexp
"[:;|]\\|%\\([%{}]\\|[_a-z]+\\)\\|YY[_A-Z]+\\|yy[_a-z]+"
622 :doc-spec
'(("(bison)Index" nil
624 :parse-rule
"[:;|]\\|%\\([%{}]\\|[_a-zA-Z][_a-zA-Z0-9]*\\)"
625 :other-modes
'(c-mode))
627 (info-lookup-maybe-add-help
629 :regexp
"\\$[^({]\\|\\.[_A-Z]*\\|[_a-zA-Z][_a-zA-Z0-9-]*"
630 :doc-spec
'(("(make)Name Index" nil
632 :parse-rule
"\\$[^({]\\|\\.[_A-Z]*\\|[_a-zA-Z0-9-]+")
634 (info-lookup-maybe-add-help
636 :regexp
"@\\([a-zA-Z]+\\|[^a-zA-Z]\\)"
637 :doc-spec
'(("(texinfo)Command and Variable Index"
638 ;; Ignore Emacs commands and prepend a `@'.
640 (if (string-match "^\\([a-zA-Z]+\\|[^a-zA-Z]\\)\\( .*\\)?$" item
)
641 (concat "@" (match-string 1 item
))))
644 (info-lookup-maybe-add-help
646 :regexp
"[_a-zA-Z][_a-zA-Z0-9]*"
647 :doc-spec
'(("(m4)Macro index"))
648 :parse-rule
"[_a-zA-Z0-9]+")
650 (info-lookup-maybe-add-help
652 :regexp
"A[CM]_[_A-Z0-9]+"
653 :doc-spec
'(("(autoconf)Macro Index" "AC_"
654 "^[ \t]+- \\(Macro\\|Variable\\): .*\\<" "\\>")
655 ("(automake)Index" nil
657 ;; Autoconf symbols are M4 macros. Thus use M4's parser.
659 :other-modes
'(m4-mode))
661 (info-lookup-maybe-add-help
664 :doc-spec
'(("(gawk)Index"
666 (let ((case-fold-search nil
))
668 ;; `BEGIN' and `END'.
669 ((string-match "^\\([A-Z]+\\) special pattern\\b" item
)
670 (match-string 1 item
))
671 ;; `if', `while', `do', ...
672 ((string-match "^\\([a-z]+\\) statement\\b" item
)
673 (if (not (string-equal (match-string 1 item
) "control"))
674 (match-string 1 item
)))
676 ((string-match "^[A-Z]+$" item
)
678 ;; Built-in functions (matches to many entries).
679 ((string-match "^[a-z]+$" item
)
681 "`" "\\([ \t]*([^)]*)\\)?'")))
683 (info-lookup-maybe-add-help
685 :regexp
"[$@%][^a-zA-Z]\\|\\$\\^[A-Z]\\|[$@%]?[a-zA-Z][_a-zA-Z0-9]*"
686 :doc-spec
'(("(perl5)Function Index"
688 (if (string-match "^\\([a-zA-Z0-9]+\\)" item
)
689 (match-string 1 item
)))
691 ("(perl5)Variable Index"
693 ;; Work around bad formatted array variables.
694 (let ((sym (cond ((or (string-match "^\\$\\(.\\|@@\\)$" item
)
695 (string-match "^\\$\\^[A-Z]$" item
))
698 "^\\([$%@]\\|@@\\)?[_a-zA-Z0-9]+" item
)
699 (match-string 0 item
))
701 (if (string-match "@@" sym
)
702 (setq sym
(concat (substring sym
0 (match-beginning 0))
703 (substring sym
(1- (match-end 0))))))
704 (if (string-equal sym
"") nil sym
)))
706 :parse-rule
"[$@%]?\\([_a-zA-Z0-9]+\\|[^a-zA-Z]\\)")
708 (info-lookup-maybe-add-help
710 :regexp
"\\\\\\([a-zA-Z]+\\|[^a-zA-Z]\\)"
711 :doc-spec
'(("(latex2e)Command Index" nil
712 "`" "\\({[^}]*}\\)?'")))
714 (info-lookup-maybe-add-help
716 :regexp
;; "\\(\\sw\\|\\s_\\)+"
719 ;; Aubrey Jaffer's rendition from <URL:ftp://ftp-swiss.ai.mit.edu/pub/scm>
720 :doc-spec
'(("(r5rs)Index")))
722 (info-lookup-maybe-add-help
723 :mode
'emacs-lisp-mode
724 :regexp
"[^()' \t\n]+"
725 :doc-spec
'(("(emacs)Command Index")
726 ("(emacs)Variable Index")
729 (let ((sym (intern-soft item
)))
731 (if (string-equal item
"nil") item
))
732 ((or (boundp sym
) (fboundp sym
))
734 "^[ \t]+- [^:]+:[ \t]*" "\\b")))
736 (info-lookup-maybe-add-help
737 :mode
'lisp-interaction-mode
738 :regexp
"[^()' \t\n]+"
740 :other-modes
'(emacs-lisp-mode))
742 (info-lookup-maybe-add-help
744 :regexp
"[^()' \t\n]+"
746 :other-modes
'(emacs-lisp-mode))
748 (info-lookup-maybe-add-help
750 :regexp
"[^()' \t\n]+"
752 :doc-spec
'(("(r5rs)Index" nil
753 "^[ \t]+- [^:]+:[ \t]*" "\\b")))
758 ;;; info-look.el ends here