Mercurial > emacs
annotate lisp/apropos.el @ 4130:e5aee6a3bb75
* hippie-exp.el: Renamed from hippie.el.
Changes from Anders Holst, to bring hippie-expand up to version 1.2:
* hippie-exp.el (hippie-expand-max-buffers): New variable.
(try-expand-line-all-buffers, try-expand-list-all-buffers,
try-expand-dabbrev-all-buffers): Use it.
(try-expand-list, try-expand-list-all-buffers): New functions.
(he-string-beg, he-string-end, he-search-loc): These values are
now markers, not integers. Uses changed.
(he-reset-string, he-substitute-string): Use a marker to preserve
the old position of point.
(try-expand-all-abbrevs): handle case the same way as the
usual expand-abbrev (which is not a very good way, but for
consistency...).
(he-dabbrev-beg): Use `skip-syntax' instead of `skip-chars', to
adjust its behavior to different modes.
(hippie-expand): Don't messages which try function it is using,
when the expansion itself is done in the minibuffer (it was very
annoying to have the message obscuring the expansion).
(try-complete-file-name, try-complete-file-name-partially,
try-complete-lisp-symbol, try-complete-lisp-symbol-partially,
try-expand-line, try-expand-line-all-buffers,
try-expand-all-abbrevs, try-expand-dabbrev,
try-expand-dabbrev-all-buffers): No unnecessary "resetting" of the
epansion, when no expansion is done (caused the buffer to be
marked as changed, although nothing was done, among other things).
(he-reset-string): Undoing of last expansion at a later occasion, now
undoes correctly (before, it garbled things up).
(make-hippie-expand-function): now uses "(function ...)"
instead of "'" (matters for compilation).
(try-expand-line, try-expand-line-all-buffers,
he-line-search-regexp): uses `comint-prompt-regexp' instead of
`shell-prompt-pattern', to strip off prompt in process buffers.
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Sun, 18 Jul 1993 06:20:15 +0000 |
parents | 804e4f30b7ce |
children | 969ebd50eb72 |
rev | line source |
---|---|
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
444
diff
changeset
|
1 ;;; apropos.el --- faster apropos commands. |
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
444
diff
changeset
|
2 |
845 | 3 ;; Copyright (C) 1989 Free Software Foundation, Inc. |
4 | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
5 ;; Author: Joe Wells <jbw@bigbird.bu.edu> |
2247
2c7997f249eb
Add or correct keywords
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1894
diff
changeset
|
6 ;; Keywords: help |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
7 |
367 | 8 ;; This file is part of GNU Emacs. |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
12 ;; the Free Software Foundation; either version 2, or (at your option) |
367 | 13 ;; any later version. |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
23 | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
24 ;;; Commentary: |
367 | 25 |
26 ;; The ideas for this package were derived from the C code in | |
27 ;; src/keymap.c and elsewhere. The functions in this file should | |
28 ;; always be byte-compiled for speed. Someone should rewrite this in | |
29 ;; C (as part of src/keymap.c) for speed. | |
30 | |
31 ;; The idea for super-apropos is based on the original implementation | |
32 ;; by Lynn Slater <lrs@esl.com>. | |
33 | |
34 ;; History: | |
35 ;; Fixed bug, current-local-map can return nil. | |
36 ;; Change, doesn't calculate key-bindings unless needed. | |
37 ;; Added super-apropos capability, changed print functions. | |
38 ;; Made fast-apropos and super-apropos share code. | |
39 ;; Sped up fast-apropos again. | |
40 ;; Added apropos-do-all option. | |
41 ;; Added fast-command-apropos. | |
42 ;; Changed doc strings to comments for helping functions. | |
43 ;; Made doc file buffer read-only, buried it. | |
44 ;; Only call substitute-command-keys if do-all set. | |
45 | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
46 ;;; Code: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
47 |
367 | 48 (defvar apropos-do-all nil |
49 "*Whether `apropos' and `super-apropos' should do everything that they can. | |
50 Makes them run 2 or 3 times slower. Set this non-nil if you have a fast | |
51 machine.") | |
52 | |
53 ;; If there isn't already a lisp variable named internal-doc-file-name, create | |
54 ;; it and document it. This is so the code will work right after RMS adds | |
55 ;; internal-doc-file-name. | |
56 ;(or (boundp 'internal-doc-file-name) | |
444 | 57 ; (setq internal-doc-file-name (concat data-directory "DOC"))) |
367 | 58 ;(or (documentation-property 'internal-doc-file-name 'variable-documentation) |
59 ; (put 'internal-doc-file-name 'variable-documentation | |
60 ; "The complete pathname of the documentation file that contains all | |
61 ;documentation for functions and variables defined before Emacs is dumped.")) | |
62 | |
63 ;;;###autoload | |
64 (defun apropos (regexp &optional do-all pred) | |
65 "Show all symbols whose names contain matches for REGEXP. | |
66 If optional argument DO-ALL is non-nil, does more (time-consuming) work such as | |
67 showing key bindings. Optional argument PRED is called with each symbol, and | |
68 if it returns nil, the symbol is not shown. | |
69 | |
70 Returns list of symbols and documentation found." | |
71 (interactive "sApropos (regexp): \nP") | |
72 (setq do-all (or apropos-do-all do-all)) | |
73 (let ((apropos-accumulate (apropos-internal regexp pred))) | |
74 (if (null apropos-accumulate) | |
75 (message "No apropos matches for `%s'" regexp) | |
76 (apropos-get-doc apropos-accumulate) | |
77 (with-output-to-temp-buffer "*Help*" | |
78 (apropos-print-matches apropos-accumulate regexp nil do-all))) | |
79 apropos-accumulate)) | |
80 | |
81 ;; If "C-h a" still has its original binding of command-apropos, change it to | |
82 ;; use fast-command-apropos. I don't use substitute-key-definition because | |
83 ;; it's slow. | |
84 ;(if (eq 'command-apropos (lookup-key help-map "a")) | |
85 ; (define-key help-map "a" 'fast-command-apropos)) | |
86 | |
87 ;; Takes LIST of symbols and adds documentation. Modifies LIST in place. | |
88 ;; Resulting alist is of form ((symbol fn-doc var-doc) ...). Should only be | |
89 ;; called by apropos. Returns LIST. | |
90 | |
91 (defun apropos-get-doc (list) | |
92 (let ((p list) | |
93 fn-doc var-doc symbol) | |
94 (while (consp p) | |
95 (setq symbol (car p) | |
96 fn-doc (and (fboundp symbol) | |
97 (documentation symbol)) | |
98 var-doc (documentation-property symbol 'variable-documentation) | |
99 fn-doc (and fn-doc | |
100 (substring fn-doc 0 (string-match "\n" fn-doc))) | |
101 var-doc (and var-doc | |
102 (substring var-doc 0 (string-match "\n" var-doc)))) | |
103 (setcar p (list symbol fn-doc var-doc)) | |
104 (setq p (cdr p))) | |
105 list)) | |
106 | |
107 ;;;###autoload | |
108 (defun super-apropos (regexp &optional do-all) | |
109 "Show symbols whose names/documentation contain matches for REGEXP. | |
110 If optional argument DO-ALL is non-nil, does more (time-consuming) work such as | |
111 showing key bindings and documentation that is not stored in the documentation | |
112 file. | |
113 | |
114 Returns list of symbols and documentation found." | |
115 (interactive "sSuper Apropos: \nP") | |
116 (setq do-all (or apropos-do-all do-all)) | |
117 (let (apropos-accumulate fn-doc var-doc item) | |
118 (setq apropos-accumulate (super-apropos-check-doc-file regexp)) | |
119 (if (null apropos-accumulate) | |
120 (message "No apropos matches for `%s'" regexp) | |
121 (if do-all (mapatoms 'super-apropos-accumulate)) | |
122 (with-output-to-temp-buffer "*Help*" | |
123 (apropos-print-matches apropos-accumulate nil t do-all))) | |
124 apropos-accumulate)) | |
125 | |
126 ;; Finds all documentation related to REGEXP in internal-doc-file-name. | |
127 ;; Returns an alist of form ((symbol fn-doc var-doc) ...). | |
128 | |
129 (defun super-apropos-check-doc-file (regexp) | |
1894
73a56a618d25
(super-apropos-check-doc-file): Look for DOC file in proper directory.
Richard M. Stallman <rms@gnu.org>
parents:
1734
diff
changeset
|
130 (let* ((doc-file (concat data-directory internal-doc-file-name)) |
73a56a618d25
(super-apropos-check-doc-file): Look for DOC file in proper directory.
Richard M. Stallman <rms@gnu.org>
parents:
1734
diff
changeset
|
131 (doc-buffer (find-file-noselect doc-file t)) |
73a56a618d25
(super-apropos-check-doc-file): Look for DOC file in proper directory.
Richard M. Stallman <rms@gnu.org>
parents:
1734
diff
changeset
|
132 ;; (doc-buffer (or (get-file-buffer doc-file) |
73a56a618d25
(super-apropos-check-doc-file): Look for DOC file in proper directory.
Richard M. Stallman <rms@gnu.org>
parents:
1734
diff
changeset
|
133 ;; (find-file-noselect doc-file))) |
367 | 134 type symbol doc sym-list) |
135 (save-excursion | |
136 (set-buffer doc-buffer) | |
137 ;; a user said he might accidentally edit the doc file | |
138 (setq buffer-read-only t) | |
139 (bury-buffer doc-buffer) | |
140 (goto-char (point-min)) | |
141 (while (re-search-forward regexp nil t) | |
142 (search-backward "\C-_") | |
143 (setq type (if (eq ?F (char-after (1+ (point)))) | |
144 1 ;function documentation | |
145 2) ;variable documentation | |
146 symbol (progn | |
147 (forward-char 2) | |
148 (read doc-buffer)) | |
149 doc (buffer-substring | |
150 (point) | |
151 (progn | |
152 (if (search-forward "\C-_" nil 'move) | |
153 (1- (point)) | |
154 (point)))) | |
155 item (assq symbol sym-list)) | |
156 (or item | |
157 (setq item (list symbol nil nil) | |
158 sym-list (cons item sym-list))) | |
159 (setcar (nthcdr type item) doc))) | |
160 sym-list)) | |
161 | |
162 ;; This is passed as the argument to map-atoms, so it is called once for every | |
163 ;; symbol in obarray. Takes one argument SYMBOL, and finds any memory-resident | |
164 ;; documentation on that symbol if it matches a variable regexp. WARNING: this | |
165 ;; function depends on the symbols fn-doc var-doc regexp and item being bound | |
166 ;; correctly when it is called!" | |
167 | |
168 (defun super-apropos-accumulate (symbol) | |
169 (cond ((string-match regexp (symbol-name symbol)) | |
170 (setq item (apropos-get-accum-item symbol)) | |
171 (setcar (cdr item) (or (safe-documentation symbol) | |
172 (nth 1 item))) | |
173 (setcar (nthcdr 2 item) (or (safe-documentation-property symbol) | |
174 (nth 2 item)))) | |
175 (t | |
176 (and (setq fn-doc (safe-documentation symbol)) | |
177 (string-match regexp fn-doc) | |
178 (setcar (cdr (apropos-get-accum-item symbol)) fn-doc)) | |
179 (and (setq var-doc (safe-documentation-property symbol)) | |
180 (string-match regexp var-doc) | |
181 (setcar (nthcdr 2 (apropos-get-accum-item symbol)) var-doc)))) | |
182 nil) | |
183 | |
184 ;; Prints the symbols and documentation in alist MATCHES of form ((symbol | |
185 ;; fn-doc var-doc) ...). Uses optional argument REGEXP to speed up searching | |
186 ;; for keybindings. The names of all symbols in MATCHES must match REGEXP. | |
187 ;; Displays in the buffer pointed to by standard-output. Optional argument | |
188 ;; SPACING means put blank lines in between each symbol's documentation. | |
189 ;; Optional argument DO-ALL means do more time-consuming work, specifically, | |
190 ;; consulting key bindings. Should only be called within a | |
191 ;; with-output-to-temp-buffer. | |
192 | |
193 (defun apropos-print-matches (matches &optional regexp spacing do-all) | |
194 (setq matches (sort matches (function | |
195 (lambda (a b) | |
196 (string-lessp (car a) (car b)))))) | |
197 (let ((p matches) | |
198 (old-buffer (current-buffer)) | |
2946
1f24ead69a2f
(apropos-print-matches): Bind tem.
Richard M. Stallman <rms@gnu.org>
parents:
2937
diff
changeset
|
199 item keys-done symbol tem) |
367 | 200 (save-excursion |
201 (set-buffer standard-output) | |
202 (or matches (princ "No matches found.")) | |
203 (while (consp p) | |
204 (setq item (car p) | |
205 symbol (car item) | |
206 p (cdr p)) | |
207 (or (not spacing) (bobp) (terpri)) | |
208 (princ symbol) ;print symbol name | |
209 ;; don't calculate key-bindings unless needed | |
210 (cond ((and do-all (commandp symbol) (not keys-done)) | |
211 (save-excursion | |
212 (set-buffer old-buffer) | |
213 (apropos-match-keys matches regexp)) | |
214 (setq keys-done t))) | |
215 (cond ((and do-all | |
216 (or (setq tem (nthcdr 3 item)) | |
217 (commandp symbol))) | |
218 (indent-to 30 1) | |
219 (if tem | |
220 (princ (mapconcat 'key-description tem ", ")) | |
221 (princ "(not bound to any keys)")))) | |
222 (terpri) | |
223 (cond ((setq tem (nth 1 item)) | |
224 (princ " Function: ") | |
225 (princ (if do-all (substitute-command-keys tem) tem)))) | |
226 (or (bolp) (terpri)) | |
227 (cond ((setq tem (nth 2 item)) | |
228 (princ " Variable: ") | |
229 (princ (if do-all (substitute-command-keys tem) tem)))) | |
230 (or (bolp) (terpri))))) | |
231 t) | |
232 | |
233 ;; Find key bindings for symbols that are cars in ALIST. Optionally, first | |
234 ;; match the symbol name against REGEXP. Modifies ALIST in place. Each key | |
235 ;; binding is added as a string to the end of the list in ALIST whose car is | |
236 ;; the corresponding symbol. The pointer to ALIST is returned. | |
237 | |
238 (defun apropos-match-keys (alist &optional regexp) | |
239 (let* ((current-local-map (current-local-map)) | |
240 (maps (append (and current-local-map | |
241 (accessible-keymaps current-local-map)) | |
242 (accessible-keymaps (current-global-map)))) | |
243 map ;map we are now inspecting | |
244 sequence ;key sequence to reach map | |
245 i ;index into vector map | |
246 command ;what is bound to current keys | |
247 key ;last key to reach command | |
248 local ;local binding for sequence + key | |
249 item) ;symbol data item in alist | |
250 ;; examine all reachable keymaps | |
251 (while (consp maps) | |
252 (setq map (cdr (car maps)) | |
253 sequence (car (car maps)) ;keys to reach this map | |
254 maps (cdr maps)) | |
2937
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
255 ;; Skip the leading `keymap', doc string, etc. |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
256 (if (eq (car map) 'keymap) |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
257 (setq map (cdr map))) |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
258 (while (stringp (car-safe map)) |
367 | 259 (setq map (cdr map))) |
2937
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
260 (while (consp map) |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
261 (cond ((consp (car map)) |
367 | 262 (setq command (cdr (car map)) |
2937
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
263 key (car (car map))) |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
264 ;; Skip any menu prompt in this key binding. |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
265 (and (consp command) (symbolp (cdr command)) |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
266 (setq command (cdr command))) |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
267 ;; if is a symbol, and matches optional regexp, and is a car |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
268 ;; in alist, and is not shadowed by a different local binding, |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
269 ;; record it |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
270 (and (symbolp command) |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
271 (if regexp (string-match regexp (symbol-name command))) |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
272 (setq item (assq command alist)) |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
273 (if (or (vectorp sequence) (not (integerp key))) |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
274 (setq key (vconcat sequence (vector key))) |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
275 (setq key (concat sequence (char-to-string key)))) |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
276 ;; checking if shadowed by local binding. |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
277 ;; either no local map, no local binding, or runs off the |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
278 ;; binding tree (number), or is the same binding |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
279 (or (not current-local-map) |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
280 (not (setq local (lookup-key current-local-map key))) |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
281 (numberp local) |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
282 (eq command local)) |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
283 ;; add this key binding to the item in alist |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
284 (nconc item (cons key nil)))) |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
285 ((vectorp (car map)) |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
286 (let ((i 0) |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
287 (vec (car map)) |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
288 (len (length (car map)))) |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
289 (while (< i len) |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
290 (setq command (aref vec i)) |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
291 (setq key i) |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
292 ;; Skip any menu prompt in this key binding. |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
293 (and (consp command) (symbolp (cdr command)) |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
294 (setq command (cdr command))) |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
295 ;; This is the same as the code in the previous case. |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
296 (and (symbolp command) |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
297 (if regexp (string-match regexp (symbol-name command))) |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
298 (setq item (assq command alist)) |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
299 (if (or (vectorp sequence) (not (integerp key))) |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
300 (setq key (vconcat sequence (vector key))) |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
301 (setq key (concat sequence (char-to-string key)))) |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
302 ;; checking if shadowed by local binding. |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
303 ;; either no local map, no local binding, or runs off the |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
304 ;; binding tree (number), or is the same binding |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
305 (or (not current-local-map) |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
306 (not (setq local (lookup-key current-local-map key))) |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
307 (numberp local) |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
308 (eq command local)) |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
309 ;; add this key binding to the item in alist |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
310 (nconc item (cons key nil))) |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
311 (setq i (1+ i)))))) |
e38ff71093b5
(apropos-match-keys): Handle modern keymap structure.
Richard M. Stallman <rms@gnu.org>
parents:
2247
diff
changeset
|
312 (setq map (cdr map))))) |
367 | 313 alist) |
314 | |
315 ;; Get an alist item in alist apropos-accumulate whose car is SYMBOL. Creates | |
316 ;; the item if not already present. Modifies apropos-accumulate in place. | |
317 | |
318 (defun apropos-get-accum-item (symbol) | |
319 (or (assq symbol apropos-accumulate) | |
320 (progn | |
321 (setq apropos-accumulate | |
322 (cons (list symbol nil nil) apropos-accumulate)) | |
323 (assq symbol apropos-accumulate)))) | |
324 | |
325 (defun safe-documentation (function) | |
326 "Like documentation, except it avoids calling `get_doc_string'. | |
327 Will return nil instead." | |
328 (while (symbolp function) | |
329 (setq function (if (fboundp function) | |
330 (symbol-function function) | |
331 0))) | |
3563
804e4f30b7ce
(safe-documentation): Don't crash on byte-compiled macro.
Richard M. Stallman <rms@gnu.org>
parents:
2946
diff
changeset
|
332 (if (eq (car-safe function) 'macro) |
804e4f30b7ce
(safe-documentation): Don't crash on byte-compiled macro.
Richard M. Stallman <rms@gnu.org>
parents:
2946
diff
changeset
|
333 (setq function (cdr function))) |
367 | 334 (if (not (consp function)) |
335 nil | |
336 (if (not (memq (car function) '(lambda autoload))) | |
337 nil | |
338 (setq function (nth 2 function)) | |
339 (if (stringp function) | |
340 function | |
341 nil)))) | |
342 | |
343 (defun safe-documentation-property (symbol) | |
344 "Like documentation-property, except it avoids calling `get_doc_string'. | |
345 Will return nil instead." | |
346 (setq symbol (get symbol 'variable-documentation)) | |
347 (if (numberp symbol) | |
348 nil | |
349 symbol)) | |
350 | |
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
444
diff
changeset
|
351 ;;; apropos.el ends here |