Mercurial > emacs
annotate lisp/info-look.el @ 20909:542ae65815fb
(info-complete): Rewrite minibuffer completion code.
(info-lookup-minor-mode, turn-on-info-lookup):
Added minor mode interface.
(info-lookup-minor-mode-string): New variable.
(info-lookup-minor-mode-map): New variable.
Provide a work-around if the custom library is not available.
(info-lookup-other-window-flag)
(info-lookup-highlight-face): Variables customized.
(info-lookup-alist): No longer customizable.
(info-lookup-add-help, info-lookup-maybe-add-help): Interface
functions for adding new modes.
(info-lookup-add-help*): New function.
(info-lookup-symbol-alist, info-lookup-file-alist): Variables deleted.
This info is specified now by calling info-lookup-maybe-add-help
and info-lookup-add-help.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 17 Feb 1998 03:25:05 +0000 |
parents | d1f6ac340403 |
children | b7e7f7c9685a |
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 | |
20909
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
4 ;; Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. |
18322 | 5 |
6 ;; Author: Ralph Schleicher <rs@purple.UL.BaWue.DE> | |
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 (eval-and-compile |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
30 (condition-case nil |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
31 (require 'custom) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
32 (error |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
33 (defmacro defgroup (&rest arg) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
34 nil) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
35 (defmacro defcustom (symbol value doc &rest arg) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
36 `(defvar ,symbol ,value ,doc ,@arg))))) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
37 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
38 (defgroup info-lookup nil |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
39 "Major mode sensitive help agent." |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
40 :group 'help :group 'languages) |
18322 | 41 |
42 (defvar info-lookup-mode nil | |
20909
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
43 "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
|
44 Help is provided according to the buffer's major mode if value is nil. |
18322 | 45 Automatically becomes buffer local when set in any fashion.") |
46 (make-variable-buffer-local 'info-lookup-mode) | |
47 | |
20909
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
48 (defcustom info-lookup-other-window-flag t |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
49 "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
|
50 :group 'info-lookup :type 'boolean) |
18322 | 51 |
20909
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
52 (defcustom info-lookup-highlight-face 'highlight |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
53 "Face for highlighting looked up help items. |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
54 Setting this variable to nil disables highlighting." |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
55 :group 'info-lookup :type 'face) |
18322 | 56 |
57 (defvar info-lookup-highlight-overlay nil | |
58 "Overlay object used for highlighting.") | |
59 | |
60 (defvar info-lookup-history nil | |
61 "History of previous input lines.") | |
62 | |
20909
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
63 (defvar info-lookup-alist nil |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
64 "Alist of known help topics. |
18322 | 65 Cons cells are of the form |
66 | |
20909
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
67 (HELP-TOPIC . HELP-DATA) |
18322 | 68 |
69 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
|
70 HELP-DATA is a HELP-TOPIC's public data set. |
18322 | 71 Value is an alist with elements of the form |
72 | |
73 (HELP-MODE REGEXP IGNORE-CASE DOC-SPEC PARSE-RULE OTHER-MODES) | |
74 | |
75 HELP-MODE is a mode's symbol. | |
76 REGEXP is a regular expression matching those help items whose | |
77 documentation can be looked up via DOC-SPEC. | |
78 IGNORE-CASE is non-nil if help items are case insensitive. | |
79 DOC-SPEC is a list of documentation specifications of the form | |
80 | |
81 (INFO-NODE TRANS-FUNC PREFIX SUFFIX) | |
82 | |
83 INFO-NODE is the name (including file name part) of an Info index. | |
84 TRANS-FUNC is a function translating index entries into help items; | |
85 nil means add only those index entries matching REGEXP, a string | |
86 means prepend string to the first word of all index entries. | |
87 PREFIX and SUFFIX are parts of a regular expression. If one of | |
88 them is non-nil then search the help item's Info node for the | |
89 first occurrence of the regular expression `PREFIX ITEM SUFFIX'. | |
90 ITEM will be highlighted with `info-lookup-highlight-face' if this | |
91 variable is not nil. | |
92 PARSE-RULE is either the symbol name of a function or a regular | |
93 expression for guessing the default help item at point. Fuzzy | |
94 regular expressions like \"[_a-zA-Z0-9]+\" do a better job if | |
95 there are no clear delimiters; do not try to write too complex | |
96 expressions. PARSE-RULE defaults to REGEXP. | |
97 OTHER-MODES is a list of cross references to other help modes.") | |
98 | |
99 (defsubst info-lookup->topic-value (topic) | |
20909
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
100 (cdr (assoc topic info-lookup-alist))) |
18322 | 101 |
102 (defsubst info-lookup->mode-value (topic mode) | |
103 (assoc mode (info-lookup->topic-value topic))) | |
104 | |
105 (defsubst info-lookup->regexp (topic mode) | |
106 (nth 1 (info-lookup->mode-value topic mode))) | |
107 | |
108 (defsubst info-lookup->ignore-case (topic mode) | |
109 (nth 2 (info-lookup->mode-value topic mode))) | |
110 | |
111 (defsubst info-lookup->doc-spec (topic mode) | |
112 (nth 3 (info-lookup->mode-value topic mode))) | |
113 | |
114 (defsubst info-lookup->parse-rule (topic mode) | |
115 (nth 4 (info-lookup->mode-value topic mode))) | |
116 | |
117 (defsubst info-lookup->other-modes (topic mode) | |
118 (nth 5 (info-lookup->mode-value topic mode))) | |
119 | |
20909
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
120 (eval-and-compile |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
121 (mapcar (lambda (keyword) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
122 (or (boundp keyword) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
123 (set keyword keyword))) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
124 '(:topic :mode :regexp :ignore-case |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
125 :doc-spec :parse-rule :other-modes))) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
126 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
127 (defun info-lookup-add-help (&rest arg) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
128 "Add or update a help specification. |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
129 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
|
130 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
131 KEYWORD ARGUMENT |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
132 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
133 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
|
134 `:doc-spec', `:parse-rule', or `:other-modes'. |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
135 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
|
136 variable `info-lookup-alist'. |
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 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
|
139 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
|
140 (apply 'info-lookup-add-help* nil arg)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
141 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
142 (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
|
143 "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
|
144 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
|
145 for more details." |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
146 (apply 'info-lookup-add-help* t arg)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
147 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
148 (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
|
149 (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
|
150 parse-rule other-modes keyword value) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
151 (setq topic 'symbol |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
152 mode major-mode |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
153 regexp "\\w+") |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
154 (while arg |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
155 (setq keyword (car arg)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
156 (or (symbolp keyword) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
157 (error "Junk in argument list \"%S\"" arg)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
158 (setq arg (cdr arg)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
159 (and (null arg) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
160 (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
|
161 (setq value (car arg) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
162 arg (cdr arg)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
163 (cond ((eq keyword :topic) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
164 (setq topic value)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
165 ((eq keyword :mode) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
166 (setq mode value)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
167 ((eq keyword :regexp) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
168 (setq regexp value)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
169 ((eq keyword :ignore-case) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
170 (setq ignore-case value)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
171 ((eq keyword :doc-spec) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
172 (setq doc-spec value)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
173 ((eq keyword :parse-rule) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
174 (setq parse-rule value)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
175 ((eq keyword :other-modes) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
176 (setq other-modes value)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
177 (t |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
178 (error "Unknown keyword \"%S\"" keyword)))) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
179 (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
|
180 (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
|
181 (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
|
182 (car (setq info-lookup-alist |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
183 (cons (cons topic nil) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
184 info-lookup-alist))))) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
185 (mode-cell (assoc mode topic-cell))) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
186 (if (null mode-cell) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
187 (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
|
188 (setcdr mode-cell data)))) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
189 nil)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
190 |
18322 | 191 (defvar info-lookup-cache nil |
192 "Cache storing data maintained automatically by the program. | |
193 Value is an alist with cons cell of the form | |
194 | |
195 (HELP-TOPIC . ((HELP-MODE INITIALIZED COMPLETIONS REFER-MODES) ...)) | |
196 | |
197 HELP-TOPIC is the symbol of a help topic. | |
198 HELP-MODE is a mode's symbol. | |
199 INITIALIZED is nil if HELP-MODE is uninitialized, t if | |
200 HELP-MODE is initialized, and `0' means HELP-MODE is | |
201 initialized but void. | |
202 COMPLETIONS is an alist of documented help items. | |
203 REFER-MODES is a list of other help modes to use.") | |
204 | |
205 (defsubst info-lookup->cache (topic) | |
206 (or (assoc topic info-lookup-cache) | |
207 (car (setq info-lookup-cache | |
208 (cons (cons topic nil) | |
209 info-lookup-cache))))) | |
210 | |
211 (defsubst info-lookup->topic-cache (topic) | |
212 (cdr (info-lookup->cache topic))) | |
213 | |
214 (defsubst info-lookup->mode-cache (topic mode) | |
215 (assoc mode (info-lookup->topic-cache topic))) | |
216 | |
217 (defsubst info-lookup->initialized (topic mode) | |
218 (nth 1 (info-lookup->mode-cache topic mode))) | |
219 | |
220 (defsubst info-lookup->completions (topic mode) | |
221 (or (info-lookup->initialized topic mode) | |
222 (info-lookup-setup-mode topic mode)) | |
223 (nth 2 (info-lookup->mode-cache topic mode))) | |
224 | |
225 (defsubst info-lookup->refer-modes (topic mode) | |
226 (or (info-lookup->initialized topic mode) | |
227 (info-lookup-setup-mode topic mode)) | |
228 (nth 3 (info-lookup->mode-cache topic mode))) | |
229 | |
230 (defsubst info-lookup->all-modes (topic mode) | |
231 (cons mode (info-lookup->refer-modes topic mode))) | |
232 | |
233 (defvar info-lookup-file-alist | |
234 '((c-mode | |
235 "[_a-zA-Z0-9./+-]+" nil | |
236 (("(libc)File Index")))) | |
237 "*Alist of help specifications for file names. | |
238 See the documentation of the variable `info-lookup-alist' for more details.") | |
239 | |
240 ;;;###autoload | |
241 (defun info-lookup-reset () | |
242 "Throw away all cached data. | |
243 This command is useful if the user wants to start at the beginning without | |
244 quitting Emacs, for example, after some Info documents were updated on the | |
245 system." | |
246 (interactive) | |
247 (setq info-lookup-cache nil)) | |
248 | |
249 ;;;###autoload | |
250 (defun info-lookup-symbol (symbol &optional mode) | |
251 "Display the documentation of a symbol. | |
252 If called interactively, SYMBOL will be read from the mini-buffer. | |
253 Prefix argument means unconditionally insert the default symbol name | |
254 into the mini-buffer so that it can be edited. | |
255 The default symbol is the one found at point." | |
256 (interactive | |
257 (info-lookup-interactive-arguments 'symbol)) | |
258 (info-lookup 'symbol symbol mode)) | |
259 | |
260 ;;;###autoload | |
261 (defun info-lookup-file (file &optional mode) | |
262 "Display the documentation of a file. | |
263 If called interactively, FILE will be read from the mini-buffer. | |
264 Prefix argument means unconditionally insert the default file name | |
265 into the mini-buffer so that it can be edited. | |
266 The default file name is the one found at point." | |
267 (interactive | |
268 (info-lookup-interactive-arguments 'file)) | |
269 (info-lookup 'file file mode)) | |
270 | |
271 (defun info-lookup-interactive-arguments (topic) | |
272 "Return default value and help mode for help topic TOPIC." | |
273 (let* ((mode (if (info-lookup->mode-value | |
274 topic (or info-lookup-mode major-mode)) | |
275 (or info-lookup-mode major-mode) | |
276 (info-lookup-change-mode topic))) | |
277 (completions (info-lookup->completions topic mode)) | |
278 (default (info-lookup-guess-default topic mode)) | |
279 (input (if (or current-prefix-arg (not (assoc default completions))) | |
280 default)) | |
281 (completion-ignore-case (info-lookup->ignore-case topic mode)) | |
282 (enable-recursive-minibuffers t) | |
283 (value (completing-read | |
284 (if (and default (not input)) | |
285 (format "Describe %s (default %s): " topic default) | |
286 (format "Describe %s: " topic)) | |
287 completions nil nil input 'info-lookup-history))) | |
288 (list (if (equal value "") default value) mode))) | |
289 | |
290 (defun info-lookup-change-mode (topic) | |
291 (let* ((completions (mapcar (lambda (arg) | |
292 (cons (symbol-name (car arg)) (car arg))) | |
293 (info-lookup->topic-value topic))) | |
294 (mode (completing-read | |
295 (format "Use %s help mode: " topic) | |
296 completions nil t nil 'info-lookup-history))) | |
297 (or (setq mode (cdr (assoc mode completions))) | |
298 (error "No %s help available" topic)) | |
299 (or (info-lookup->mode-value topic mode) | |
300 (error "No %s help available for `%s'" topic mode)) | |
301 (setq info-lookup-mode mode))) | |
302 | |
303 (defun info-lookup (topic item mode) | |
304 "Display the documentation of a help item." | |
305 (if (not mode) | |
306 (setq mode (or info-lookup-mode major-mode))) | |
307 (or (info-lookup->mode-value topic mode) | |
308 (error "No %s help available for `%s'" topic mode)) | |
309 (let ((entry (or (assoc (if (info-lookup->ignore-case topic mode) | |
310 (downcase item) item) | |
311 (info-lookup->completions topic mode)) | |
312 (error "Not documented as a %s: %s" topic (or item "")))) | |
313 (modes (info-lookup->all-modes topic mode)) | |
314 (window (selected-window)) | |
20690
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
315 found doc-spec node prefix suffix doc-found) |
18322 | 316 (if (not info-lookup-other-window-flag) |
317 (info) | |
318 (save-window-excursion (info)) | |
319 (switch-to-buffer-other-window "*info*")) | |
320 (while (and (not found) modes) | |
321 (setq doc-spec (info-lookup->doc-spec topic (car modes))) | |
322 (while (and (not found) doc-spec) | |
323 (setq node (nth 0 (car doc-spec)) | |
324 prefix (nth 2 (car doc-spec)) | |
325 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
|
326 (when (condition-case error-data |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
327 (progn |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
328 (Info-goto-node node) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
329 (setq doc-found t)) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
330 (error |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
331 (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
|
332 (sit-for 1) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
333 nil)) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
334 (condition-case nil |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
335 (progn |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
336 (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
|
337 (setq found t) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
338 (if (or prefix suffix) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
339 (let ((case-fold-search |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
340 (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
|
341 (buffer-read-only nil)) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
342 (goto-char (point-min)) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
343 (re-search-forward |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
344 (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
|
345 (goto-char (match-beginning 0)) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
346 (and window-system info-lookup-highlight-face |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
347 ;; 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
|
348 ;; 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
|
349 (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
|
350 (let ((start (match-beginning 0)) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
351 (end (match-end 0))) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
352 (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
|
353 (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
|
354 start end (current-buffer)) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
355 (setq info-lookup-highlight-overlay |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
356 (make-overlay start end)))) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
357 (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
|
358 'face info-lookup-highlight-face))))) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
359 (error nil))) |
18322 | 360 (setq doc-spec (cdr doc-spec))) |
361 (setq modes (cdr modes))) | |
20690
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
362 (or doc-found |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
363 (error "Info documentation for lookup was not found")) |
18322 | 364 ;; Don't leave the Info buffer if the help item couldn't be looked up. |
365 (if (and info-lookup-other-window-flag found) | |
366 (select-window window)))) | |
367 | |
368 (defun info-lookup-setup-mode (topic mode) | |
369 "Initialize the internal data structure." | |
370 (or (info-lookup->initialized topic mode) | |
371 (let (cell data (initialized 0) completions refer-modes) | |
372 (if (not (info-lookup->mode-value topic mode)) | |
373 (message "No %s help available for `%s'" topic mode) | |
374 ;; Recursively setup cross references. | |
375 ;; But refer only to non-void modes. | |
376 (mapcar (lambda (arg) | |
377 (or (info-lookup->initialized topic arg) | |
378 (info-lookup-setup-mode topic arg)) | |
379 (and (eq (info-lookup->initialized topic arg) t) | |
380 (setq refer-modes (cons arg refer-modes)))) | |
381 (info-lookup->other-modes topic mode)) | |
382 (setq refer-modes (nreverse refer-modes)) | |
383 ;; Build the full completion alist. | |
384 (setq completions | |
385 (nconc (info-lookup-make-completions topic mode) | |
386 (apply 'append | |
387 (mapcar (lambda (arg) | |
388 (info-lookup->completions topic arg)) | |
389 refer-modes)))) | |
390 (setq initialized t)) | |
391 ;; Update `info-lookup-cache'. | |
392 (setq cell (info-lookup->mode-cache topic mode) | |
393 data (list initialized completions refer-modes)) | |
394 (if (not cell) | |
395 (setcdr (info-lookup->cache topic) | |
396 (cons (cons mode data) (info-lookup->topic-cache topic))) | |
397 (setcdr cell data)) | |
398 initialized))) | |
399 | |
400 (defun info-lookup-make-completions (topic mode) | |
401 "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
|
402 (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
|
403 (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
|
404 "\\)\\([ \t].*\\)?$")) |
20690
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
405 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
|
406 (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
|
407 (with-current-buffer buffer |
c7b3ef0ed1ad
(info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents:
18323
diff
changeset
|
408 (Info-mode)) |
c7b3ef0ed1ad
(info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents:
18323
diff
changeset
|
409 (while doc-spec |
c7b3ef0ed1ad
(info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents:
18323
diff
changeset
|
410 (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
|
411 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
|
412 (lambda (arg) |
c7b3ef0ed1ad
(info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents:
18323
diff
changeset
|
413 (if (string-match regexp arg) |
c7b3ef0ed1ad
(info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents:
18323
diff
changeset
|
414 (match-string 1 arg)))) |
c7b3ef0ed1ad
(info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents:
18323
diff
changeset
|
415 ((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
|
416 (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
|
417 (lambda (arg) |
c7b3ef0ed1ad
(info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents:
18323
diff
changeset
|
418 (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
|
419 (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
|
420 (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
|
421 (with-current-buffer buffer |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
422 (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
|
423 (when (condition-case error-data |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
424 (progn |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
425 (Info-goto-node node) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
426 (setq doc-found t)) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
427 (error |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
428 (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
|
429 (sit-for 1) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
430 nil)) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
431 (condition-case nil |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
432 (progn |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
433 (goto-char (point-min)) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
434 (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
|
435 (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
|
436 (setq entry (match-string 1) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
437 item (funcall trans entry)) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
438 (and (info-lookup->ignore-case topic mode) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
439 (setq item (downcase item))) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
440 (and (string-equal entry item) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
441 (setq entry nil)) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
442 (or (assoc item result) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
443 (setq result (cons (cons item entry) result)))))) |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
444 (error nil)))) |
20519
c7b3ef0ed1ad
(info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents:
18323
diff
changeset
|
445 (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
|
446 (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
|
447 (or doc-found |
a51c71dd5cda
(info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents:
20519
diff
changeset
|
448 (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
|
449 result)) |
18322 | 450 |
451 (defun info-lookup-guess-default (topic mode) | |
452 "Pick up default item at point (with favor to look back). | |
453 Return nil if there is nothing appropriate." | |
454 (let ((modes (info-lookup->all-modes topic mode)) | |
455 (start (point)) guess whitespace) | |
456 (while (and (not guess) modes) | |
457 (setq guess (info-lookup-guess-default* topic (car modes)) | |
458 modes (cdr modes)) | |
459 (goto-char start)) | |
460 ;; Collapse whitespace characters. | |
461 (and guess (concat (delete nil (mapcar (lambda (ch) | |
462 (if (or (char-equal ch ? ) | |
463 (char-equal ch ?\t) | |
464 (char-equal ch ?\n)) | |
465 (if (not whitespace) | |
466 (setq whitespace ? )) | |
467 (setq whitespace nil) ch)) | |
468 guess)))))) | |
469 | |
470 (defun info-lookup-guess-default* (topic mode) | |
471 (let ((case-fold-search (info-lookup->ignore-case topic mode)) | |
472 (rule (or (info-lookup->parse-rule topic mode) | |
473 (info-lookup->regexp topic mode))) | |
474 (start (point)) end regexp subexp result) | |
475 (if (symbolp rule) | |
476 (setq result (funcall rule)) | |
477 (if (consp rule) | |
478 (setq regexp (car rule) | |
479 subexp (cdr rule)) | |
480 (setq regexp rule | |
481 subexp 0)) | |
482 (skip-chars-backward " \t\n") (setq end (point)) | |
483 (while (and (re-search-backward regexp nil t) | |
484 (looking-at regexp) | |
485 (>= (match-end 0) end)) | |
486 (setq result (match-string subexp))) | |
487 (if (not result) | |
488 (progn | |
489 (goto-char start) | |
490 (skip-chars-forward " \t\n") | |
491 (and (looking-at regexp) | |
492 (setq result (match-string subexp)))))) | |
493 result)) | |
494 | |
495 (defun info-lookup-guess-c-symbol () | |
496 "Get the C symbol at point." | |
497 (condition-case nil | |
498 (progn | |
499 (backward-sexp) | |
500 (let ((start (point)) prefix name) | |
501 ;; Test for a leading `struct', `union', or `enum' keyword | |
502 ;; but ignore names like `foo_struct'. | |
503 (setq prefix (and (< (skip-chars-backward " \t\n") 0) | |
504 (< (skip-chars-backward "_a-zA-Z0-9") 0) | |
505 (looking-at "\\(struct\\|union\\|enum\\)\\s ") | |
506 (concat (match-string 1) " "))) | |
507 (goto-char start) | |
508 (and (looking-at "[_a-zA-Z][_a-zA-Z0-9]*") | |
509 (setq name (match-string 0))) | |
510 ;; Caveat! Look forward if point is at `struct' etc. | |
511 (and (not prefix) | |
512 (or (string-equal name "struct") | |
513 (string-equal name "union") | |
514 (string-equal name "enum")) | |
515 (looking-at "[a-z]+\\s +\\([_a-zA-Z][_a-zA-Z0-9]*\\)") | |
516 (setq prefix (concat name " ") | |
517 name (match-string 1))) | |
518 (and (or prefix name) | |
519 (concat prefix name)))) | |
520 (error nil))) | |
521 | |
522 ;;;###autoload | |
523 (defun info-complete-symbol (&optional mode) | |
524 "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
|
525 (interactive) |
64d728fb396a
(info-complete-symbol): If MODE is nil, use the default value.
Richard M. Stallman <rms@gnu.org>
parents:
18322
diff
changeset
|
526 (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
|
527 (or mode |
64d728fb396a
(info-complete-symbol): If MODE is nil, use the default value.
Richard M. Stallman <rms@gnu.org>
parents:
18322
diff
changeset
|
528 (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
|
529 '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
|
530 (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
|
531 (info-lookup-change-mode 'symbol))))) |
18322 | 532 |
533 ;;;###autoload | |
534 (defun info-complete-file (&optional mode) | |
535 "Perform completion on file preceding point." | |
536 (interactive | |
537 (list (if (info-lookup->mode-value | |
538 'file (or info-lookup-mode major-mode)) | |
539 (or info-lookup-mode major-mode) | |
540 (info-lookup-change-mode 'file)))) | |
541 (info-complete 'file mode)) | |
542 | |
543 (defun info-complete (topic mode) | |
544 "Try to complete a help item." | |
545 (barf-if-buffer-read-only) | |
546 (if (not mode) | |
547 (setq mode (or info-lookup-mode major-mode))) | |
548 (or (info-lookup->mode-value topic mode) | |
549 (error "No %s completion available for `%s'" topic mode)) | |
550 (let ((modes (info-lookup->all-modes topic mode)) | |
20909
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
551 (completions (info-lookup->completions topic mode)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
552 (completion-ignore-case (info-lookup->ignore-case topic mode)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
553 (start (point)) try completion) |
18322 | 554 (while (and (not try) modes) |
555 (setq mode (car modes) | |
556 modes (cdr modes) | |
557 try (info-lookup-guess-default* topic mode)) | |
558 (goto-char start)) | |
559 (and (not try) | |
20909
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
560 (error "Found no %S to complete" topic)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
561 (setq completion (try-completion try completions)) |
18322 | 562 (cond ((not completion) |
20909
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
563 (ding) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
564 (message "No match")) |
18322 | 565 ((stringp completion) |
20909
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
566 (or (assoc completion completions) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
567 (setq completion (completing-read |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
568 (format "Complete %S: " topic) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
569 completions nil t completion |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
570 info-lookup-history))) |
18322 | 571 (delete-region (- start (length try)) start) |
20909
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
572 (insert completion)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
573 (t |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
574 (message "%s is complete" (capitalize (prin1-to-string topic))))))) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
575 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
576 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
577 ;;; Info-lookup minor mode. |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
578 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
579 (defvar info-lookup-minor-mode nil |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
580 "Non-`nil' enables Info-lookup mode.") |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
581 (make-variable-buffer-local 'info-lookup-minor-mode) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
582 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
583 (defvar info-lookup-minor-mode-string " Info" |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
584 "Indicator included in the mode line when in Info-lookup mode.") |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
585 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
586 (or (assq 'info-lookup-minor-mode minor-mode-alist) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
587 (setq minor-mode-alist (cons '(info-lookup-minor-mode |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
588 info-lookup-minor-mode-string) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
589 minor-mode-alist))) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
590 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
591 (defvar info-lookup-minor-mode-map (make-sparse-keymap) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
592 "Minor mode map for Info-lookup mode.") |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
593 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
594 (or (assq 'info-lookup-minor-mode minor-mode-map-alist) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
595 (setq minor-mode-map-alist (cons (cons 'info-lookup-minor-mode |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
596 info-lookup-minor-mode-map) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
597 minor-mode-map-alist))) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
598 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
599 ;;;### autoload |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
600 (defun info-lookup-minor-mode (&optional arg) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
601 "Minor mode for looking up the documentation of a symbol or file. |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
602 Special commands: |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
603 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
604 \\{info-lookup-minor-mode-map}" |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
605 (interactive "P") |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
606 (setq info-lookup-minor-mode (if (null arg) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
607 (not info-lookup-minor-mode) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
608 (> (prefix-numeric-value arg) 0))) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
609 (set-buffer-modified-p (buffer-modified-p))) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
610 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
611 (define-key info-lookup-minor-mode-map |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
612 "\C-c\C-hf" 'info-lookup-symbol) ; Describe function. |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
613 (define-key info-lookup-minor-mode-map |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
614 "\C-c\C-hv" 'info-lookup-symbol) ; Describe variable. |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
615 (define-key info-lookup-minor-mode-map |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
616 "\C-c\C-ht" 'info-lookup-symbol) ; Describe type. |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
617 (define-key info-lookup-minor-mode-map |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
618 "\C-c\C-hp" 'info-lookup-file) ; Describe program. |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
619 (define-key info-lookup-minor-mode-map |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
620 "\C-c\C-if" 'info-complete-symbol) ; Complete function. |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
621 (define-key info-lookup-minor-mode-map |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
622 "\C-c\C-iv" 'info-complete-symbol) ; Complete variable. |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
623 (define-key info-lookup-minor-mode-map |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
624 "\C-c\C-it" 'info-complete-symbol) ; Complete type. |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
625 (define-key info-lookup-minor-mode-map |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
626 "\C-c\C-ip" 'info-complete-file) ; Complete program. |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
627 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
628 ;;;### autoload |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
629 (defun turn-on-info-lookup () |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
630 "Unconditionally turn on Info-lookup mode." |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
631 (info-lookup-minor-mode 1)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
632 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
633 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
634 ;;; Initialize some common modes. |
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 'symbol |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
638 :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
|
639 :doc-spec '(("(libc)Function Index" nil |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
640 "^[ \t]+- \\(Function\\|Macro\\): .*\\<" "\\>") |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
641 ("(libc)Variable Index" nil |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
642 "^[ \t]+- \\(Variable\\|Macro\\): .*\\<" "\\>") |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
643 ("(libc)Type Index" nil |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
644 "^[ \t]+- Data Type: \\<" "\\>") |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
645 ("(termcap)Var Index" nil |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
646 "^[ \t]*`" "'")) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
647 :parse-rule 'info-lookup-guess-c-symbol) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
648 |
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 'c-mode :topic 'file |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
651 :regexp "[_a-zA-Z0-9./+-]+" |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
652 :doc-spec '(("(libc)File Index"))) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
653 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
654 (info-lookup-maybe-add-help |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
655 :mode 'bison-mode |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
656 :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
|
657 :doc-spec '(("(bison)Index" nil |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
658 "`" "'")) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
659 :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
|
660 :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
|
661 |
20909
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
662 (info-lookup-maybe-add-help |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
663 :mode 'makefile-mode |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
664 :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
|
665 :doc-spec '(("(make)Name Index" nil |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
666 "^[ \t]*`" "'")) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
667 :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
|
668 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
669 (info-lookup-maybe-add-help |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
670 :mode 'texinfo-mode |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
671 :regexp "@\\([a-zA-Z]+\\|[^a-zA-Z]\\)" |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
672 :doc-spec '(("(texinfo)Command and Variable Index" |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
673 ;; Ignore Emacs commands and prepend a `@'. |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
674 (lambda (item) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
675 (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
|
676 (concat "@" (match-string 1 item)))) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
677 "`" "'"))) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
678 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
679 (info-lookup-maybe-add-help |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
680 :mode 'm4-mode |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
681 :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
|
682 :doc-spec '(("(m4)Macro index")) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
683 :parse-rule "[_a-zA-Z0-9]+") |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
684 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
685 (info-lookup-maybe-add-help |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
686 :mode 'autoconf-mode |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
687 :regexp "A[CM]_[_A-Z0-9]+" |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
688 :doc-spec '(("(autoconf)Macro Index" "AC_" |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
689 "^[ \t]+- \\(Macro\\|Variable\\): .*\\<" "\\>") |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
690 ("(automake)Index" nil |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
691 "^[ \t]*`" "'")) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
692 ;; 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
|
693 :parse-rule 'ignore |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
694 :other-modes '(m4-mode)) |
18322 | 695 |
20909
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
696 (info-lookup-maybe-add-help |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
697 :mode 'awk-mode |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
698 :regexp "[_a-zA-Z]+" |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
699 :doc-spec '(("(gawk)Index" |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
700 (lambda (item) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
701 (let ((case-fold-search nil)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
702 (cond |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
703 ;; `BEGIN' and `END'. |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
704 ((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
|
705 (match-string 1 item)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
706 ;; `if', `while', `do', ... |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
707 ((string-match "^\\([a-z]+\\) statement\\b" item) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
708 (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
|
709 (match-string 1 item))) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
710 ;; `NR', `NF', ... |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
711 ((string-match "^[A-Z]+$" item) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
712 item) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
713 ;; Built-in functions (matches to many entries). |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
714 ((string-match "^[a-z]+$" item) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
715 item)))) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
716 "`" "\\([ \t]*([^)]*)\\)?'"))) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
717 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
718 (info-lookup-maybe-add-help |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
719 :mode 'perl-mode |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
720 :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
|
721 :doc-spec '(("(perl5)Function Index" |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
722 (lambda (item) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
723 (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
|
724 (match-string 1 item))) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
725 "^" "\\b") |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
726 ("(perl5)Variable Index" |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
727 (lambda (item) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
728 ;; Work around bad formatted array variables. |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
729 (let ((sym (cond ((or (string-match "^\\$\\(.\\|@@\\)$" item) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
730 (string-match "^\\$\\^[A-Z]$" item)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
731 item) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
732 ((string-match |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
733 "^\\([$%@]\\|@@\\)?[_a-zA-Z0-9]+" item) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
734 (match-string 0 item)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
735 (t "")))) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
736 (if (string-match "@@" sym) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
737 (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
|
738 (substring sym (1- (match-end 0)))))) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
739 (if (string-equal sym "") nil sym))) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
740 "^" "\\b")) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
741 :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
|
742 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
743 (info-lookup-maybe-add-help |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
744 :mode 'latex-mode |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
745 :regexp "\\\\\\([a-zA-Z]+\\|[^a-zA-Z]\\)" |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
746 :doc-spec '(("(latex2e)Command Index" nil |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
747 "`" "\\({[^}]*}\\)?'"))) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
748 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
749 (info-lookup-maybe-add-help |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
750 :mode 'emacs-lisp-mode |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
751 :regexp "[^()' \t\n]+" |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
752 :doc-spec '(("(emacs)Command Index") |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
753 ("(emacs)Variable Index"))) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
754 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
755 (info-lookup-maybe-add-help |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
756 :mode 'lisp-interaction-mode |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
757 :regexp "[^()' \t\n]+" |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
758 :parse-rule 'ignore |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
759 :other-modes '(emacs-lisp-mode)) |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
760 |
542ae65815fb
(info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents:
20899
diff
changeset
|
761 |
18322 | 762 (provide 'info-look) |
763 | |
764 ;;; info-look.el ends here |