Mercurial > emacs
annotate lisp/info-look.el @ 32559:bc60bd171784
(keymap_memberp): Ensure that nil is not a member.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Mon, 16 Oct 2000 21:57:11 +0000 |
parents | 2dc989936987 |
children | d29b9968e84f |
rev | line source |
---|---|
18322 | 1 ;;; info-look.el --- major-mode-sensitive Info index lookup facility. |
2 ;; An older version of this was known as libc.el. | |
3 | |
25310 | 4 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc. |
18322 | 5 |
30110
23cb074f9d88
Change author's mail address.
Gerd Moellmann <gerd@gnu.org>
parents:
28112
diff
changeset
|
6 ;; Author: Ralph Schleicher <rs@nunatak.allgaeu.org> |
18322 | 7 ;; Keywords: help languages |
8 | |
9 ;; This file is part of GNU Emacs. | |
10 | |
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) | |
14 ;; any later version. | |
15 | |
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. | |
20 | |
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. | |
25 | |
26 ;;; Code: | |
27 | |
28 (require 'info) | |
20909
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
29 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
30 (defgroup info-lookup nil |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
31 "Major mode sensitive help agent." |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
32 :group 'help :group 'languages) |
18322 | 33 |
34 (defvar info-lookup-mode nil | |
20909
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
35 "Symbol of the current buffer's help mode. |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
36 Help is provided according to the buffer's major mode if value is nil. |
18322 | 37 Automatically becomes buffer local when set in any fashion.") |
38 (make-variable-buffer-local 'info-lookup-mode) | |
39 | |
20909
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
40 (defcustom info-lookup-other-window-flag t |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
41 "Non-nil means pop up the Info buffer in another window." |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
42 :group 'info-lookup :type 'boolean) |
18322 | 43 |
20909
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
44 (defcustom info-lookup-highlight-face 'highlight |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
45 "Face for highlighting looked up help items. |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
46 Setting this variable to nil disables highlighting." |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
47 :group 'info-lookup :type 'face) |
18322 | 48 |
49 (defvar info-lookup-highlight-overlay nil | |
50 "Overlay object used for highlighting.") | |
51 | |
22281 | 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 | |
59 | |
60 (REGEXP . MODE) | |
61 | |
62 If a file name matches REGEXP, then use help mode MODE instead of the | |
63 buffer's major mode." | |
64 :group 'info-lookup :type '(repeat (cons (string :tag "Regexp") | |
65 (symbol :tag "Mode")))) | |
66 | |
18322 | 67 (defvar info-lookup-history nil |
68 "History of previous input lines.") | |
69 | |
20909
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
70 (defvar info-lookup-alist nil |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
71 "Alist of known help topics. |
18322 | 72 Cons cells are of the form |
73 | |
20909
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
74 (HELP-TOPIC . HELP-DATA) |
18322 | 75 |
76 HELP-TOPIC is the symbol of a help topic. | |
20909
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
77 HELP-DATA is a HELP-TOPIC's public data set. |
18322 | 78 Value is an alist with elements of the form |
79 | |
80 (HELP-MODE REGEXP IGNORE-CASE DOC-SPEC PARSE-RULE OTHER-MODES) | |
81 | |
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 | |
87 | |
88 (INFO-NODE TRANS-FUNC PREFIX SUFFIX) | |
89 | |
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 | |
98 variable is not nil. | |
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.") | |
105 | |
106 (defsubst info-lookup->topic-value (topic) | |
20909
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
107 (cdr (assoc topic info-lookup-alist))) |
18322 | 108 |
109 (defsubst info-lookup->mode-value (topic mode) | |
110 (assoc mode (info-lookup->topic-value topic))) | |
111 | |
112 (defsubst info-lookup->regexp (topic mode) | |
113 (nth 1 (info-lookup->mode-value topic mode))) | |
114 | |
115 (defsubst info-lookup->ignore-case (topic mode) | |
116 (nth 2 (info-lookup->mode-value topic mode))) | |
117 | |
118 (defsubst info-lookup->doc-spec (topic mode) | |
119 (nth 3 (info-lookup->mode-value topic mode))) | |
120 | |
121 (defsubst info-lookup->parse-rule (topic mode) | |
122 (nth 4 (info-lookup->mode-value topic mode))) | |
123 | |
124 (defsubst info-lookup->other-modes (topic mode) | |
125 (nth 5 (info-lookup->mode-value topic mode))) | |
126 | |
20909
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
127 (eval-and-compile |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
128 (mapcar (lambda (keyword) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
129 (or (boundp keyword) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
130 (set keyword keyword))) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
131 '(:topic :mode :regexp :ignore-case |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
132 :doc-spec :parse-rule :other-modes))) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
133 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
134 (defun info-lookup-add-help (&rest arg) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
135 "Add or update a help specification. |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
136 Function arguments are one or more options of the form |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
137 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
138 KEYWORD ARGUMENT |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
139 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
140 KEYWORD is either `:topic', `:mode', `:regexp', `:ignore-case', |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
141 `:doc-spec', `:parse-rule', or `:other-modes'. |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
142 ARGUMENT has a value as explained in the documentation of the |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
143 variable `info-lookup-alist'. |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
144 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
145 If no topic or mode option has been specified, then the help topic defaults |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
146 to `symbol', and the help mode defaults to the current major mode." |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
147 (apply 'info-lookup-add-help* nil arg)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
148 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
149 (defun info-lookup-maybe-add-help (&rest arg) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
150 "Add a help specification iff no one is defined. |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
151 See the documentation of the function `info-lookup-add-help' |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
152 for more details." |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
153 (apply 'info-lookup-add-help* t arg)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
154 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
155 (defun info-lookup-add-help* (maybe &rest arg) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
156 (let (topic mode regexp ignore-case doc-spec |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
157 parse-rule other-modes keyword value) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
158 (setq topic 'symbol |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
159 mode major-mode |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
160 regexp "\\w+") |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
161 (while arg |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
162 (setq keyword (car arg)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
163 (or (symbolp keyword) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
164 (error "Junk in argument list \"%S\"" arg)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
165 (setq arg (cdr arg)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
166 (and (null arg) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
167 (error "Keyword \"%S\" is missing an argument" keyword)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
168 (setq value (car arg) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
169 arg (cdr arg)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
170 (cond ((eq keyword :topic) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
171 (setq topic value)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
172 ((eq keyword :mode) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
173 (setq mode value)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
174 ((eq keyword :regexp) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
175 (setq regexp value)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
176 ((eq keyword :ignore-case) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
177 (setq ignore-case value)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
178 ((eq keyword :doc-spec) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
179 (setq doc-spec value)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
180 ((eq keyword :parse-rule) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
181 (setq parse-rule value)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
182 ((eq keyword :other-modes) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
183 (setq other-modes value)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
184 (t |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
185 (error "Unknown keyword \"%S\"" keyword)))) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
186 (or (and maybe (info-lookup->mode-value topic mode)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
187 (let* ((data (list regexp ignore-case doc-spec parse-rule other-modes)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
188 (topic-cell (or (assoc topic info-lookup-alist) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
189 (car (setq info-lookup-alist |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
190 (cons (cons topic nil) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
191 info-lookup-alist))))) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
192 (mode-cell (assoc mode topic-cell))) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
193 (if (null mode-cell) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
194 (setcdr topic-cell (cons (cons mode data) (cdr topic-cell))) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
195 (setcdr mode-cell data)))) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
196 nil)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
197 |
18322 | 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 | |
201 | |
202 (HELP-TOPIC . ((HELP-MODE INITIALIZED COMPLETIONS REFER-MODES) ...)) | |
203 | |
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.") | |
211 | |
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))))) | |
217 | |
21334
66b3b9fe3e3c
(info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents:
20973
diff
changeset
|
218 (defun info-lookup->topic-cache (topic) |
18322 | 219 (cdr (info-lookup->cache topic))) |
220 | |
21334
66b3b9fe3e3c
(info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents:
20973
diff
changeset
|
221 (defun info-lookup->mode-cache (topic mode) |
18322 | 222 (assoc mode (info-lookup->topic-cache topic))) |
223 | |
21334
66b3b9fe3e3c
(info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents:
20973
diff
changeset
|
224 (defun info-lookup->initialized (topic mode) |
18322 | 225 (nth 1 (info-lookup->mode-cache topic mode))) |
226 | |
21334
66b3b9fe3e3c
(info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents:
20973
diff
changeset
|
227 (defun info-lookup->completions (topic mode) |
18322 | 228 (or (info-lookup->initialized topic mode) |
229 (info-lookup-setup-mode topic mode)) | |
230 (nth 2 (info-lookup->mode-cache topic mode))) | |
231 | |
21334
66b3b9fe3e3c
(info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents:
20973
diff
changeset
|
232 (defun info-lookup->refer-modes (topic mode) |
18322 | 233 (or (info-lookup->initialized topic mode) |
234 (info-lookup-setup-mode topic mode)) | |
235 (nth 3 (info-lookup->mode-cache topic mode))) | |
236 | |
21334
66b3b9fe3e3c
(info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents:
20973
diff
changeset
|
237 (defun info-lookup->all-modes (topic mode) |
18322 | 238 (cons mode (info-lookup->refer-modes topic mode))) |
239 | |
21334
66b3b9fe3e3c
(info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents:
20973
diff
changeset
|
240 (defun info-lookup-quick-all-modes (topic mode) |
66b3b9fe3e3c
(info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents:
20973
diff
changeset
|
241 (cons mode (info-lookup->other-modes topic mode))) |
66b3b9fe3e3c
(info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents:
20973
diff
changeset
|
242 |
18322 | 243 ;;;###autoload |
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 | |
248 system." | |
249 (interactive) | |
250 (setq info-lookup-cache nil)) | |
251 | |
252 ;;;###autoload | |
253 (defun info-lookup-symbol (symbol &optional mode) | |
24829
749c12791859
(info-lookup-file, info-lookup-symbol): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
24769
diff
changeset
|
254 "Display the definition of SYMBOL, as found in the relevant manual. |
749c12791859
(info-lookup-file, info-lookup-symbol): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
24769
diff
changeset
|
255 When this command is called interactively, it reads SYMBOL from the minibuffer. |
749c12791859
(info-lookup-file, info-lookup-symbol): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
24769
diff
changeset
|
256 In the minibuffer, use M-n to yank the default argument value |
749c12791859
(info-lookup-file, info-lookup-symbol): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
24769
diff
changeset
|
257 into the minibuffer so you can edit it. |
25057
6019ba9c1a95
(info-lookup-interactive-arguments): Add optional
Karl Heuer <kwzh@gnu.org>
parents:
25041
diff
changeset
|
258 The default symbol is the one found at point. |
6019ba9c1a95
(info-lookup-interactive-arguments): Add optional
Karl Heuer <kwzh@gnu.org>
parents:
25041
diff
changeset
|
259 |
6019ba9c1a95
(info-lookup-interactive-arguments): Add optional
Karl Heuer <kwzh@gnu.org>
parents:
25041
diff
changeset
|
260 With prefix arg a query for the symbol help mode is offered." |
18322 | 261 (interactive |
25057
6019ba9c1a95
(info-lookup-interactive-arguments): Add optional
Karl Heuer <kwzh@gnu.org>
parents:
25041
diff
changeset
|
262 (info-lookup-interactive-arguments 'symbol current-prefix-arg)) |
18322 | 263 (info-lookup 'symbol symbol mode)) |
264 | |
265 ;;;###autoload | |
266 (defun info-lookup-file (file &optional mode) | |
267 "Display the documentation of a file. | |
24829
749c12791859
(info-lookup-file, info-lookup-symbol): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
24769
diff
changeset
|
268 When this command is called interactively, it reads FILE from the minibuffer. |
749c12791859
(info-lookup-file, info-lookup-symbol): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
24769
diff
changeset
|
269 In the minibuffer, use M-n to yank the default file name |
749c12791859
(info-lookup-file, info-lookup-symbol): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
24769
diff
changeset
|
270 into the minibuffer so you can edit it. |
25057
6019ba9c1a95
(info-lookup-interactive-arguments): Add optional
Karl Heuer <kwzh@gnu.org>
parents:
25041
diff
changeset
|
271 The default file name is the one found at point. |
6019ba9c1a95
(info-lookup-interactive-arguments): Add optional
Karl Heuer <kwzh@gnu.org>
parents:
25041
diff
changeset
|
272 |
6019ba9c1a95
(info-lookup-interactive-arguments): Add optional
Karl Heuer <kwzh@gnu.org>
parents:
25041
diff
changeset
|
273 With prefix arg a query for the file help mode is offered." |
18322 | 274 (interactive |
25057
6019ba9c1a95
(info-lookup-interactive-arguments): Add optional
Karl Heuer <kwzh@gnu.org>
parents:
25041
diff
changeset
|
275 (info-lookup-interactive-arguments 'file current-prefix-arg)) |
18322 | 276 (info-lookup 'file file mode)) |
277 | |
25057
6019ba9c1a95
(info-lookup-interactive-arguments): Add optional
Karl Heuer <kwzh@gnu.org>
parents:
25041
diff
changeset
|
278 (defun info-lookup-interactive-arguments (topic &optional query) |
6019ba9c1a95
(info-lookup-interactive-arguments): Add optional
Karl Heuer <kwzh@gnu.org>
parents:
25041
diff
changeset
|
279 "Read and return argument value (and help mode) for help topic TOPIC. |
6019ba9c1a95
(info-lookup-interactive-arguments): Add optional
Karl Heuer <kwzh@gnu.org>
parents:
25041
diff
changeset
|
280 If optional argument QUERY is non-nil, query for the help mode." |
6019ba9c1a95
(info-lookup-interactive-arguments): Add optional
Karl Heuer <kwzh@gnu.org>
parents:
25041
diff
changeset
|
281 (let* ((mode (cond (query |
6019ba9c1a95
(info-lookup-interactive-arguments): Add optional
Karl Heuer <kwzh@gnu.org>
parents:
25041
diff
changeset
|
282 (info-lookup-change-mode topic)) |
6019ba9c1a95
(info-lookup-interactive-arguments): Add optional
Karl Heuer <kwzh@gnu.org>
parents:
25041
diff
changeset
|
283 ((info-lookup->mode-value topic (info-lookup-select-mode)) |
6019ba9c1a95
(info-lookup-interactive-arguments): Add optional
Karl Heuer <kwzh@gnu.org>
parents:
25041
diff
changeset
|
284 info-lookup-mode) |
6019ba9c1a95
(info-lookup-interactive-arguments): Add optional
Karl Heuer <kwzh@gnu.org>
parents:
25041
diff
changeset
|
285 ((info-lookup-change-mode topic)))) |
18322 | 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 | |
24829
749c12791859
(info-lookup-file, info-lookup-symbol): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
24769
diff
changeset
|
291 (if default |
18322 | 292 (format "Describe %s (default %s): " topic default) |
293 (format "Describe %s: " topic)) | |
24829
749c12791859
(info-lookup-file, info-lookup-symbol): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
24769
diff
changeset
|
294 completions nil nil nil 'info-lookup-history default))) |
18322 | 295 (list (if (equal value "") default value) mode))) |
296 | |
22281 | 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))) | |
306 | |
18322 | 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))) | |
319 | |
320 (defun info-lookup (topic item mode) | |
321 "Display the documentation of a help item." | |
22281 | 322 (or mode (setq mode (info-lookup-select-mode))) |
18322 | 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)) | |
20690
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
331 found doc-spec node prefix suffix doc-found) |
25057
6019ba9c1a95
(info-lookup-interactive-arguments): Add optional
Karl Heuer <kwzh@gnu.org>
parents:
25041
diff
changeset
|
332 (if (or (not info-lookup-other-window-flag) |
6019ba9c1a95
(info-lookup-interactive-arguments): Add optional
Karl Heuer <kwzh@gnu.org>
parents:
25041
diff
changeset
|
333 (eq (current-buffer) (get-buffer "*info*"))) |
18322 | 334 (info) |
30348
2dc989936987
(info-lookup): If *info* is shown in another frame
Gerd Moellmann <gerd@gnu.org>
parents:
30110
diff
changeset
|
335 (progn |
2dc989936987
(info-lookup): If *info* is shown in another frame
Gerd Moellmann <gerd@gnu.org>
parents:
30110
diff
changeset
|
336 (save-window-excursion (info)) |
2dc989936987
(info-lookup): If *info* is shown in another frame
Gerd Moellmann <gerd@gnu.org>
parents:
30110
diff
changeset
|
337 ;; Determine whether or not the Info buffer is visible in |
2dc989936987
(info-lookup): If *info* is shown in another frame
Gerd Moellmann <gerd@gnu.org>
parents:
30110
diff
changeset
|
338 ;; another frame on the same display. If it is, simply raise |
2dc989936987
(info-lookup): If *info* is shown in another frame
Gerd Moellmann <gerd@gnu.org>
parents:
30110
diff
changeset
|
339 ;; that frame. Otherwise, display it in another window. |
2dc989936987
(info-lookup): If *info* is shown in another frame
Gerd Moellmann <gerd@gnu.org>
parents:
30110
diff
changeset
|
340 (let* ((window (get-buffer-window "*info*" t)) |
2dc989936987
(info-lookup): If *info* is shown in another frame
Gerd Moellmann <gerd@gnu.org>
parents:
30110
diff
changeset
|
341 (info-frame (and window (window-frame window)))) |
2dc989936987
(info-lookup): If *info* is shown in another frame
Gerd Moellmann <gerd@gnu.org>
parents:
30110
diff
changeset
|
342 (if (and info-frame |
2dc989936987
(info-lookup): If *info* is shown in another frame
Gerd Moellmann <gerd@gnu.org>
parents:
30110
diff
changeset
|
343 (display-multi-frame-p) |
2dc989936987
(info-lookup): If *info* is shown in another frame
Gerd Moellmann <gerd@gnu.org>
parents:
30110
diff
changeset
|
344 (memq info-frame (frames-on-display-list))) |
2dc989936987
(info-lookup): If *info* is shown in another frame
Gerd Moellmann <gerd@gnu.org>
parents:
30110
diff
changeset
|
345 (select-frame info-frame) |
2dc989936987
(info-lookup): If *info* is shown in another frame
Gerd Moellmann <gerd@gnu.org>
parents:
30110
diff
changeset
|
346 (switch-to-buffer-other-window "*info*"))))) |
18322 | 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))) | |
20690
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
353 (when (condition-case error-data |
25310 | 354 (progn |
20690
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
355 (Info-goto-node node) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
356 (setq doc-found t)) |
25310 | 357 (error |
20690
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
358 (message "Cannot access Info node %s" node) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
359 (sit-for 1) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
360 nil)) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
361 (condition-case nil |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
362 (progn |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
363 (Info-menu (or (cdr entry) item)) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
364 (setq found t) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
365 (if (or prefix suffix) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
366 (let ((case-fold-search |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
367 (info-lookup->ignore-case topic (car modes))) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
368 (buffer-read-only nil)) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
369 (goto-char (point-min)) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
370 (re-search-forward |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
371 (concat prefix (regexp-quote item) suffix)) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
372 (goto-char (match-beginning 0)) |
28112
853a7fcaf7f0
(info-lookup): Use display-color-p.
Dave Love <fx@gnu.org>
parents:
25364
diff
changeset
|
373 (and (display-color-p) info-lookup-highlight-face |
20690
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
374 ;; Search again for ITEM so that the first |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
375 ;; occurence of ITEM will be highlighted. |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
376 (re-search-forward (regexp-quote item)) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
377 (let ((start (match-beginning 0)) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
378 (end (match-end 0))) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
379 (if (overlayp info-lookup-highlight-overlay) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
380 (move-overlay info-lookup-highlight-overlay |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
381 start end (current-buffer)) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
382 (setq info-lookup-highlight-overlay |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
383 (make-overlay start end)))) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
384 (overlay-put info-lookup-highlight-overlay |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
385 'face info-lookup-highlight-face))))) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
386 (error nil))) |
18322 | 387 (setq doc-spec (cdr doc-spec))) |
388 (setq modes (cdr modes))) | |
20690
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
389 (or doc-found |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
390 (error "Info documentation for lookup was not found")) |
18322 | 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)))) | |
394 | |
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. | |
411 (setq completions | |
25041
d45a32b777f6
(info-lookup-setup-mode): Don't give up, if
Karl Heuer <kwzh@gnu.org>
parents:
24829
diff
changeset
|
412 (nconc (condition-case nil |
d45a32b777f6
(info-lookup-setup-mode): Don't give up, if
Karl Heuer <kwzh@gnu.org>
parents:
24829
diff
changeset
|
413 (info-lookup-make-completions topic mode) |
d45a32b777f6
(info-lookup-setup-mode): Don't give up, if
Karl Heuer <kwzh@gnu.org>
parents:
24829
diff
changeset
|
414 (error nil)) |
18322 | 415 (apply 'append |
416 (mapcar (lambda (arg) | |
417 (info-lookup->completions topic arg)) | |
418 refer-modes)))) | |
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)) | |
423 (if (not cell) | |
424 (setcdr (info-lookup->cache topic) | |
425 (cons (cons mode data) (info-lookup->topic-cache topic))) | |
426 (setcdr cell data)) | |
427 initialized))) | |
428 | |
429 (defun info-lookup-make-completions (topic mode) | |
430 "Create a unique alist from all index entries." | |
20519
c7b3ef0ed1ad
(info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents:
18323
diff
changeset
|
431 (let ((doc-spec (info-lookup->doc-spec topic mode)) |
c7b3ef0ed1ad
(info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents:
18323
diff
changeset
|
432 (regexp (concat "^\\(" (info-lookup->regexp topic mode) |
c7b3ef0ed1ad
(info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents:
18323
diff
changeset
|
433 "\\)\\([ \t].*\\)?$")) |
20690
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
434 node trans entry item prefix result doc-found |
20519
c7b3ef0ed1ad
(info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents:
18323
diff
changeset
|
435 (buffer (get-buffer-create " temp-info-look"))) |
c7b3ef0ed1ad
(info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents:
18323
diff
changeset
|
436 (with-current-buffer buffer |
c7b3ef0ed1ad
(info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents:
18323
diff
changeset
|
437 (Info-mode)) |
c7b3ef0ed1ad
(info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents:
18323
diff
changeset
|
438 (while doc-spec |
c7b3ef0ed1ad
(info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents:
18323
diff
changeset
|
439 (setq node (nth 0 (car doc-spec)) |
c7b3ef0ed1ad
(info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents:
18323
diff
changeset
|
440 trans (cond ((eq (nth 1 (car doc-spec)) nil) |
c7b3ef0ed1ad
(info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents:
18323
diff
changeset
|
441 (lambda (arg) |
c7b3ef0ed1ad
(info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents:
18323
diff
changeset
|
442 (if (string-match regexp arg) |
c7b3ef0ed1ad
(info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents:
18323
diff
changeset
|
443 (match-string 1 arg)))) |
c7b3ef0ed1ad
(info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents:
18323
diff
changeset
|
444 ((stringp (nth 1 (car doc-spec))) |
c7b3ef0ed1ad
(info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents:
18323
diff
changeset
|
445 (setq prefix (nth 1 (car doc-spec))) |
c7b3ef0ed1ad
(info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents:
18323
diff
changeset
|
446 (lambda (arg) |
c7b3ef0ed1ad
(info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents:
18323
diff
changeset
|
447 (if (string-match "^\\([^: \t\n]+\\)" arg) |
c7b3ef0ed1ad
(info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents:
18323
diff
changeset
|
448 (concat prefix (match-string 1 arg))))) |
c7b3ef0ed1ad
(info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents:
18323
diff
changeset
|
449 (t (nth 1 (car doc-spec))))) |
20690
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
450 (with-current-buffer buffer |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
451 (message "Processing Info node `%s'..." node) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
452 (when (condition-case error-data |
25310 | 453 (progn |
20690
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
454 (Info-goto-node node) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
455 (setq doc-found t)) |
25310 | 456 (error |
20690
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
457 (message "Cannot access Info node `%s'" node) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
458 (sit-for 1) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
459 nil)) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
460 (condition-case nil |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
461 (progn |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
462 (goto-char (point-min)) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
463 (and (search-forward "\n* Menu:" nil t) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
464 (while (re-search-forward "\n\\* \\([^:\t\n]*\\):" nil t) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
465 (setq entry (match-string 1) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
466 item (funcall trans entry)) |
23365
d400637428d1
Remove duplicate scheme-mode entry.
Dave Love <fx@gnu.org>
parents:
23346
diff
changeset
|
467 ;; `trans' can return nil if the regexp doesn't match. |
d400637428d1
Remove duplicate scheme-mode entry.
Dave Love <fx@gnu.org>
parents:
23346
diff
changeset
|
468 (when (and item |
d400637428d1
Remove duplicate scheme-mode entry.
Dave Love <fx@gnu.org>
parents:
23346
diff
changeset
|
469 ;; Sometimes there's more than one Menu: |
25310 | 470 (not (string= entry "Menu"))) |
23365
d400637428d1
Remove duplicate scheme-mode entry.
Dave Love <fx@gnu.org>
parents:
23346
diff
changeset
|
471 (and (info-lookup->ignore-case topic mode) |
d400637428d1
Remove duplicate scheme-mode entry.
Dave Love <fx@gnu.org>
parents:
23346
diff
changeset
|
472 (setq item (downcase item))) |
d400637428d1
Remove duplicate scheme-mode entry.
Dave Love <fx@gnu.org>
parents:
23346
diff
changeset
|
473 (and (string-equal entry item) |
d400637428d1
Remove duplicate scheme-mode entry.
Dave Love <fx@gnu.org>
parents:
23346
diff
changeset
|
474 (setq entry nil)) |
d400637428d1
Remove duplicate scheme-mode entry.
Dave Love <fx@gnu.org>
parents:
23346
diff
changeset
|
475 (and (or (assoc item result) |
d400637428d1
Remove duplicate scheme-mode entry.
Dave Love <fx@gnu.org>
parents:
23346
diff
changeset
|
476 (setq result (cons (cons item entry) |
d400637428d1
Remove duplicate scheme-mode entry.
Dave Love <fx@gnu.org>
parents:
23346
diff
changeset
|
477 result)))))))) |
20690
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
478 (error nil)))) |
20519
c7b3ef0ed1ad
(info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents:
18323
diff
changeset
|
479 (message "Processing Info node `%s'...done" node) |
c7b3ef0ed1ad
(info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents:
18323
diff
changeset
|
480 (setq doc-spec (cdr doc-spec))) |
20690
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
481 (or doc-found |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
482 (error "Info documentation for lookup was not found")) |
20519
c7b3ef0ed1ad
(info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents:
18323
diff
changeset
|
483 result)) |
18322 | 484 |
485 (defun info-lookup-guess-default (topic mode) | |
25222
1802f1bb3285
(info-lookup-guess-c-symbol): Use skip-syntax-backward.
Karl Heuer <kwzh@gnu.org>
parents:
25057
diff
changeset
|
486 "Return a guess for a symbol to look up, based on text around point. |
1802f1bb3285
(info-lookup-guess-c-symbol): Use skip-syntax-backward.
Karl Heuer <kwzh@gnu.org>
parents:
25057
diff
changeset
|
487 Try all related modes applicable to TOPIC and MODE. |
1802f1bb3285
(info-lookup-guess-c-symbol): Use skip-syntax-backward.
Karl Heuer <kwzh@gnu.org>
parents:
25057
diff
changeset
|
488 Return nil if there is nothing appropriate in the buffer near point." |
18322 | 489 (let ((modes (info-lookup->all-modes topic mode)) |
25222
1802f1bb3285
(info-lookup-guess-c-symbol): Use skip-syntax-backward.
Karl Heuer <kwzh@gnu.org>
parents:
25057
diff
changeset
|
490 guess) |
18322 | 491 (while (and (not guess) modes) |
492 (setq guess (info-lookup-guess-default* topic (car modes)) | |
25222
1802f1bb3285
(info-lookup-guess-c-symbol): Use skip-syntax-backward.
Karl Heuer <kwzh@gnu.org>
parents:
25057
diff
changeset
|
493 modes (cdr modes))) |
18322 | 494 ;; Collapse whitespace characters. |
25222
1802f1bb3285
(info-lookup-guess-c-symbol): Use skip-syntax-backward.
Karl Heuer <kwzh@gnu.org>
parents:
25057
diff
changeset
|
495 (when guess |
1802f1bb3285
(info-lookup-guess-c-symbol): Use skip-syntax-backward.
Karl Heuer <kwzh@gnu.org>
parents:
25057
diff
changeset
|
496 (let ((pos 0)) |
1802f1bb3285
(info-lookup-guess-c-symbol): Use skip-syntax-backward.
Karl Heuer <kwzh@gnu.org>
parents:
25057
diff
changeset
|
497 (while (string-match "[ \t\n]+" guess pos) |
1802f1bb3285
(info-lookup-guess-c-symbol): Use skip-syntax-backward.
Karl Heuer <kwzh@gnu.org>
parents:
25057
diff
changeset
|
498 (setq pos (1+ (match-beginning 0))) |
1802f1bb3285
(info-lookup-guess-c-symbol): Use skip-syntax-backward.
Karl Heuer <kwzh@gnu.org>
parents:
25057
diff
changeset
|
499 (setq guess (replace-match " " t t guess))))) |
1802f1bb3285
(info-lookup-guess-c-symbol): Use skip-syntax-backward.
Karl Heuer <kwzh@gnu.org>
parents:
25057
diff
changeset
|
500 guess)) |
18322 | 501 |
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) | |
25222
1802f1bb3285
(info-lookup-guess-c-symbol): Use skip-syntax-backward.
Karl Heuer <kwzh@gnu.org>
parents:
25057
diff
changeset
|
507 (save-excursion |
1802f1bb3285
(info-lookup-guess-c-symbol): Use skip-syntax-backward.
Karl Heuer <kwzh@gnu.org>
parents:
25057
diff
changeset
|
508 (if (symbolp rule) |
1802f1bb3285
(info-lookup-guess-c-symbol): Use skip-syntax-backward.
Karl Heuer <kwzh@gnu.org>
parents:
25057
diff
changeset
|
509 (setq result (funcall rule)) |
1802f1bb3285
(info-lookup-guess-c-symbol): Use skip-syntax-backward.
Karl Heuer <kwzh@gnu.org>
parents:
25057
diff
changeset
|
510 (if (consp rule) |
1802f1bb3285
(info-lookup-guess-c-symbol): Use skip-syntax-backward.
Karl Heuer <kwzh@gnu.org>
parents:
25057
diff
changeset
|
511 (setq regexp (car rule) |
1802f1bb3285
(info-lookup-guess-c-symbol): Use skip-syntax-backward.
Karl Heuer <kwzh@gnu.org>
parents:
25057
diff
changeset
|
512 subexp (cdr rule)) |
1802f1bb3285
(info-lookup-guess-c-symbol): Use skip-syntax-backward.
Karl Heuer <kwzh@gnu.org>
parents:
25057
diff
changeset
|
513 (setq regexp rule |
1802f1bb3285
(info-lookup-guess-c-symbol): Use skip-syntax-backward.
Karl Heuer <kwzh@gnu.org>
parents:
25057
diff
changeset
|
514 subexp 0)) |
25310 | 515 ;; If at start of symbol, don't go back to end of previous one. |
516 (if (save-match-data | |
517 (looking-at "[ \t\n]")) | |
518 (skip-chars-backward " \t\n")) | |
519 (setq end (point)) | |
25222
1802f1bb3285
(info-lookup-guess-c-symbol): Use skip-syntax-backward.
Karl Heuer <kwzh@gnu.org>
parents:
25057
diff
changeset
|
520 (while (and (re-search-backward regexp nil t) |
1802f1bb3285
(info-lookup-guess-c-symbol): Use skip-syntax-backward.
Karl Heuer <kwzh@gnu.org>
parents:
25057
diff
changeset
|
521 (looking-at regexp) |
1802f1bb3285
(info-lookup-guess-c-symbol): Use skip-syntax-backward.
Karl Heuer <kwzh@gnu.org>
parents:
25057
diff
changeset
|
522 (>= (match-end 0) end)) |
1802f1bb3285
(info-lookup-guess-c-symbol): Use skip-syntax-backward.
Karl Heuer <kwzh@gnu.org>
parents:
25057
diff
changeset
|
523 (setq result (match-string subexp))) |
1802f1bb3285
(info-lookup-guess-c-symbol): Use skip-syntax-backward.
Karl Heuer <kwzh@gnu.org>
parents:
25057
diff
changeset
|
524 (if (not result) |
1802f1bb3285
(info-lookup-guess-c-symbol): Use skip-syntax-backward.
Karl Heuer <kwzh@gnu.org>
parents:
25057
diff
changeset
|
525 (progn |
1802f1bb3285
(info-lookup-guess-c-symbol): Use skip-syntax-backward.
Karl Heuer <kwzh@gnu.org>
parents:
25057
diff
changeset
|
526 (goto-char start) |
1802f1bb3285
(info-lookup-guess-c-symbol): Use skip-syntax-backward.
Karl Heuer <kwzh@gnu.org>
parents:
25057
diff
changeset
|
527 (skip-chars-forward " \t\n") |
1802f1bb3285
(info-lookup-guess-c-symbol): Use skip-syntax-backward.
Karl Heuer <kwzh@gnu.org>
parents:
25057
diff
changeset
|
528 (and (looking-at regexp) |
1802f1bb3285
(info-lookup-guess-c-symbol): Use skip-syntax-backward.
Karl Heuer <kwzh@gnu.org>
parents:
25057
diff
changeset
|
529 (setq result (match-string subexp))))))) |
18322 | 530 result)) |
531 | |
532 (defun info-lookup-guess-c-symbol () | |
533 "Get the C symbol at point." | |
534 (condition-case nil | |
535 (progn | |
25222
1802f1bb3285
(info-lookup-guess-c-symbol): Use skip-syntax-backward.
Karl Heuer <kwzh@gnu.org>
parents:
25057
diff
changeset
|
536 (skip-syntax-backward "w_") |
18322 | 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) " "))) | |
544 (goto-char start) | |
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. | |
548 (and (not prefix) | |
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)))) | |
557 (error nil))) | |
558 | |
559 ;;;###autoload | |
560 (defun info-complete-symbol (&optional mode) | |
561 "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
|
562 (interactive) |
64d728fb396a
(info-complete-symbol): If MODE is nil, use the default value.
Richard M. Stallman <rms@gnu.org>
parents:
18322
diff
changeset
|
563 (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
|
564 (or mode |
64d728fb396a
(info-complete-symbol): If MODE is nil, use the default value.
Richard M. Stallman <rms@gnu.org>
parents:
18322
diff
changeset
|
565 (if (info-lookup->mode-value |
22281 | 566 'symbol (info-lookup-select-mode)) |
567 info-lookup-mode | |
18323
64d728fb396a
(info-complete-symbol): If MODE is nil, use the default value.
Richard M. Stallman <rms@gnu.org>
parents:
18322
diff
changeset
|
568 (info-lookup-change-mode 'symbol))))) |
18322 | 569 |
570 ;;;###autoload | |
571 (defun info-complete-file (&optional mode) | |
572 "Perform completion on file preceding point." | |
20973
b7e7f7c9685a
Added support for the Emacs Lisp manual.
Karl Heuer <kwzh@gnu.org>
parents:
20909
diff
changeset
|
573 (interactive) |
b7e7f7c9685a
Added support for the Emacs Lisp manual.
Karl Heuer <kwzh@gnu.org>
parents:
20909
diff
changeset
|
574 (info-complete 'file |
b7e7f7c9685a
Added support for the Emacs Lisp manual.
Karl Heuer <kwzh@gnu.org>
parents:
20909
diff
changeset
|
575 (or mode |
b7e7f7c9685a
Added support for the Emacs Lisp manual.
Karl Heuer <kwzh@gnu.org>
parents:
20909
diff
changeset
|
576 (if (info-lookup->mode-value |
22281 | 577 'file (info-lookup-select-mode)) |
578 info-lookup-mode | |
20973
b7e7f7c9685a
Added support for the Emacs Lisp manual.
Karl Heuer <kwzh@gnu.org>
parents:
20909
diff
changeset
|
579 (info-lookup-change-mode 'file))))) |
18322 | 580 |
581 (defun info-complete (topic mode) | |
582 "Try to complete a help item." | |
583 (barf-if-buffer-read-only) | |
22281 | 584 (or mode (setq mode (info-lookup-select-mode))) |
18322 | 585 (or (info-lookup->mode-value topic mode) |
586 (error "No %s completion available for `%s'" topic mode)) | |
21334
66b3b9fe3e3c
(info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents:
20973
diff
changeset
|
587 (let ((modes (info-lookup-quick-all-modes topic mode)) |
66b3b9fe3e3c
(info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents:
20973
diff
changeset
|
588 (start (point)) |
66b3b9fe3e3c
(info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents:
20973
diff
changeset
|
589 try) |
18322 | 590 (while (and (not try) modes) |
591 (setq mode (car modes) | |
592 modes (cdr modes) | |
593 try (info-lookup-guess-default* topic mode)) | |
594 (goto-char start)) | |
595 (and (not try) | |
20909
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
596 (error "Found no %S to complete" topic)) |
21334
66b3b9fe3e3c
(info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents:
20973
diff
changeset
|
597 (let ((completions (info-lookup->completions topic mode)) |
66b3b9fe3e3c
(info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents:
20973
diff
changeset
|
598 (completion-ignore-case (info-lookup->ignore-case topic mode)) |
66b3b9fe3e3c
(info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents:
20973
diff
changeset
|
599 completion) |
66b3b9fe3e3c
(info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents:
20973
diff
changeset
|
600 (setq completion (try-completion try completions)) |
66b3b9fe3e3c
(info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents:
20973
diff
changeset
|
601 (cond ((not completion) |
66b3b9fe3e3c
(info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents:
20973
diff
changeset
|
602 (ding) |
66b3b9fe3e3c
(info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents:
20973
diff
changeset
|
603 (message "No match")) |
66b3b9fe3e3c
(info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents:
20973
diff
changeset
|
604 ((stringp completion) |
66b3b9fe3e3c
(info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents:
20973
diff
changeset
|
605 (or (assoc completion completions) |
66b3b9fe3e3c
(info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents:
20973
diff
changeset
|
606 (setq completion (completing-read |
66b3b9fe3e3c
(info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents:
20973
diff
changeset
|
607 (format "Complete %S: " topic) |
66b3b9fe3e3c
(info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents:
20973
diff
changeset
|
608 completions nil t completion |
66b3b9fe3e3c
(info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents:
20973
diff
changeset
|
609 info-lookup-history))) |
25310 | 610 ;; Find the original symbol and zap it. |
611 (end-of-line) | |
612 (while (and (search-backward try nil t) | |
613 (< start (point)))) | |
614 (replace-match "") | |
21334
66b3b9fe3e3c
(info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents:
20973
diff
changeset
|
615 (insert completion)) |
66b3b9fe3e3c
(info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents:
20973
diff
changeset
|
616 (t |
66b3b9fe3e3c
(info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents:
20973
diff
changeset
|
617 (message "%s is complete" |
66b3b9fe3e3c
(info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents:
20973
diff
changeset
|
618 (capitalize (prin1-to-string topic)))))))) |
20909
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
619 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
620 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
621 ;;; Initialize some common modes. |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
622 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
623 (info-lookup-maybe-add-help |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
624 :mode 'c-mode :topic 'symbol |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
625 :regexp "\\(struct \\|union \\|enum \\)?[_a-zA-Z][_a-zA-Z0-9]*" |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
626 :doc-spec '(("(libc)Function Index" nil |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
627 "^[ \t]+- \\(Function\\|Macro\\): .*\\<" "\\>") |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
628 ("(libc)Variable Index" nil |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
629 "^[ \t]+- \\(Variable\\|Macro\\): .*\\<" "\\>") |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
630 ("(libc)Type Index" nil |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
631 "^[ \t]+- Data Type: \\<" "\\>") |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
632 ("(termcap)Var Index" nil |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
633 "^[ \t]*`" "'")) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
634 :parse-rule 'info-lookup-guess-c-symbol) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
635 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
636 (info-lookup-maybe-add-help |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
637 :mode 'c-mode :topic 'file |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
638 :regexp "[_a-zA-Z0-9./+-]+" |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
639 :doc-spec '(("(libc)File Index"))) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
640 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
641 (info-lookup-maybe-add-help |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
642 :mode 'bison-mode |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
643 :regexp "[:;|]\\|%\\([%{}]\\|[_a-z]+\\)\\|YY[_A-Z]+\\|yy[_a-z]+" |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
644 :doc-spec '(("(bison)Index" nil |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
645 "`" "'")) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
646 :parse-rule "[:;|]\\|%\\([%{}]\\|[_a-zA-Z][_a-zA-Z0-9]*\\)" |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
647 :other-modes '(c-mode)) |
20899
d1f6ac340403
(info-complete): Display completions on second invocation at same point
Richard M. Stallman <rms@gnu.org>
parents:
20690
diff
changeset
|
648 |
20909
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
649 (info-lookup-maybe-add-help |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
650 :mode 'makefile-mode |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
651 :regexp "\\$[^({]\\|\\.[_A-Z]*\\|[_a-zA-Z][_a-zA-Z0-9-]*" |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
652 :doc-spec '(("(make)Name Index" nil |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
653 "^[ \t]*`" "'")) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
654 :parse-rule "\\$[^({]\\|\\.[_A-Z]*\\|[_a-zA-Z0-9-]+") |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
655 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
656 (info-lookup-maybe-add-help |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
657 :mode 'texinfo-mode |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
658 :regexp "@\\([a-zA-Z]+\\|[^a-zA-Z]\\)" |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
659 :doc-spec '(("(texinfo)Command and Variable Index" |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
660 ;; Ignore Emacs commands and prepend a `@'. |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
661 (lambda (item) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
662 (if (string-match "^\\([a-zA-Z]+\\|[^a-zA-Z]\\)\\( .*\\)?$" item) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
663 (concat "@" (match-string 1 item)))) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
664 "`" "'"))) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
665 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
666 (info-lookup-maybe-add-help |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
667 :mode 'm4-mode |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
668 :regexp "[_a-zA-Z][_a-zA-Z0-9]*" |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
669 :doc-spec '(("(m4)Macro index")) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
670 :parse-rule "[_a-zA-Z0-9]+") |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
671 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
672 (info-lookup-maybe-add-help |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
673 :mode 'autoconf-mode |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
674 :regexp "A[CM]_[_A-Z0-9]+" |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
675 :doc-spec '(("(autoconf)Macro Index" "AC_" |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
676 "^[ \t]+- \\(Macro\\|Variable\\): .*\\<" "\\>") |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
677 ("(automake)Index" nil |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
678 "^[ \t]*`" "'")) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
679 ;; Autoconf symbols are M4 macros. Thus use M4's parser. |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
680 :parse-rule 'ignore |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
681 :other-modes '(m4-mode)) |
18322 | 682 |
20909
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
683 (info-lookup-maybe-add-help |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
684 :mode 'awk-mode |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
685 :regexp "[_a-zA-Z]+" |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
686 :doc-spec '(("(gawk)Index" |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
687 (lambda (item) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
688 (let ((case-fold-search nil)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
689 (cond |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
690 ;; `BEGIN' and `END'. |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
691 ((string-match "^\\([A-Z]+\\) special pattern\\b" item) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
692 (match-string 1 item)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
693 ;; `if', `while', `do', ... |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
694 ((string-match "^\\([a-z]+\\) statement\\b" item) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
695 (if (not (string-equal (match-string 1 item) "control")) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
696 (match-string 1 item))) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
697 ;; `NR', `NF', ... |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
698 ((string-match "^[A-Z]+$" item) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
699 item) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
700 ;; Built-in functions (matches to many entries). |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
701 ((string-match "^[a-z]+$" item) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
702 item)))) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
703 "`" "\\([ \t]*([^)]*)\\)?'"))) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
704 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
705 (info-lookup-maybe-add-help |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
706 :mode 'perl-mode |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
707 :regexp "[$@%][^a-zA-Z]\\|\\$\\^[A-Z]\\|[$@%]?[a-zA-Z][_a-zA-Z0-9]*" |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
708 :doc-spec '(("(perl5)Function Index" |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
709 (lambda (item) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
710 (if (string-match "^\\([a-zA-Z0-9]+\\)" item) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
711 (match-string 1 item))) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
712 "^" "\\b") |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
713 ("(perl5)Variable Index" |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
714 (lambda (item) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
715 ;; Work around bad formatted array variables. |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
716 (let ((sym (cond ((or (string-match "^\\$\\(.\\|@@\\)$" item) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
717 (string-match "^\\$\\^[A-Z]$" item)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
718 item) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
719 ((string-match |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
720 "^\\([$%@]\\|@@\\)?[_a-zA-Z0-9]+" item) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
721 (match-string 0 item)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
722 (t "")))) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
723 (if (string-match "@@" sym) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
724 (setq sym (concat (substring sym 0 (match-beginning 0)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
725 (substring sym (1- (match-end 0)))))) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
726 (if (string-equal sym "") nil sym))) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
727 "^" "\\b")) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
728 :parse-rule "[$@%]?\\([_a-zA-Z0-9]+\\|[^a-zA-Z]\\)") |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
729 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
730 (info-lookup-maybe-add-help |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
731 :mode 'latex-mode |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
732 :regexp "\\\\\\([a-zA-Z]+\\|[^a-zA-Z]\\)" |
25041
d45a32b777f6
(info-lookup-setup-mode): Don't give up, if
Karl Heuer <kwzh@gnu.org>
parents:
24829
diff
changeset
|
733 :doc-spec '(("(latex)Command Index" nil |
20909
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
734 "`" "\\({[^}]*}\\)?'"))) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
735 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
736 (info-lookup-maybe-add-help |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
737 :mode 'emacs-lisp-mode |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
738 :regexp "[^()' \t\n]+" |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
739 :doc-spec '(("(emacs)Command Index") |
20973
b7e7f7c9685a
Added support for the Emacs Lisp manual.
Karl Heuer <kwzh@gnu.org>
parents:
20909
diff
changeset
|
740 ("(emacs)Variable Index") |
b7e7f7c9685a
Added support for the Emacs Lisp manual.
Karl Heuer <kwzh@gnu.org>
parents:
20909
diff
changeset
|
741 ("(elisp)Index" |
b7e7f7c9685a
Added support for the Emacs Lisp manual.
Karl Heuer <kwzh@gnu.org>
parents:
20909
diff
changeset
|
742 (lambda (item) |
b7e7f7c9685a
Added support for the Emacs Lisp manual.
Karl Heuer <kwzh@gnu.org>
parents:
20909
diff
changeset
|
743 (let ((sym (intern-soft item))) |
b7e7f7c9685a
Added support for the Emacs Lisp manual.
Karl Heuer <kwzh@gnu.org>
parents:
20909
diff
changeset
|
744 (cond ((null sym) |
b7e7f7c9685a
Added support for the Emacs Lisp manual.
Karl Heuer <kwzh@gnu.org>
parents:
20909
diff
changeset
|
745 (if (string-equal item "nil") item)) |
b7e7f7c9685a
Added support for the Emacs Lisp manual.
Karl Heuer <kwzh@gnu.org>
parents:
20909
diff
changeset
|
746 ((or (boundp sym) (fboundp sym)) |
b7e7f7c9685a
Added support for the Emacs Lisp manual.
Karl Heuer <kwzh@gnu.org>
parents:
20909
diff
changeset
|
747 item)))) |
b7e7f7c9685a
Added support for the Emacs Lisp manual.
Karl Heuer <kwzh@gnu.org>
parents:
20909
diff
changeset
|
748 "^[ \t]+- [^:]+:[ \t]*" "\\b"))) |
20909
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
749 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
750 (info-lookup-maybe-add-help |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
751 :mode 'lisp-interaction-mode |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
752 :regexp "[^()' \t\n]+" |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
753 :parse-rule 'ignore |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
754 :other-modes '(emacs-lisp-mode)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
755 |
21334
66b3b9fe3e3c
(info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents:
20973
diff
changeset
|
756 (info-lookup-maybe-add-help |
66b3b9fe3e3c
(info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents:
20973
diff
changeset
|
757 :mode 'lisp-mode |
66b3b9fe3e3c
(info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents:
20973
diff
changeset
|
758 :regexp "[^()' \t\n]+" |
66b3b9fe3e3c
(info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents:
20973
diff
changeset
|
759 :parse-rule 'ignore |
66b3b9fe3e3c
(info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents:
20973
diff
changeset
|
760 :other-modes '(emacs-lisp-mode)) |
66b3b9fe3e3c
(info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents:
20973
diff
changeset
|
761 |
22281 | 762 (info-lookup-maybe-add-help |
763 :mode 'scheme-mode | |
764 :regexp "[^()' \t\n]+" | |
765 :ignore-case t | |
23365
d400637428d1
Remove duplicate scheme-mode entry.
Dave Love <fx@gnu.org>
parents:
23346
diff
changeset
|
766 ;; Aubrey Jaffer's rendition from <URL:ftp://ftp-swiss.ai.mit.edu/pub/scm> |
22281 | 767 :doc-spec '(("(r5rs)Index" nil |
768 "^[ \t]+- [^:]+:[ \t]*" "\\b"))) | |
769 | |
23346 | 770 (info-lookup-maybe-add-help |
771 :mode 'octave-mode | |
772 :regexp "[_a-zA-Z0-9]+" | |
25364
d593a9e28430
Octave-mode support: for the function index entries, allow the prefix
Stephen Eglen <stephen@gnu.org>
parents:
25310
diff
changeset
|
773 :doc-spec '(("(octave)Function Index" nil |
d593a9e28430
Octave-mode support: for the function index entries, allow the prefix
Stephen Eglen <stephen@gnu.org>
parents:
25310
diff
changeset
|
774 "^ - [^:]+:[ ]+\\(\\[[^=]*=[ ]+\\)?" nil) |
23346 | 775 ("(octave)Variable Index" nil "^ - [^:]+:[ ]+" nil) |
776 ;; Catch lines of the form "xyz statement" | |
25310 | 777 ("(octave)Concept Index" |
23346 | 778 (lambda (item) |
779 (cond | |
780 ((string-match "^\\([A-Z]+\\) statement\\b" item) | |
781 (match-string 1 item)) | |
782 (t nil))) | |
783 nil; "^ - [^:]+:[ ]+" don't think this prefix is useful here. | |
784 nil))) | |
20909
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
785 |
18322 | 786 (provide 'info-look) |
787 | |
788 ;;; info-look.el ends here |