annotate lisp/info-look.el @ 20455:aff2a2638ef4

(GROW_FAIL_STACK): Fix test for stack size at max.
author Karl Heuer <kwzh@gnu.org>
date Thu, 11 Dec 1997 07:21:05 +0000
parents 64d728fb396a
children c7b3ef0ed1ad
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18322
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 ;;; info-look.el --- major-mode-sensitive Info index lookup facility.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2 ;; An older version of this was known as libc.el.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4 ;; Copyright (C) 1995, 1996, 1997 Ralph Schleicher.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 ;; Author: Ralph Schleicher <rs@purple.UL.BaWue.DE>
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 ;; Keywords: help languages
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;; any later version.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; GNU General Public License for more details.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;; Boston, MA 02111-1307, USA.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 ;;; Code:
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 (require 'info)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 (defvar info-lookup-mode nil
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 "*Symbol of the current buffer's help mode.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 Provide help according to the buffer's major mode if value is nil.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 Automatically becomes buffer local when set in any fashion.")
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 (make-variable-buffer-local 'info-lookup-mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 (defvar info-lookup-other-window-flag t
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 "*Non-nil means pop up the Info buffer in another window.")
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 (defvar info-lookup-highlight-face 'highlight
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 "*Face for highlighting looked up help items.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 Setting this variable to nil disables highlighting.")
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 (defvar info-lookup-highlight-overlay nil
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 "Overlay object used for highlighting.")
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 (defvar info-lookup-history nil
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 "History of previous input lines.")
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 (defvar info-lookup-alist '((symbol . info-lookup-symbol-alist)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 (file . info-lookup-file-alist))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 "*Alist of known help topics.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 Cons cells are of the form
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 (HELP-TOPIC . VARIABLE)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 HELP-TOPIC is the symbol of a help topic.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 VARIABLE is a variable storing HELP-TOPIC's public data.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 Value is an alist with elements of the form
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 (HELP-MODE REGEXP IGNORE-CASE DOC-SPEC PARSE-RULE OTHER-MODES)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 HELP-MODE is a mode's symbol.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 REGEXP is a regular expression matching those help items whose
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 documentation can be looked up via DOC-SPEC.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 IGNORE-CASE is non-nil if help items are case insensitive.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 DOC-SPEC is a list of documentation specifications of the form
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 (INFO-NODE TRANS-FUNC PREFIX SUFFIX)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 INFO-NODE is the name (including file name part) of an Info index.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 TRANS-FUNC is a function translating index entries into help items;
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 nil means add only those index entries matching REGEXP, a string
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 means prepend string to the first word of all index entries.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 PREFIX and SUFFIX are parts of a regular expression. If one of
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 them is non-nil then search the help item's Info node for the
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 first occurrence of the regular expression `PREFIX ITEM SUFFIX'.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 ITEM will be highlighted with `info-lookup-highlight-face' if this
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 variable is not nil.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 PARSE-RULE is either the symbol name of a function or a regular
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 expression for guessing the default help item at point. Fuzzy
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 regular expressions like \"[_a-zA-Z0-9]+\" do a better job if
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 there are no clear delimiters; do not try to write too complex
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 expressions. PARSE-RULE defaults to REGEXP.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 OTHER-MODES is a list of cross references to other help modes.")
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 (defsubst info-lookup->topic-value (topic)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 (symbol-value (cdr (assoc topic info-lookup-alist))))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 (defsubst info-lookup->mode-value (topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 (assoc mode (info-lookup->topic-value topic)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 (defsubst info-lookup->regexp (topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 (nth 1 (info-lookup->mode-value topic mode)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 (defsubst info-lookup->ignore-case (topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 (nth 2 (info-lookup->mode-value topic mode)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 (defsubst info-lookup->doc-spec (topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 (nth 3 (info-lookup->mode-value topic mode)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 (defsubst info-lookup->parse-rule (topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 (nth 4 (info-lookup->mode-value topic mode)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 (defsubst info-lookup->other-modes (topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 (nth 5 (info-lookup->mode-value topic mode)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 (defvar info-lookup-cache nil
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 "Cache storing data maintained automatically by the program.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 Value is an alist with cons cell of the form
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 (HELP-TOPIC . ((HELP-MODE INITIALIZED COMPLETIONS REFER-MODES) ...))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 HELP-TOPIC is the symbol of a help topic.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 HELP-MODE is a mode's symbol.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 INITIALIZED is nil if HELP-MODE is uninitialized, t if
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 HELP-MODE is initialized, and `0' means HELP-MODE is
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 initialized but void.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 COMPLETIONS is an alist of documented help items.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 REFER-MODES is a list of other help modes to use.")
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 (defsubst info-lookup->cache (topic)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 (or (assoc topic info-lookup-cache)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 (car (setq info-lookup-cache
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 (cons (cons topic nil)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 info-lookup-cache)))))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 (defsubst info-lookup->topic-cache (topic)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 (cdr (info-lookup->cache topic)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 (defsubst info-lookup->mode-cache (topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 (assoc mode (info-lookup->topic-cache topic)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 (defsubst info-lookup->initialized (topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 (nth 1 (info-lookup->mode-cache topic mode)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 (defsubst info-lookup->completions (topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 (or (info-lookup->initialized topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 (info-lookup-setup-mode topic mode))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 (nth 2 (info-lookup->mode-cache topic mode)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 (defsubst info-lookup->refer-modes (topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 (or (info-lookup->initialized topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 (info-lookup-setup-mode topic mode))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 (nth 3 (info-lookup->mode-cache topic mode)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 (defsubst info-lookup->all-modes (topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 (cons mode (info-lookup->refer-modes topic mode)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 (defvar info-lookup-symbol-alist
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 '((autoconf-mode
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 "A[CM]_[_A-Z0-9]+" nil
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 (("(autoconf)Macro Index" "AC_"
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 "^[ \t]+- \\(Macro\\|Variable\\): .*\\<" "\\>")
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 ("(automake)Index" nil
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 "^[ \t]*`" "'"))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156 ;; Autoconf symbols are M4 macros. Thus use M4's parser.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 ignore
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 (m4-mode))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 (bison-mode
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160 "[:;|]\\|%\\([%{}]\\|[_a-z]+\\)\\|YY[_A-Z]+\\|yy[_a-z]+" nil
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 (("(bison)Index" nil
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162 "`" "'"))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163 "[:;|]\\|%\\([%{}]\\|[_a-zA-Z][_a-zA-Z0-9]*\\)"
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 (c-mode))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 (c-mode
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 "\\(struct \\|union \\|enum \\)?[_a-zA-Z][_a-zA-Z0-9]*" nil
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167 (("(libc)Function Index" nil
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 "^[ \t]+- \\(Function\\|Macro\\): .*\\<" "\\>")
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169 ("(libc)Variable Index" nil
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 "^[ \t]+- \\(Variable\\|Macro\\): .*\\<" "\\>")
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 ("(libc)Type Index" nil
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172 "^[ \t]+- Data Type: \\<" "\\>")
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 ("(termcap)Var Index" nil
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 "^[ \t]*`" "'"))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 info-lookup-guess-c-symbol)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 (m4-mode
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 "[_a-zA-Z][_a-zA-Z0-9]*" nil
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 (("(m4)Macro index"))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 "[_a-zA-Z0-9]+")
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 (makefile-mode
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 "\\$[^({]\\|\\.[_A-Z]*\\|[_a-zA-Z][_a-zA-Z0-9-]*" nil
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 (("(make)Name Index" nil
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 "^[ \t]*`" "'"))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 "\\$[^({]\\|\\.[_A-Z]*\\|[_a-zA-Z0-9-]+")
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 (texinfo-mode
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 "@\\([a-zA-Z]+\\|[^a-zA-Z]\\)" nil
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 (("(texinfo)Command and Variable Index"
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 ;; Ignore Emacs commands and prepend a `@'.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 (lambda (item)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 (if (string-match "^\\([a-zA-Z]+\\|[^a-zA-Z]\\)\\( .*\\)?$" item)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 (concat "@" (match-string 1 item))))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 "`" "'"))))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 "*Alist of help specifications for symbol names.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 See the documentation of the variable `info-lookup-alist' for more details.")
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 (defvar info-lookup-file-alist
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 '((c-mode
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 "[_a-zA-Z0-9./+-]+" nil
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 (("(libc)File Index"))))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 "*Alist of help specifications for file names.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 See the documentation of the variable `info-lookup-alist' for more details.")
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 ;;;###autoload
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 (defun info-lookup-reset ()
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 "Throw away all cached data.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206 This command is useful if the user wants to start at the beginning without
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 quitting Emacs, for example, after some Info documents were updated on the
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 system."
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 (interactive)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 (setq info-lookup-cache nil))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 ;;;###autoload
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 (defun info-lookup-symbol (symbol &optional mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214 "Display the documentation of a symbol.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215 If called interactively, SYMBOL will be read from the mini-buffer.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216 Prefix argument means unconditionally insert the default symbol name
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 into the mini-buffer so that it can be edited.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 The default symbol is the one found at point."
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 (interactive
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 (info-lookup-interactive-arguments 'symbol))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 (info-lookup 'symbol symbol mode))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 ;;;###autoload
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 (defun info-lookup-file (file &optional mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 "Display the documentation of a file.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 If called interactively, FILE will be read from the mini-buffer.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 Prefix argument means unconditionally insert the default file name
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228 into the mini-buffer so that it can be edited.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 The default file name is the one found at point."
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 (interactive
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231 (info-lookup-interactive-arguments 'file))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232 (info-lookup 'file file mode))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 (defun info-lookup-interactive-arguments (topic)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235 "Return default value and help mode for help topic TOPIC."
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 (let* ((mode (if (info-lookup->mode-value
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 topic (or info-lookup-mode major-mode))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238 (or info-lookup-mode major-mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239 (info-lookup-change-mode topic)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240 (completions (info-lookup->completions topic mode))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241 (default (info-lookup-guess-default topic mode))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242 (input (if (or current-prefix-arg (not (assoc default completions)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 default))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244 (completion-ignore-case (info-lookup->ignore-case topic mode))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 (enable-recursive-minibuffers t)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246 (value (completing-read
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247 (if (and default (not input))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
248 (format "Describe %s (default %s): " topic default)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249 (format "Describe %s: " topic))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250 completions nil nil input 'info-lookup-history)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251 (list (if (equal value "") default value) mode)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 (defun info-lookup-change-mode (topic)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254 (let* ((completions (mapcar (lambda (arg)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255 (cons (symbol-name (car arg)) (car arg)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256 (info-lookup->topic-value topic)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257 (mode (completing-read
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258 (format "Use %s help mode: " topic)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259 completions nil t nil 'info-lookup-history)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260 (or (setq mode (cdr (assoc mode completions)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261 (error "No %s help available" topic))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 (or (info-lookup->mode-value topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 (error "No %s help available for `%s'" topic mode))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264 (setq info-lookup-mode mode)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266 (defun info-lookup (topic item mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267 "Display the documentation of a help item."
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268 (if (not mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269 (setq mode (or info-lookup-mode major-mode)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270 (or (info-lookup->mode-value topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 (error "No %s help available for `%s'" topic mode))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272 (let ((entry (or (assoc (if (info-lookup->ignore-case topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273 (downcase item) item)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274 (info-lookup->completions topic mode))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275 (error "Not documented as a %s: %s" topic (or item ""))))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
276 (modes (info-lookup->all-modes topic mode))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277 (window (selected-window))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278 found doc-spec node prefix suffix)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279 (if (not info-lookup-other-window-flag)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280 (info)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
281 (save-window-excursion (info))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282 (switch-to-buffer-other-window "*info*"))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 (while (and (not found) modes)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284 (setq doc-spec (info-lookup->doc-spec topic (car modes)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285 (while (and (not found) doc-spec)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286 (setq node (nth 0 (car doc-spec))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287 prefix (nth 2 (car doc-spec))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
288 suffix (nth 3 (car doc-spec)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289 (condition-case nil
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
290 (progn
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291 (Info-goto-node node)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292 (Info-menu (or (cdr entry) item))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293 (setq found t)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
294 (if (or prefix suffix)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295 (let ((case-fold-search
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296 (info-lookup->ignore-case topic (car modes)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297 (buffer-read-only nil))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
298 (goto-char (point-min))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299 (re-search-forward
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300 (concat prefix (regexp-quote item) suffix))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
301 (goto-char (match-beginning 0))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302 (and window-system info-lookup-highlight-face
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
303 ;; Search again for ITEM so that the first
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
304 ;; occurence of ITEM will be highlighted.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
305 (re-search-forward (regexp-quote item))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
306 (let ((start (match-beginning 0))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307 (end (match-end 0)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
308 (if (overlayp info-lookup-highlight-overlay)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309 (move-overlay info-lookup-highlight-overlay
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
310 start end (current-buffer))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311 (setq info-lookup-highlight-overlay
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
312 (make-overlay start end))))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
313 (overlay-put info-lookup-highlight-overlay
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
314 'face info-lookup-highlight-face)))))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
315 (error nil))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
316 (setq doc-spec (cdr doc-spec)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
317 (setq modes (cdr modes)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318 ;; Don't leave the Info buffer if the help item couldn't be looked up.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
319 (if (and info-lookup-other-window-flag found)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
320 (select-window window))))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
321
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
322 (defun info-lookup-setup-mode (topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323 "Initialize the internal data structure."
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324 (or (info-lookup->initialized topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325 (let (cell data (initialized 0) completions refer-modes)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
326 (if (not (info-lookup->mode-value topic mode))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327 (message "No %s help available for `%s'" topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328 ;; Recursively setup cross references.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329 ;; But refer only to non-void modes.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330 (mapcar (lambda (arg)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331 (or (info-lookup->initialized topic arg)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332 (info-lookup-setup-mode topic arg))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333 (and (eq (info-lookup->initialized topic arg) t)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334 (setq refer-modes (cons arg refer-modes))))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335 (info-lookup->other-modes topic mode))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336 (setq refer-modes (nreverse refer-modes))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337 ;; Build the full completion alist.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
338 (setq completions
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
339 (nconc (info-lookup-make-completions topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340 (apply 'append
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
341 (mapcar (lambda (arg)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
342 (info-lookup->completions topic arg))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343 refer-modes))))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
344 (setq initialized t))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
345 ;; Update `info-lookup-cache'.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
346 (setq cell (info-lookup->mode-cache topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
347 data (list initialized completions refer-modes))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
348 (if (not cell)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
349 (setcdr (info-lookup->cache topic)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
350 (cons (cons mode data) (info-lookup->topic-cache topic)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
351 (setcdr cell data))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
352 initialized)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
353
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
354 (defun info-lookup-make-completions (topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
355 "Create a unique alist from all index entries."
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
356 (condition-case nil
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
357 (let ((doc-spec (info-lookup->doc-spec topic mode))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
358 (regexp (concat "^\\(" (info-lookup->regexp topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
359 "\\)\\([ \t].*\\)?$"))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
360 node trans entry item prefix result)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
361 (save-window-excursion
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
362 (info)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
363 (while doc-spec
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
364 (setq node (nth 0 (car doc-spec))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
365 trans (cond ((eq (nth 1 (car doc-spec)) nil)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
366 (lambda (arg)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
367 (if (string-match regexp arg)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
368 (match-string 1 arg))))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
369 ((stringp (nth 1 (car doc-spec)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
370 (setq prefix (nth 1 (car doc-spec)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
371 (lambda (arg)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
372 (if (string-match "^\\([^: \t\n]+\\)" arg)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
373 (concat prefix (match-string 1 arg)))))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
374 (t (nth 1 (car doc-spec)))))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
375 (message "Processing Info node \"%s\"..." node)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376 (Info-goto-node node)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
377 (goto-char (point-min))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
378 (and (search-forward "\n* Menu:" nil t)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
379 (while (re-search-forward "\n\\* \\([^:\t\n]*\\):" nil t)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
380 (setq entry (match-string 1)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
381 item (funcall trans entry))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
382 (and (info-lookup->ignore-case topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
383 (setq item (downcase item)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
384 (and (string-equal entry item)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
385 (setq entry nil))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386 (or (assoc item result)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
387 (setq result (cons (cons item entry) result)))))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
388 (message "Processing Info node \"%s\"... done" node)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
389 (setq doc-spec (cdr doc-spec)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
390 (Info-directory))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
391 result)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
392 (error nil)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
393
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
394 (defun info-lookup-guess-default (topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
395 "Pick up default item at point (with favor to look back).
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
396 Return nil if there is nothing appropriate."
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
397 (let ((modes (info-lookup->all-modes topic mode))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
398 (start (point)) guess whitespace)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
399 (while (and (not guess) modes)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
400 (setq guess (info-lookup-guess-default* topic (car modes))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
401 modes (cdr modes))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
402 (goto-char start))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
403 ;; Collapse whitespace characters.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
404 (and guess (concat (delete nil (mapcar (lambda (ch)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405 (if (or (char-equal ch ? )
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
406 (char-equal ch ?\t)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
407 (char-equal ch ?\n))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
408 (if (not whitespace)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
409 (setq whitespace ? ))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
410 (setq whitespace nil) ch))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
411 guess))))))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
412
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
413 (defun info-lookup-guess-default* (topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
414 (let ((case-fold-search (info-lookup->ignore-case topic mode))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415 (rule (or (info-lookup->parse-rule topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
416 (info-lookup->regexp topic mode)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417 (start (point)) end regexp subexp result)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418 (if (symbolp rule)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419 (setq result (funcall rule))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420 (if (consp rule)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
421 (setq regexp (car rule)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422 subexp (cdr rule))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423 (setq regexp rule
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424 subexp 0))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425 (skip-chars-backward " \t\n") (setq end (point))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426 (while (and (re-search-backward regexp nil t)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427 (looking-at regexp)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
428 (>= (match-end 0) end))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
429 (setq result (match-string subexp)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
430 (if (not result)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
431 (progn
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
432 (goto-char start)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
433 (skip-chars-forward " \t\n")
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
434 (and (looking-at regexp)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
435 (setq result (match-string subexp))))))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
436 result))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
437
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
438 (defun info-lookup-guess-c-symbol ()
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
439 "Get the C symbol at point."
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
440 (condition-case nil
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
441 (progn
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
442 (backward-sexp)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
443 (let ((start (point)) prefix name)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444 ;; Test for a leading `struct', `union', or `enum' keyword
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
445 ;; but ignore names like `foo_struct'.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
446 (setq prefix (and (< (skip-chars-backward " \t\n") 0)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
447 (< (skip-chars-backward "_a-zA-Z0-9") 0)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
448 (looking-at "\\(struct\\|union\\|enum\\)\\s ")
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
449 (concat (match-string 1) " ")))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
450 (goto-char start)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
451 (and (looking-at "[_a-zA-Z][_a-zA-Z0-9]*")
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
452 (setq name (match-string 0)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
453 ;; Caveat! Look forward if point is at `struct' etc.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
454 (and (not prefix)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
455 (or (string-equal name "struct")
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
456 (string-equal name "union")
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
457 (string-equal name "enum"))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
458 (looking-at "[a-z]+\\s +\\([_a-zA-Z][_a-zA-Z0-9]*\\)")
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
459 (setq prefix (concat name " ")
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
460 name (match-string 1)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
461 (and (or prefix name)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
462 (concat prefix name))))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
463 (error nil)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
464
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
465 ;;;###autoload
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
466 (defun info-complete-symbol (&optional mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
467 "Perform completion on symbol preceding point."
18323
64d728fb396a (info-complete-symbol): If MODE is nil, use the default value.
Richard M. Stallman <rms@gnu.org>
parents: 18322
diff changeset
468 (interactive)
64d728fb396a (info-complete-symbol): If MODE is nil, use the default value.
Richard M. Stallman <rms@gnu.org>
parents: 18322
diff changeset
469 (info-complete 'symbol
64d728fb396a (info-complete-symbol): If MODE is nil, use the default value.
Richard M. Stallman <rms@gnu.org>
parents: 18322
diff changeset
470 (or mode
64d728fb396a (info-complete-symbol): If MODE is nil, use the default value.
Richard M. Stallman <rms@gnu.org>
parents: 18322
diff changeset
471 (if (info-lookup->mode-value
64d728fb396a (info-complete-symbol): If MODE is nil, use the default value.
Richard M. Stallman <rms@gnu.org>
parents: 18322
diff changeset
472 'symbol (or info-lookup-mode major-mode))
64d728fb396a (info-complete-symbol): If MODE is nil, use the default value.
Richard M. Stallman <rms@gnu.org>
parents: 18322
diff changeset
473 (or info-lookup-mode major-mode)
64d728fb396a (info-complete-symbol): If MODE is nil, use the default value.
Richard M. Stallman <rms@gnu.org>
parents: 18322
diff changeset
474 (info-lookup-change-mode 'symbol)))))
18322
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
475
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
476 ;;;###autoload
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
477 (defun info-complete-file (&optional mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
478 "Perform completion on file preceding point."
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
479 (interactive
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
480 (list (if (info-lookup->mode-value
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
481 'file (or info-lookup-mode major-mode))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
482 (or info-lookup-mode major-mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
483 (info-lookup-change-mode 'file))))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
484 (info-complete 'file mode))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
485
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
486 (defun info-complete (topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
487 "Try to complete a help item."
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
488 (barf-if-buffer-read-only)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
489 (if (not mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
490 (setq mode (or info-lookup-mode major-mode)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
491 (or (info-lookup->mode-value topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
492 (error "No %s completion available for `%s'" topic mode))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
493 (let ((modes (info-lookup->all-modes topic mode))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
494 (start (point)) try completion)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
495 (while (and (not try) modes)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
496 (setq mode (car modes)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
497 modes (cdr modes)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
498 try (info-lookup-guess-default* topic mode))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
499 (goto-char start))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
500 (and (not try)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
501 (error "Found no %s to complete" topic))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
502 (setq completion (try-completion
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
503 try (info-lookup->completions topic mode)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
504 (cond ((not completion)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
505 (ding))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
506 ((stringp completion)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
507 (delete-region (- start (length try)) start)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
508 (insert completion)))))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
509
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
510 (provide 'info-look)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
511
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
512 ;;; info-look.el ends here