Mercurial > emacs
annotate lisp/apropos.el @ 36224:600506f65cbf
Fix copyright notice.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Tue, 20 Feb 2001 12:30:16 +0000 |
parents | d2f15377cc82 |
children | b174db545cfd |
rev | line source |
---|---|
12498
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
1 ;;; apropos.el --- apropos commands for users and programmers. |
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
444
diff
changeset
|
2 |
12498
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
3 ;; Copyright (C) 1989, 1994, 1995 Free Software Foundation, Inc. |
845 | 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> |
23867 | 6 ;; Rewritten: Daniel Pfeiffer <occitan@esperanto.org> |
2247
2c7997f249eb
Add or correct keywords
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1894
diff
changeset
|
7 ;; Keywords: help |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
8 |
367 | 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 | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
13 ;; the Free Software Foundation; either version 2, or (at your option) |
367 | 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 | |
14169 | 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. | |
367 | 25 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
26 ;;; Commentary: |
367 | 27 |
28 ;; The ideas for this package were derived from the C code in | |
29 ;; src/keymap.c and elsewhere. The functions in this file should | |
30 ;; always be byte-compiled for speed. Someone should rewrite this in | |
31 ;; C (as part of src/keymap.c) for speed. | |
32 | |
33 ;; The idea for super-apropos is based on the original implementation | |
34 ;; by Lynn Slater <lrs@esl.com>. | |
35 | |
36 ;; History: | |
37 ;; Fixed bug, current-local-map can return nil. | |
38 ;; Change, doesn't calculate key-bindings unless needed. | |
39 ;; Added super-apropos capability, changed print functions. | |
12498
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
40 ;;; Made fast-apropos and super-apropos share code. |
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
41 ;;; Sped up fast-apropos again. |
367 | 42 ;; Added apropos-do-all option. |
12498
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
43 ;;; Added fast-command-apropos. |
367 | 44 ;; Changed doc strings to comments for helping functions. |
12498
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
45 ;;; Made doc file buffer read-only, buried it. |
367 | 46 ;; Only call substitute-command-keys if do-all set. |
47 | |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
48 ;; Optionally use configurable faces to make the output more legible. |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
49 ;; Differentiate between command, function and macro. |
12498
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
50 ;; Apropos-command (ex command-apropos) does cmd and optionally user var. |
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
51 ;; Apropos shows all 3 aspects of symbols (fn, var and plist) |
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
52 ;; Apropos-documentation (ex super-apropos) now finds all it should. |
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
53 ;; New apropos-value snoops through all values and optionally plists. |
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
54 ;; Reading DOC file doesn't load nroff. |
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
55 ;; Added hypertext following of documentation, mouse-2 on variable gives value |
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
56 ;; from buffer in active window. |
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
57 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
58 ;;; Code: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
59 |
18941 | 60 (defgroup apropos nil |
61 "Apropos commands for users and programmers" | |
25297
bbfc1bd58fcc
Don't capitalize custom group name.
Dave Love <fx@gnu.org>
parents:
23867
diff
changeset
|
62 :group 'help |
18941 | 63 :prefix "apropos") |
64 | |
12498
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
65 ;; I see a degradation of maybe 10-20% only. |
18941 | 66 (defcustom apropos-do-all nil |
12498
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
67 "*Whether the apropos commands should do more. |
18941 | 68 |
69 Slows them down more or less. Set this non-nil if you have a fast machine." | |
70 :group 'apropos | |
71 :type 'boolean) | |
12498
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
72 |
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
73 |
25752
bb28bbb732db
(apropos-symbol-face): Non-nil even for ttys.
Richard M. Stallman <rms@gnu.org>
parents:
25297
diff
changeset
|
74 (defcustom apropos-symbol-face 'bold |
bb28bbb732db
(apropos-symbol-face): Non-nil even for ttys.
Richard M. Stallman <rms@gnu.org>
parents:
25297
diff
changeset
|
75 "*Face for symbol name in Apropos output, or nil for none." |
18941 | 76 :group 'apropos |
77 :type 'face) | |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
78 |
25752
bb28bbb732db
(apropos-symbol-face): Non-nil even for ttys.
Richard M. Stallman <rms@gnu.org>
parents:
25297
diff
changeset
|
79 (defcustom apropos-keybinding-face 'underline |
bb28bbb732db
(apropos-symbol-face): Non-nil even for ttys.
Richard M. Stallman <rms@gnu.org>
parents:
25297
diff
changeset
|
80 "*Face for lists of keybinding in Apropos output, or nil for none." |
18941 | 81 :group 'apropos |
82 :type 'face) | |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
83 |
25752
bb28bbb732db
(apropos-symbol-face): Non-nil even for ttys.
Richard M. Stallman <rms@gnu.org>
parents:
25297
diff
changeset
|
84 (defcustom apropos-label-face 'italic |
bb28bbb732db
(apropos-symbol-face): Non-nil even for ttys.
Richard M. Stallman <rms@gnu.org>
parents:
25297
diff
changeset
|
85 "*Face for label (`Command', `Variable' ...) in Apropos output. |
bb28bbb732db
(apropos-symbol-face): Non-nil even for ttys.
Richard M. Stallman <rms@gnu.org>
parents:
25297
diff
changeset
|
86 A value of nil means don't use any special font for them, and also |
bb28bbb732db
(apropos-symbol-face): Non-nil even for ttys.
Richard M. Stallman <rms@gnu.org>
parents:
25297
diff
changeset
|
87 turns off mouse highlighting." |
18941 | 88 :group 'apropos |
89 :type 'face) | |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
90 |
25752
bb28bbb732db
(apropos-symbol-face): Non-nil even for ttys.
Richard M. Stallman <rms@gnu.org>
parents:
25297
diff
changeset
|
91 (defcustom apropos-property-face 'bold-italic |
bb28bbb732db
(apropos-symbol-face): Non-nil even for ttys.
Richard M. Stallman <rms@gnu.org>
parents:
25297
diff
changeset
|
92 "*Face for property name in apropos output, or nil for none." |
18941 | 93 :group 'apropos |
94 :type 'face) | |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
95 |
25752
bb28bbb732db
(apropos-symbol-face): Non-nil even for ttys.
Richard M. Stallman <rms@gnu.org>
parents:
25297
diff
changeset
|
96 (defcustom apropos-match-face 'secondary-selection |
bb28bbb732db
(apropos-symbol-face): Non-nil even for ttys.
Richard M. Stallman <rms@gnu.org>
parents:
25297
diff
changeset
|
97 "*Face for matching text in Apropos documentation/value, or nil for none. |
bb28bbb732db
(apropos-symbol-face): Non-nil even for ttys.
Richard M. Stallman <rms@gnu.org>
parents:
25297
diff
changeset
|
98 This applies when you look for matches in the documentation or variable value |
bb28bbb732db
(apropos-symbol-face): Non-nil even for ttys.
Richard M. Stallman <rms@gnu.org>
parents:
25297
diff
changeset
|
99 for the regexp; the part that matches gets displayed in this font." |
18941 | 100 :group 'apropos |
101 :type 'face) | |
12498
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
102 |
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
103 |
13752
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
104 (defvar apropos-mode-map |
12498
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
105 (let ((map (make-sparse-keymap))) |
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
106 (define-key map "\C-m" 'apropos-follow) |
21897
7f104a4fc567
(apropos-mode-map): Bind q to quit-window.
Richard M. Stallman <rms@gnu.org>
parents:
20508
diff
changeset
|
107 (define-key map " " 'scroll-up) |
7f104a4fc567
(apropos-mode-map): Bind q to quit-window.
Richard M. Stallman <rms@gnu.org>
parents:
20508
diff
changeset
|
108 (define-key map "\177" 'scroll-down) |
7f104a4fc567
(apropos-mode-map): Bind q to quit-window.
Richard M. Stallman <rms@gnu.org>
parents:
20508
diff
changeset
|
109 (define-key map "q" 'quit-window) |
12498
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
110 (define-key map [mouse-2] 'apropos-mouse-follow) |
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
111 (define-key map [down-mouse-2] nil) |
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
112 map) |
13752
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
113 "Keymap used in Apropos mode.") |
12498
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
114 |
29498 | 115 (defvar apropos-mode-hook nil |
116 "*Hook run when mode is turned on.") | |
12498
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
117 |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
118 (defvar apropos-regexp nil |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
119 "Regexp used in current apropos run.") |
367 | 120 |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
121 (defvar apropos-files-scanned () |
13965
3453c54100b5
(apropos-files-scanned): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
13752
diff
changeset
|
122 "List of elc files already scanned in current run of `apropos-documentation'.") |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
123 |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
124 (defvar apropos-accumulator () |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
125 "Alist of symbols already found in current apropos run.") |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
126 |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
127 (defvar apropos-item () |
29764 | 128 "Current item in or for `apropos-accumulator'.") |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
129 |
26719
8a6fd8991465
(apropos-mode): Add autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
25752
diff
changeset
|
130 ;;;###autoload |
32147
f7c3f0fff3e7
(apropos-mode): Use define-derived-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29764
diff
changeset
|
131 (define-derived-mode apropos-mode fundamental-mode "Apropos" |
13752
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
132 "Major mode for following hyperlinks in output of apropos commands. |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
133 |
32147
f7c3f0fff3e7
(apropos-mode): Use define-derived-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29764
diff
changeset
|
134 \\{apropos-mode-map}") |
13752
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
135 |
20335
445110a43268
(apropos-variable): New command.
Richard M. Stallman <rms@gnu.org>
parents:
20208
diff
changeset
|
136 ;;;###autoload |
22218
eb4deede0c5a
(apropos-command): Change 3rd arg to VAR-PREDICATE
Richard M. Stallman <rms@gnu.org>
parents:
22182
diff
changeset
|
137 (defun apropos-variable (regexp &optional do-all) |
eb4deede0c5a
(apropos-command): Change 3rd arg to VAR-PREDICATE
Richard M. Stallman <rms@gnu.org>
parents:
22182
diff
changeset
|
138 "Show user variables that match REGEXP. |
29764 | 139 With optional prefix DO-ALL or if `apropos-do-all' is non-nil, also show |
22218
eb4deede0c5a
(apropos-command): Change 3rd arg to VAR-PREDICATE
Richard M. Stallman <rms@gnu.org>
parents:
22182
diff
changeset
|
140 normal variables." |
eb4deede0c5a
(apropos-command): Change 3rd arg to VAR-PREDICATE
Richard M. Stallman <rms@gnu.org>
parents:
22182
diff
changeset
|
141 (interactive (list (read-string |
eb4deede0c5a
(apropos-command): Change 3rd arg to VAR-PREDICATE
Richard M. Stallman <rms@gnu.org>
parents:
22182
diff
changeset
|
142 (concat "Apropos " |
eb4deede0c5a
(apropos-command): Change 3rd arg to VAR-PREDICATE
Richard M. Stallman <rms@gnu.org>
parents:
22182
diff
changeset
|
143 (if (or current-prefix-arg apropos-do-all) |
eb4deede0c5a
(apropos-command): Change 3rd arg to VAR-PREDICATE
Richard M. Stallman <rms@gnu.org>
parents:
22182
diff
changeset
|
144 "variable" |
eb4deede0c5a
(apropos-command): Change 3rd arg to VAR-PREDICATE
Richard M. Stallman <rms@gnu.org>
parents:
22182
diff
changeset
|
145 "user option") |
eb4deede0c5a
(apropos-command): Change 3rd arg to VAR-PREDICATE
Richard M. Stallman <rms@gnu.org>
parents:
22182
diff
changeset
|
146 " (regexp): ")) |
eb4deede0c5a
(apropos-command): Change 3rd arg to VAR-PREDICATE
Richard M. Stallman <rms@gnu.org>
parents:
22182
diff
changeset
|
147 current-prefix-arg)) |
eb4deede0c5a
(apropos-command): Change 3rd arg to VAR-PREDICATE
Richard M. Stallman <rms@gnu.org>
parents:
22182
diff
changeset
|
148 (apropos-command regexp nil |
22326
a049e7c748d9
(apropos-variable): Fixed argument to apropos-command.
Karl Heuer <kwzh@gnu.org>
parents:
22219
diff
changeset
|
149 (if (or do-all apropos-do-all) |
22218
eb4deede0c5a
(apropos-command): Change 3rd arg to VAR-PREDICATE
Richard M. Stallman <rms@gnu.org>
parents:
22182
diff
changeset
|
150 #'(lambda (symbol) |
eb4deede0c5a
(apropos-command): Change 3rd arg to VAR-PREDICATE
Richard M. Stallman <rms@gnu.org>
parents:
22182
diff
changeset
|
151 (and (boundp symbol) |
eb4deede0c5a
(apropos-command): Change 3rd arg to VAR-PREDICATE
Richard M. Stallman <rms@gnu.org>
parents:
22182
diff
changeset
|
152 (get symbol 'variable-documentation))) |
eb4deede0c5a
(apropos-command): Change 3rd arg to VAR-PREDICATE
Richard M. Stallman <rms@gnu.org>
parents:
22182
diff
changeset
|
153 'user-variable-p))) |
13752
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
154 |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
155 ;; For auld lang syne: |
12498
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
156 ;;;###autoload |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
157 (fset 'command-apropos 'apropos-command) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
158 ;;;###autoload |
22218
eb4deede0c5a
(apropos-command): Change 3rd arg to VAR-PREDICATE
Richard M. Stallman <rms@gnu.org>
parents:
22182
diff
changeset
|
159 (defun apropos-command (apropos-regexp &optional do-all var-predicate) |
29764 | 160 "Show commands (interactively callable functions) that match APROPOS-REGEXP. |
161 With optional prefix DO-ALL, or if `apropos-do-all' is non-nil, also show | |
22219
0d635ed37f07
(apropos-command): If DO-ALL is set, search functions, not variables.
Richard M. Stallman <rms@gnu.org>
parents:
22218
diff
changeset
|
162 noninteractive functions. |
22218
eb4deede0c5a
(apropos-command): Change 3rd arg to VAR-PREDICATE
Richard M. Stallman <rms@gnu.org>
parents:
22182
diff
changeset
|
163 |
22219
0d635ed37f07
(apropos-command): If DO-ALL is set, search functions, not variables.
Richard M. Stallman <rms@gnu.org>
parents:
22218
diff
changeset
|
164 If VAR-PREDICATE is non-nil, show only variables, and only those that |
22218
eb4deede0c5a
(apropos-command): Change 3rd arg to VAR-PREDICATE
Richard M. Stallman <rms@gnu.org>
parents:
22182
diff
changeset
|
165 satisfy the predicate VAR-PREDICATE." |
20335
445110a43268
(apropos-variable): New command.
Richard M. Stallman <rms@gnu.org>
parents:
20208
diff
changeset
|
166 (interactive (list (read-string (concat |
445110a43268
(apropos-variable): New command.
Richard M. Stallman <rms@gnu.org>
parents:
20208
diff
changeset
|
167 "Apropos command " |
445110a43268
(apropos-variable): New command.
Richard M. Stallman <rms@gnu.org>
parents:
20208
diff
changeset
|
168 (if (or current-prefix-arg |
445110a43268
(apropos-variable): New command.
Richard M. Stallman <rms@gnu.org>
parents:
20208
diff
changeset
|
169 apropos-do-all) |
22219
0d635ed37f07
(apropos-command): If DO-ALL is set, search functions, not variables.
Richard M. Stallman <rms@gnu.org>
parents:
22218
diff
changeset
|
170 "or function ") |
20335
445110a43268
(apropos-variable): New command.
Richard M. Stallman <rms@gnu.org>
parents:
20208
diff
changeset
|
171 "(regexp): ")) |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
172 current-prefix-arg)) |
12498
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
173 (let ((message |
13752
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
174 (let ((standard-output (get-buffer-create "*Apropos*"))) |
12498
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
175 (print-help-return-message 'identity)))) |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
176 (or do-all (setq do-all apropos-do-all)) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
177 (setq apropos-accumulator |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
178 (apropos-internal apropos-regexp |
22326
a049e7c748d9
(apropos-variable): Fixed argument to apropos-command.
Karl Heuer <kwzh@gnu.org>
parents:
22219
diff
changeset
|
179 (or var-predicate |
a049e7c748d9
(apropos-variable): Fixed argument to apropos-command.
Karl Heuer <kwzh@gnu.org>
parents:
22219
diff
changeset
|
180 (if do-all 'functionp 'commandp)))) |
20480
048c8ad9bcaa
(apropos, apropos-command): Ignore symbols that have apropos-inhibit property.
Richard M. Stallman <rms@gnu.org>
parents:
20335
diff
changeset
|
181 (let ((tem apropos-accumulator)) |
048c8ad9bcaa
(apropos, apropos-command): Ignore symbols that have apropos-inhibit property.
Richard M. Stallman <rms@gnu.org>
parents:
20335
diff
changeset
|
182 (while tem |
048c8ad9bcaa
(apropos, apropos-command): Ignore symbols that have apropos-inhibit property.
Richard M. Stallman <rms@gnu.org>
parents:
20335
diff
changeset
|
183 (if (get (car tem) 'apropos-inhibit) |
048c8ad9bcaa
(apropos, apropos-command): Ignore symbols that have apropos-inhibit property.
Richard M. Stallman <rms@gnu.org>
parents:
20335
diff
changeset
|
184 (setq apropos-accumulator (delq (car tem) apropos-accumulator))) |
048c8ad9bcaa
(apropos, apropos-command): Ignore symbols that have apropos-inhibit property.
Richard M. Stallman <rms@gnu.org>
parents:
20335
diff
changeset
|
185 (setq tem (cdr tem)))) |
22532
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
186 (let ((p apropos-accumulator) |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
187 doc symbol) |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
188 (while p |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
189 (setcar p (list |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
190 (setq symbol (car p)) |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
191 (unless var-predicate |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
192 (if (functionp symbol) |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
193 (if (setq doc (documentation symbol t)) |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
194 (substring doc 0 (string-match "\n" doc)) |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
195 "(not documented)"))) |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
196 (and var-predicate |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
197 (funcall var-predicate symbol) |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
198 (if (setq doc (documentation-property |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
199 symbol 'variable-documentation t)) |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
200 (substring doc 0 |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
201 (string-match "\n" doc)))))) |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
202 (setq p (cdr p)))) |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
203 (and (apropos-print t nil) |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
204 message |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
205 (message message)))) |
12498
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
206 |
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
207 |
367 | 208 ;;;###autoload |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
209 (defun apropos (apropos-regexp &optional do-all) |
29764 | 210 "Show all bound symbols whose names match APROPOS-REGEXP. |
211 With optional prefix DO-ALL or if `apropos-do-all' is non-nil, also | |
212 show unbound symbols and key bindings, which is a little more | |
213 time-consuming. Returns list of symbols and documentation found." | |
12498
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
214 (interactive "sApropos symbol (regexp): \nP") |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
215 (setq apropos-accumulator |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
216 (apropos-internal apropos-regexp |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
217 (and (not do-all) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
218 (not apropos-do-all) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
219 (lambda (symbol) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
220 (or (fboundp symbol) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
221 (boundp symbol) |
17417
c351a7e1880c
(apropos): Add support for faces, widgets, and user options.
Richard M. Stallman <rms@gnu.org>
parents:
17167
diff
changeset
|
222 (facep symbol) |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
223 (symbol-plist symbol)))))) |
20480
048c8ad9bcaa
(apropos, apropos-command): Ignore symbols that have apropos-inhibit property.
Richard M. Stallman <rms@gnu.org>
parents:
20335
diff
changeset
|
224 (let ((tem apropos-accumulator)) |
048c8ad9bcaa
(apropos, apropos-command): Ignore symbols that have apropos-inhibit property.
Richard M. Stallman <rms@gnu.org>
parents:
20335
diff
changeset
|
225 (while tem |
048c8ad9bcaa
(apropos, apropos-command): Ignore symbols that have apropos-inhibit property.
Richard M. Stallman <rms@gnu.org>
parents:
20335
diff
changeset
|
226 (if (get (car tem) 'apropos-inhibit) |
048c8ad9bcaa
(apropos, apropos-command): Ignore symbols that have apropos-inhibit property.
Richard M. Stallman <rms@gnu.org>
parents:
20335
diff
changeset
|
227 (setq apropos-accumulator (delq (car tem) apropos-accumulator))) |
048c8ad9bcaa
(apropos, apropos-command): Ignore symbols that have apropos-inhibit property.
Richard M. Stallman <rms@gnu.org>
parents:
20335
diff
changeset
|
228 (setq tem (cdr tem)))) |
22532
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
229 (let ((p apropos-accumulator) |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
230 symbol doc properties) |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
231 (while p |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
232 (setcar p (list |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
233 (setq symbol (car p)) |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
234 (when (fboundp symbol) |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
235 (if (setq doc (condition-case nil |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
236 (documentation symbol t) |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
237 (void-function |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
238 "(alias for undefined function)"))) |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
239 (substring doc 0 (string-match "\n" doc)) |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
240 "(not documented)")) |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
241 (when (boundp symbol) |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
242 (if (setq doc (documentation-property |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
243 symbol 'variable-documentation t)) |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
244 (substring doc 0 (string-match "\n" doc)) |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
245 "(not documented)")) |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
246 (when (setq properties (symbol-plist symbol)) |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
247 (setq doc (list (car properties))) |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
248 (while (setq properties (cdr (cdr properties))) |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
249 (setq doc (cons (car properties) doc))) |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
250 (mapconcat #'symbol-name (nreverse doc) " ")) |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
251 (when (get symbol 'widget-type) |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
252 (if (setq doc (documentation-property |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
253 symbol 'widget-documentation t)) |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
254 (substring doc 0 |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
255 (string-match "\n" doc)) |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
256 "(not documented)")) |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
257 (when (facep symbol) |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
258 (if (setq doc (documentation-property |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
259 symbol 'face-documentation t)) |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
260 (substring doc 0 |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
261 (string-match "\n" doc)) |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
262 "(not documented)")) |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
263 (when (get symbol 'custom-group) |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
264 (if (setq doc (documentation-property |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
265 symbol 'group-documentation t)) |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
266 (substring doc 0 |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
267 (string-match "\n" doc)) |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
268 "(not documented)")))) |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
269 (setq p (cdr p)))) |
12498
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
270 (apropos-print |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
271 (or do-all apropos-do-all) |
12498
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
272 nil)) |
367 | 273 |
274 | |
275 ;;;###autoload | |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
276 (defun apropos-value (apropos-regexp &optional do-all) |
29764 | 277 "Show all symbols whose value's printed image matches APROPOS-REGEXP. |
278 With optional prefix DO-ALL or if `apropos-do-all' is non-nil, also looks | |
12498
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
279 at the function and at the names and values of properties. |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
280 Returns list of symbols and values found." |
12498
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
281 (interactive "sApropos value (regexp): \nP") |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
282 (or do-all (setq do-all apropos-do-all)) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
283 (setq apropos-accumulator ()) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
284 (let (f v p) |
12498
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
285 (mapatoms |
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
286 (lambda (symbol) |
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
287 (setq f nil v nil p nil) |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
288 (or (memq symbol '(apropos-regexp do-all apropos-accumulator |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
289 symbol f v p)) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
290 (setq v (apropos-value-internal 'boundp symbol 'symbol-value))) |
12498
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
291 (if do-all |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
292 (setq f (apropos-value-internal 'fboundp symbol 'symbol-function) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
293 p (apropos-format-plist symbol "\n " t))) |
12498
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
294 (if (or f v p) |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
295 (setq apropos-accumulator (cons (list symbol f v p) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
296 apropos-accumulator)))))) |
22532
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
297 (apropos-print nil t)) |
12498
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
298 |
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
299 |
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
300 ;;;###autoload |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
301 (defun apropos-documentation (apropos-regexp &optional do-all) |
29764 | 302 "Show symbols whose documentation contain matches for APROPOS-REGEXP. |
303 With optional prefix DO-ALL or if `apropos-do-all' is non-nil, also use | |
12498
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
304 documentation that is not stored in the documentation file and show key |
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
305 bindings. |
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
306 Returns list of symbols and documentation found." |
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
307 (interactive "sApropos documentation (regexp): \nP") |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
308 (or do-all (setq do-all apropos-do-all)) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
309 (setq apropos-accumulator () apropos-files-scanned ()) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
310 (let ((standard-input (get-buffer-create " apropos-temp")) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
311 f v) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
312 (unwind-protect |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
313 (save-excursion |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
314 (set-buffer standard-input) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
315 (apropos-documentation-check-doc-file) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
316 (if do-all |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
317 (mapatoms |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
318 (lambda (symbol) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
319 (setq f (apropos-safe-documentation symbol) |
13752
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
320 v (get symbol 'variable-documentation)) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
321 (if (integerp v) (setq v)) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
322 (setq f (apropos-documentation-internal f) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
323 v (apropos-documentation-internal v)) |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
324 (if (or f v) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
325 (if (setq apropos-item |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
326 (cdr (assq symbol apropos-accumulator))) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
327 (progn |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
328 (if f |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
329 (setcar apropos-item f)) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
330 (if v |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
331 (setcar (cdr apropos-item) v))) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
332 (setq apropos-accumulator |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
333 (cons (list symbol f v) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
334 apropos-accumulator))))))) |
22532
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
335 (apropos-print nil t)) |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
336 (kill-buffer standard-input)))) |
12498
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
337 |
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
338 |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
339 (defun apropos-value-internal (predicate symbol function) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
340 (if (funcall predicate symbol) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
341 (progn |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
342 (setq symbol (prin1-to-string (funcall function symbol))) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
343 (if (string-match apropos-regexp symbol) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
344 (progn |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
345 (if apropos-match-face |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
346 (put-text-property (match-beginning 0) (match-end 0) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
347 'face apropos-match-face |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
348 symbol)) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
349 symbol))))) |
367 | 350 |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
351 (defun apropos-documentation-internal (doc) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
352 (if (consp doc) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
353 (apropos-documentation-check-elc-file (car doc)) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
354 (and doc |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
355 (string-match apropos-regexp doc) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
356 (progn |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
357 (if apropos-match-face |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
358 (put-text-property (match-beginning 0) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
359 (match-end 0) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
360 'face apropos-match-face |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
361 (setq doc (copy-sequence doc)))) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
362 doc)))) |
367 | 363 |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
364 (defun apropos-format-plist (pl sep &optional compare) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
365 (setq pl (symbol-plist pl)) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
366 (let (p p-out) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
367 (while pl |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
368 (setq p (format "%s %S" (car pl) (nth 1 pl))) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
369 (if (or (not compare) (string-match apropos-regexp p)) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
370 (if apropos-property-face |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
371 (put-text-property 0 (length (symbol-name (car pl))) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
372 'face apropos-property-face p)) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
373 (setq p nil)) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
374 (if p |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
375 (progn |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
376 (and compare apropos-match-face |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
377 (put-text-property (match-beginning 0) (match-end 0) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
378 'face apropos-match-face |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
379 p)) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
380 (setq p-out (concat p-out (if p-out sep) p)))) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
381 (setq pl (nthcdr 2 pl))) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
382 p-out)) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
383 |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
384 |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
385 ;; Finds all documentation related to APROPOS-REGEXP in internal-doc-file-name. |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
386 |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
387 (defun apropos-documentation-check-doc-file () |
13752
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
388 (let (type symbol (sepa 2) sepb beg end) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
389 (insert ?\^_) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
390 (backward-char) |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
391 (insert-file-contents (concat doc-directory internal-doc-file-name)) |
13752
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
392 (forward-char) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
393 (while (save-excursion |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
394 (setq sepb (search-forward "\^_")) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
395 (not (eobp))) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
396 (beginning-of-line 2) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
397 (if (save-restriction |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
398 (narrow-to-region (point) (1- sepb)) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
399 (re-search-forward apropos-regexp nil t)) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
400 (progn |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
401 (setq beg (match-beginning 0) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
402 end (point)) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
403 (goto-char (1+ sepa)) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
404 (or (setq type (if (eq ?F (preceding-char)) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
405 1 ; function documentation |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
406 2) ; variable documentation |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
407 symbol (read) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
408 beg (- beg (point) 1) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
409 end (- end (point) 1) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
410 doc (buffer-substring (1+ (point)) (1- sepb)) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
411 apropos-item (assq symbol apropos-accumulator)) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
412 (setq apropos-item (list symbol nil nil) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
413 apropos-accumulator (cons apropos-item |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
414 apropos-accumulator))) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
415 (if apropos-match-face |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
416 (put-text-property beg end 'face apropos-match-face doc)) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
417 (setcar (nthcdr type apropos-item) doc))) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
418 (setq sepa (goto-char sepb))))) |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
419 |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
420 (defun apropos-documentation-check-elc-file (file) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
421 (if (member file apropos-files-scanned) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
422 nil |
13752
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
423 (let (symbol doc beg end this-is-a-variable) |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
424 (setq apropos-files-scanned (cons file apropos-files-scanned)) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
425 (erase-buffer) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
426 (insert-file-contents file) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
427 (while (search-forward "\n#@" nil t) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
428 ;; Read the comment length, and advance over it. |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
429 (setq end (read) |
13752
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
430 beg (1+ (point)) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
431 end (+ (point) end -1)) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
432 (forward-char) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
433 (if (save-restriction |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
434 ;; match ^ and $ relative to doc string |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
435 (narrow-to-region beg end) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
436 (re-search-forward apropos-regexp nil t)) |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
437 (progn |
13752
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
438 (goto-char (+ end 2)) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
439 (setq doc (buffer-substring beg end) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
440 end (- (match-end 0) beg) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
441 beg (- (match-beginning 0) beg) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
442 this-is-a-variable (looking-at "(def\\(var\\|const\\) ") |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
443 symbol (progn |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
444 (skip-chars-forward "(a-z") |
13752
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
445 (forward-char) |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
446 (read)) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
447 symbol (if (consp symbol) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
448 (nth 1 symbol) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
449 symbol)) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
450 (if (if this-is-a-variable |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
451 (get symbol 'variable-documentation) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
452 (and (fboundp symbol) (apropos-safe-documentation symbol))) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
453 (progn |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
454 (or (setq apropos-item (assq symbol apropos-accumulator)) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
455 (setq apropos-item (list symbol nil nil) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
456 apropos-accumulator (cons apropos-item |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
457 apropos-accumulator))) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
458 (if apropos-match-face |
13752
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
459 (put-text-property beg end 'face apropos-match-face |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
460 doc)) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
461 (setcar (nthcdr (if this-is-a-variable 2 1) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
462 apropos-item) |
13752
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
463 doc))))))))) |
367 | 464 |
10283
1d1c5ea9eb86
(super-apropos-check-elc-file): New function.
Richard M. Stallman <rms@gnu.org>
parents:
10282
diff
changeset
|
465 |
367 | 466 |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
467 (defun apropos-safe-documentation (function) |
29764 | 468 "Like `documentation', except it avoids calling `get_doc_string'. |
367 | 469 Will return nil instead." |
12498
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
470 (while (and function (symbolp function)) |
367 | 471 (setq function (if (fboundp function) |
12498
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
472 (symbol-function function)))) |
3563
804e4f30b7ce
(safe-documentation): Don't crash on byte-compiled macro.
Richard M. Stallman <rms@gnu.org>
parents:
2946
diff
changeset
|
473 (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
|
474 (setq function (cdr function))) |
12498
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
475 (setq function (if (byte-code-function-p function) |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
476 (if (> (length function) 4) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
477 (aref function 4)) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
478 (if (eq (car-safe function) 'autoload) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
479 (nth 2 function) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
480 (if (eq (car-safe function) 'lambda) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
481 (if (stringp (nth 2 function)) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
482 (nth 2 function) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
483 (if (stringp (nth 3 function)) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
484 (nth 3 function))))))) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
485 (if (integerp function) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
486 nil |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
487 function)) |
12498
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
488 |
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
489 |
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
490 |
25752
bb28bbb732db
(apropos-symbol-face): Non-nil even for ttys.
Richard M. Stallman <rms@gnu.org>
parents:
25297
diff
changeset
|
491 (defvar apropos-label-properties nil |
bb28bbb732db
(apropos-symbol-face): Non-nil even for ttys.
Richard M. Stallman <rms@gnu.org>
parents:
25297
diff
changeset
|
492 "List of face properties to use for a label. |
bb28bbb732db
(apropos-symbol-face): Non-nil even for ttys.
Richard M. Stallman <rms@gnu.org>
parents:
25297
diff
changeset
|
493 Bound by `apropos-print' for use by `apropos-print-doc'.") |
bb28bbb732db
(apropos-symbol-face): Non-nil even for ttys.
Richard M. Stallman <rms@gnu.org>
parents:
25297
diff
changeset
|
494 |
22532
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
495 (defun apropos-print (do-keys spacing) |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
496 "Output result of apropos searching into buffer `*Apropos*'. |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
497 The value of `apropos-accumulator' is the list of items to output. |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
498 Each element should have the format (SYMBOL FN-DOC VAR-DOC [PLIST-DOC]). |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
499 The return value is the list that was in `apropos-accumulator', sorted |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
500 alphabetically by symbol name; but this function also sets |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
501 `apropos-accumulator' to nil before returning." |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
502 (if (null apropos-accumulator) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
503 (message "No apropos matches for `%s'" apropos-regexp) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
504 (setq apropos-accumulator |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
505 (sort apropos-accumulator (lambda (a b) |
13752
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
506 (string-lessp (car a) (car b))))) |
25752
bb28bbb732db
(apropos-symbol-face): Non-nil even for ttys.
Richard M. Stallman <rms@gnu.org>
parents:
25297
diff
changeset
|
507 (setq apropos-label-properties |
bb28bbb732db
(apropos-symbol-face): Non-nil even for ttys.
Richard M. Stallman <rms@gnu.org>
parents:
25297
diff
changeset
|
508 (if (and apropos-label-face |
bb28bbb732db
(apropos-symbol-face): Non-nil even for ttys.
Richard M. Stallman <rms@gnu.org>
parents:
25297
diff
changeset
|
509 (symbolp apropos-label-face)) |
bb28bbb732db
(apropos-symbol-face): Non-nil even for ttys.
Richard M. Stallman <rms@gnu.org>
parents:
25297
diff
changeset
|
510 `(face ,apropos-label-face |
33921
d2f15377cc82
(apropos-print): Add help-echo to active text.
Dave Love <fx@gnu.org>
parents:
32147
diff
changeset
|
511 mouse-face highlight |
d2f15377cc82
(apropos-print): Add help-echo to active text.
Dave Love <fx@gnu.org>
parents:
32147
diff
changeset
|
512 help-echo "mouse-2: display help on this item"))) |
13470
0bfd3ae57234
(apropos-print): Use buffer *Apropos*, not *Help*.
Richard M. Stallman <rms@gnu.org>
parents:
12640
diff
changeset
|
513 (with-output-to-temp-buffer "*Apropos*" |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
514 (let ((p apropos-accumulator) |
12498
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
515 (old-buffer (current-buffer)) |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
516 symbol item point1 point2) |
13752
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
517 (set-buffer standard-output) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
518 (apropos-mode) |
29199
cc07870ddb45
(apropos-print): Use display-mouse-p instead of
Eli Zaretskii <eliz@gnu.org>
parents:
28844
diff
changeset
|
519 (if (display-mouse-p) |
14150
1d9ae58b9e91
(apropos-print): Fix previous change to mouse message.
Erik Naggum <erik@naggum.no>
parents:
14104
diff
changeset
|
520 (insert "If you move the mouse over text that changes color,\n" |
1d9ae58b9e91
(apropos-print): Fix previous change to mouse message.
Erik Naggum <erik@naggum.no>
parents:
14104
diff
changeset
|
521 (substitute-command-keys |
14104
e61c666cef56
(apropos-print): Fix message about mouse command.
Karl Heuer <kwzh@gnu.org>
parents:
13965
diff
changeset
|
522 "you can click \\[apropos-mouse-follow] to get more information.\n"))) |
13752
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
523 (insert (substitute-command-keys |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
524 "In this buffer, type \\[apropos-follow] to get full documentation.\n\n")) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
525 (while (consp p) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
526 (or (not spacing) (bobp) (terpri)) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
527 (setq apropos-item (car p) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
528 symbol (car apropos-item) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
529 p (cdr p) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
530 point1 (point)) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
531 (princ symbol) ; print symbol name |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
532 (setq point2 (point)) |
14395
8e97dadccf2b
(apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
533 ;; Calculate key-bindings if we want them. |
13752
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
534 (and do-keys |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
535 (commandp symbol) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
536 (indent-to 30 1) |
14395
8e97dadccf2b
(apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
537 (if (let ((keys |
8e97dadccf2b
(apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
538 (save-excursion |
8e97dadccf2b
(apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
539 (set-buffer old-buffer) |
8e97dadccf2b
(apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
540 (where-is-internal symbol))) |
8e97dadccf2b
(apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
541 filtered) |
8e97dadccf2b
(apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
542 ;; Copy over the list of key sequences, |
8e97dadccf2b
(apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
543 ;; omitting any that contain a buffer or a frame. |
8e97dadccf2b
(apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
544 (while keys |
8e97dadccf2b
(apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
545 (let ((key (car keys)) |
8e97dadccf2b
(apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
546 (i 0) |
8e97dadccf2b
(apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
547 loser) |
8e97dadccf2b
(apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
548 (while (< i (length key)) |
8e97dadccf2b
(apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
549 (if (or (framep (aref key i)) |
8e97dadccf2b
(apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
550 (bufferp (aref key i))) |
8e97dadccf2b
(apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
551 (setq loser t)) |
8e97dadccf2b
(apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
552 (setq i (1+ i))) |
8e97dadccf2b
(apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
553 (or loser |
8e97dadccf2b
(apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
554 (setq filtered (cons key filtered)))) |
8e97dadccf2b
(apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
555 (setq keys (cdr keys))) |
8e97dadccf2b
(apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
556 (setq item filtered)) |
8e97dadccf2b
(apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
557 ;; Convert the remaining keys to a string and insert. |
8e97dadccf2b
(apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
558 (insert |
13752
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
559 (mapconcat |
14395
8e97dadccf2b
(apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
560 (lambda (key) |
29764 | 561 (setq key (condition-case () |
23386
ac8f85b1733c
(apropos-print): control invalid characters.
Karl Heuer <kwzh@gnu.org>
parents:
22532
diff
changeset
|
562 (key-description key) |
ac8f85b1733c
(apropos-print): control invalid characters.
Karl Heuer <kwzh@gnu.org>
parents:
22532
diff
changeset
|
563 (error))) |
14395
8e97dadccf2b
(apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
564 (if apropos-keybinding-face |
13752
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
565 (put-text-property 0 (length key) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
566 'face apropos-keybinding-face |
14395
8e97dadccf2b
(apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
567 key)) |
8e97dadccf2b
(apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
568 key) |
8e97dadccf2b
(apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
569 item ", ")) |
15159
b22de331ee43
(apropos-print): If command has no key bindings, say how to run it with M-x.
Richard M. Stallman <rms@gnu.org>
parents:
14400
diff
changeset
|
570 (insert "M-x") |
b22de331ee43
(apropos-print): If command has no key bindings, say how to run it with M-x.
Richard M. Stallman <rms@gnu.org>
parents:
14400
diff
changeset
|
571 (put-text-property (- (point) 3) (point) |
b22de331ee43
(apropos-print): If command has no key bindings, say how to run it with M-x.
Richard M. Stallman <rms@gnu.org>
parents:
14400
diff
changeset
|
572 'face apropos-keybinding-face) |
b22de331ee43
(apropos-print): If command has no key bindings, say how to run it with M-x.
Richard M. Stallman <rms@gnu.org>
parents:
14400
diff
changeset
|
573 (insert " " (symbol-name symbol) " ") |
b22de331ee43
(apropos-print): If command has no key bindings, say how to run it with M-x.
Richard M. Stallman <rms@gnu.org>
parents:
14400
diff
changeset
|
574 (insert "RET") |
b22de331ee43
(apropos-print): If command has no key bindings, say how to run it with M-x.
Richard M. Stallman <rms@gnu.org>
parents:
14400
diff
changeset
|
575 (put-text-property (- (point) 3) (point) |
b22de331ee43
(apropos-print): If command has no key bindings, say how to run it with M-x.
Richard M. Stallman <rms@gnu.org>
parents:
14400
diff
changeset
|
576 'face apropos-keybinding-face))) |
13752
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
577 (terpri) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
578 ;; only now so we don't propagate text attributes all over |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
579 (put-text-property point1 point2 'item |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
580 (if (eval `(or ,@(cdr apropos-item))) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
581 (car apropos-item) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
582 apropos-item)) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
583 (if apropos-symbol-face |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
584 (put-text-property point1 point2 'face apropos-symbol-face)) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
585 (apropos-print-doc 'describe-function 1 |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
586 (if (commandp symbol) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
587 "Command" |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
588 (if (apropos-macrop symbol) |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
589 "Macro" |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
590 "Function")) |
20508
16f1fd128350
(apropos-print): Pass t instead of DO-KEYS
Richard M. Stallman <rms@gnu.org>
parents:
20480
diff
changeset
|
591 t) |
28844
a6e1babce2a1
(apropos-print): use `describe-face' instead of
Dave Love <fx@gnu.org>
parents:
26719
diff
changeset
|
592 ;; We used to use `customize-variable-other-window' instead |
22408
500bc7f67524
(apropos-print): The cross ref for a variable
Richard M. Stallman <rms@gnu.org>
parents:
22326
diff
changeset
|
593 ;; for a customizable variable, but that is slow. |
500bc7f67524
(apropos-print): The cross ref for a variable
Richard M. Stallman <rms@gnu.org>
parents:
22326
diff
changeset
|
594 ;; It is better to show an ordinary help buffer |
500bc7f67524
(apropos-print): The cross ref for a variable
Richard M. Stallman <rms@gnu.org>
parents:
22326
diff
changeset
|
595 ;; and let the user click on the customization button |
500bc7f67524
(apropos-print): The cross ref for a variable
Richard M. Stallman <rms@gnu.org>
parents:
22326
diff
changeset
|
596 ;; in that buffer, if he wants to. |
28844
a6e1babce2a1
(apropos-print): use `describe-face' instead of
Dave Love <fx@gnu.org>
parents:
26719
diff
changeset
|
597 ;; Likewise for `customize-face-other-window'. |
22408
500bc7f67524
(apropos-print): The cross ref for a variable
Richard M. Stallman <rms@gnu.org>
parents:
22326
diff
changeset
|
598 (apropos-print-doc 'describe-variable 2 "Variable" t) |
20508
16f1fd128350
(apropos-print): Pass t instead of DO-KEYS
Richard M. Stallman <rms@gnu.org>
parents:
20480
diff
changeset
|
599 (apropos-print-doc 'customize-group-other-window 6 "Group" t) |
28844
a6e1babce2a1
(apropos-print): use `describe-face' instead of
Dave Love <fx@gnu.org>
parents:
26719
diff
changeset
|
600 (apropos-print-doc 'describe-face 5 "Face" t) |
20508
16f1fd128350
(apropos-print): Pass t instead of DO-KEYS
Richard M. Stallman <rms@gnu.org>
parents:
20480
diff
changeset
|
601 (apropos-print-doc 'widget-browse-other-window 4 "Widget" t) |
13752
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
602 (apropos-print-doc 'apropos-describe-plist 3 |
22532
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
603 "Plist" nil)) |
5a83f0f3b29d
(apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents:
22408
diff
changeset
|
604 (setq buffer-read-only t)))) |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
605 (prog1 apropos-accumulator |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
606 (setq apropos-accumulator ()))) ; permit gc |
12498
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
607 |
367 | 608 |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
609 (defun apropos-macrop (symbol) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
610 "T if SYMBOL is a Lisp macro." |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
611 (and (fboundp symbol) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
612 (consp (setq symbol |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
613 (symbol-function symbol))) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
614 (or (eq (car symbol) 'macro) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
615 (if (eq (car symbol) 'autoload) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
616 (memq (nth 4 symbol) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
617 '(macro t)))))) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
618 |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
619 |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
620 (defun apropos-print-doc (action i str do-keys) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
621 (if (stringp (setq i (nth i apropos-item))) |
12498
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
622 (progn |
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
623 (insert " ") |
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
624 (put-text-property (- (point) 2) (1- (point)) |
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
625 'action action) |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
626 (insert str ": ") |
25752
bb28bbb732db
(apropos-symbol-face): Non-nil even for ttys.
Richard M. Stallman <rms@gnu.org>
parents:
25297
diff
changeset
|
627 (if apropos-label-properties |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
628 (add-text-properties (- (point) (length str) 2) |
12498
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
629 (1- (point)) |
25752
bb28bbb732db
(apropos-symbol-face): Non-nil even for ttys.
Richard M. Stallman <rms@gnu.org>
parents:
25297
diff
changeset
|
630 apropos-label-properties)) |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
631 (insert (if do-keys (substitute-command-keys i) i)) |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
632 (or (bolp) (terpri))))) |
12498
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
633 |
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
634 |
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
635 (defun apropos-mouse-follow (event) |
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
636 (interactive "e") |
13752
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
637 (let ((other (if (eq (current-buffer) (get-buffer "*Apropos*")) |
12498
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
638 () |
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
639 (current-buffer)))) |
13656
b5b44ae33653
(apropos-follow): Rewrite to use whole line as target of reference.
Richard M. Stallman <rms@gnu.org>
parents:
13621
diff
changeset
|
640 (save-excursion |
b5b44ae33653
(apropos-follow): Rewrite to use whole line as target of reference.
Richard M. Stallman <rms@gnu.org>
parents:
13621
diff
changeset
|
641 (set-buffer (window-buffer (posn-window (event-start event)))) |
b5b44ae33653
(apropos-follow): Rewrite to use whole line as target of reference.
Richard M. Stallman <rms@gnu.org>
parents:
13621
diff
changeset
|
642 (goto-char (posn-point (event-start event))) |
b5b44ae33653
(apropos-follow): Rewrite to use whole line as target of reference.
Richard M. Stallman <rms@gnu.org>
parents:
13621
diff
changeset
|
643 (or (and (not (eobp)) (get-text-property (point) 'mouse-face)) |
b5b44ae33653
(apropos-follow): Rewrite to use whole line as target of reference.
Richard M. Stallman <rms@gnu.org>
parents:
13621
diff
changeset
|
644 (and (not (bobp)) (get-text-property (1- (point)) 'mouse-face)) |
b5b44ae33653
(apropos-follow): Rewrite to use whole line as target of reference.
Richard M. Stallman <rms@gnu.org>
parents:
13621
diff
changeset
|
645 (error "There is nothing to follow here")) |
b5b44ae33653
(apropos-follow): Rewrite to use whole line as target of reference.
Richard M. Stallman <rms@gnu.org>
parents:
13621
diff
changeset
|
646 (apropos-follow other)))) |
12498
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
647 |
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
648 |
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
649 (defun apropos-follow (&optional other) |
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
650 (interactive) |
13656
b5b44ae33653
(apropos-follow): Rewrite to use whole line as target of reference.
Richard M. Stallman <rms@gnu.org>
parents:
13621
diff
changeset
|
651 (let* (;; Properties are always found at the beginning of the line. |
b5b44ae33653
(apropos-follow): Rewrite to use whole line as target of reference.
Richard M. Stallman <rms@gnu.org>
parents:
13621
diff
changeset
|
652 (bol (save-excursion (beginning-of-line) (point))) |
b5b44ae33653
(apropos-follow): Rewrite to use whole line as target of reference.
Richard M. Stallman <rms@gnu.org>
parents:
13621
diff
changeset
|
653 ;; If there is no `item' property here, look behind us. |
b5b44ae33653
(apropos-follow): Rewrite to use whole line as target of reference.
Richard M. Stallman <rms@gnu.org>
parents:
13621
diff
changeset
|
654 (item (get-text-property bol 'item)) |
b5b44ae33653
(apropos-follow): Rewrite to use whole line as target of reference.
Richard M. Stallman <rms@gnu.org>
parents:
13621
diff
changeset
|
655 (item-at (if item nil (previous-single-property-change bol 'item))) |
b5b44ae33653
(apropos-follow): Rewrite to use whole line as target of reference.
Richard M. Stallman <rms@gnu.org>
parents:
13621
diff
changeset
|
656 ;; Likewise, if there is no `action' property here, look in front. |
b5b44ae33653
(apropos-follow): Rewrite to use whole line as target of reference.
Richard M. Stallman <rms@gnu.org>
parents:
13621
diff
changeset
|
657 (action (get-text-property bol 'action)) |
b5b44ae33653
(apropos-follow): Rewrite to use whole line as target of reference.
Richard M. Stallman <rms@gnu.org>
parents:
13621
diff
changeset
|
658 (action-at (if action nil (next-single-property-change bol 'action)))) |
b5b44ae33653
(apropos-follow): Rewrite to use whole line as target of reference.
Richard M. Stallman <rms@gnu.org>
parents:
13621
diff
changeset
|
659 (and (null item) item-at |
b5b44ae33653
(apropos-follow): Rewrite to use whole line as target of reference.
Richard M. Stallman <rms@gnu.org>
parents:
13621
diff
changeset
|
660 (setq item (get-text-property (1- item-at) 'item))) |
b5b44ae33653
(apropos-follow): Rewrite to use whole line as target of reference.
Richard M. Stallman <rms@gnu.org>
parents:
13621
diff
changeset
|
661 (and (null action) action-at |
b5b44ae33653
(apropos-follow): Rewrite to use whole line as target of reference.
Richard M. Stallman <rms@gnu.org>
parents:
13621
diff
changeset
|
662 (setq action (get-text-property action-at 'action))) |
b5b44ae33653
(apropos-follow): Rewrite to use whole line as target of reference.
Richard M. Stallman <rms@gnu.org>
parents:
13621
diff
changeset
|
663 (if (not (and item action)) |
13621
57b72553e78d
(apropos-print): Put the item property
Richard M. Stallman <rms@gnu.org>
parents:
13611
diff
changeset
|
664 (error "There is nothing to follow here")) |
13656
b5b44ae33653
(apropos-follow): Rewrite to use whole line as target of reference.
Richard M. Stallman <rms@gnu.org>
parents:
13621
diff
changeset
|
665 (if (consp item) (error "There is nothing to follow in `%s'" (car item))) |
b5b44ae33653
(apropos-follow): Rewrite to use whole line as target of reference.
Richard M. Stallman <rms@gnu.org>
parents:
13621
diff
changeset
|
666 (if other (set-buffer other)) |
b5b44ae33653
(apropos-follow): Rewrite to use whole line as target of reference.
Richard M. Stallman <rms@gnu.org>
parents:
13621
diff
changeset
|
667 (funcall action item))) |
12498
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
668 |
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
669 |
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
670 |
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
671 (defun apropos-describe-plist (symbol) |
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
672 "Display a pretty listing of SYMBOL's plist." |
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
673 (with-output-to-temp-buffer "*Help*" |
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
674 (set-buffer standard-output) |
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
675 (princ "Symbol ") |
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
676 (prin1 symbol) |
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
677 (princ "'s plist is\n (") |
12640
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
678 (if apropos-symbol-face |
d194c63cb75c
Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents:
12498
diff
changeset
|
679 (put-text-property 8 (- (point) 14) 'face apropos-symbol-face)) |
12498
9fb6a9b6658b
Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents:
11190
diff
changeset
|
680 (insert (apropos-format-plist symbol "\n ")) |
13752
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
681 (princ ")") |
e3b945c8141e
(apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents:
13656
diff
changeset
|
682 (print-help-return-message))) |
367 | 683 |
18383 | 684 (provide 'apropos) |
685 | |
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
444
diff
changeset
|
686 ;;; apropos.el ends here |