annotate lisp/packages/apropos.el @ 2:ac2d302a0011 r19-15b2

Import from CVS: tag r19-15b2
author cvs
date Mon, 13 Aug 2007 08:46:35 +0200
parents 376386a54a3c
children b82b59fe008d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; apropos.el --- apropos commands for users and programmers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Copyright (C) 1989, 1994, 1995 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Author: Joe Wells <jbw@bigbird.bu.edu>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Rewritten: Daniel.Pfeiffer@Informatik.START.dbp.de, fax (+49 69) 7588-2389
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; Keywords: help
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;; Boston, MA 02111-1307, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
26 ;;; Synched up with: FSF 19.34.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; The ideas for this package were derived from the C code in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;; src/keymap.c and elsewhere. The functions in this file should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; always be byte-compiled for speed. Someone should rewrite this in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;; C (as part of src/keymap.c) for speed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;; The idea for super-apropos is based on the original implementation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;; by Lynn Slater <lrs@esl.com>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;; History:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;; Fixed bug, current-local-map can return nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;; Change, doesn't calculate key-bindings unless needed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;; Added super-apropos capability, changed print functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;;; Made fast-apropos and super-apropos share code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;;; Sped up fast-apropos again.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;; Added apropos-do-all option.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;;; Added fast-command-apropos.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;; Changed doc strings to comments for helping functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;;; Made doc file buffer read-only, buried it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;; Only call substitute-command-keys if do-all set.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;; Optionally use configurable faces to make the output more legible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;; Differentiate between command, function and macro.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;; Apropos-command (ex command-apropos) does cmd and optionally user var.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;; Apropos shows all 3 aspects of symbols (fn, var and plist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;; Apropos-documentation (ex super-apropos) now finds all it should.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;; New apropos-value snoops through all values and optionally plists.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;; Reading DOC file doesn't load nroff.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;; Added hypertext following of documentation, mouse-2 on variable gives value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;; from buffer in active window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;; I see a degradation of maybe 10-20% only.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
63 ;; [sb -- FSF protects the face declarations with `if window-system'
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
64 ;; I see no reason why we should do so]
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (defvar apropos-do-all nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 "*Whether the apropos commands should do more.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 Slows them down more or less. Set this non-nil if you have a fast machine.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (defvar apropos-symbol-face 'bold
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 "*Face for symbol name in apropos output or `nil'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 This looks good, but slows down the commands several times.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (defvar apropos-keybinding-face 'underline
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 "*Face for keybinding display in apropos output or `nil'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 This looks good, but slows down the commands several times.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (defvar apropos-label-face 'italic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 "*Face for label (Command, Variable ...) in apropos output or `nil'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 If this is `nil' no mouse highlighting occurs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 This looks good, but slows down the commands several times.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 When this is a face name, as it is initially, it gets transformed to a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 text-property list for efficiency.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (defvar apropos-property-face 'bold-italic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 "*Face for property name in apropos output or `nil'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 This looks good, but slows down the commands several times.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (defvar apropos-match-face 'secondary-selection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 "*Face for matching part in apropos-documentation/value output or `nil'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 This looks good, but slows down the commands several times.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (defvar apropos-mode-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (let ((map (make-sparse-keymap)))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
95 (define-key map [(control m)] 'apropos-follow)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
96 (define-key map [(button2up)] 'apropos-mouse-follow)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
97 (define-key map [(button2down)] 'undefined)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 "Keymap used in Apropos mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (defvar apropos-regexp nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 "Regexp used in current apropos run.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (defvar apropos-files-scanned ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 "List of elc files already scanned in current run of `apropos-documentation'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (defvar apropos-accumulator ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 "Alist of symbols already found in current apropos run.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (defvar apropos-item ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 "Current item in or for apropos-accumulator.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (defun apropos-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 "Major mode for following hyperlinks in output of apropos commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 \\{apropos-mode-map}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (kill-all-local-variables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (use-local-map apropos-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (setq major-mode 'apropos-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 mode-name "Apropos"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 ;; For auld lang syne:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (fset 'command-apropos 'apropos-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (defun apropos-command (apropos-regexp &optional do-all)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 "Shows commands (interactively callable functions) that match REGEXP.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 With optional prefix ARG or if `apropos-do-all' is non-nil, also show
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 variables."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (interactive (list (read-string (concat "Apropos command "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (if (or current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 apropos-do-all)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 "or variable ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 "(regexp): "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 current-prefix-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (let ((message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (let ((standard-output (get-buffer-create "*Apropos*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (print-help-return-message 'identity))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (or do-all (setq do-all apropos-do-all))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (setq apropos-accumulator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (apropos-internal apropos-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (if do-all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (lambda (symbol) (or (commandp symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (user-variable-p symbol)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 'commandp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (if (apropos-print
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (lambda (p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (let (doc symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (while p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (setcar p (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (setq symbol (car p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (if (commandp symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (if (setq doc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 ;; XEmacs change: if obsolete,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 ;; only mention that.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (or (function-obsoleteness-doc symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (documentation symbol t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (substring doc 0 (string-match "\n" doc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 "(not documented)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (and do-all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (user-variable-p symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (if (setq doc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 ;; XEmacs change: if obsolete,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 ;; only mention that.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (variable-obsoleteness-doc symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (documentation-property
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 symbol 'variable-documentation t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (substring doc 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (string-match "\n" doc))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (setq p (cdr p)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (and message (message message)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (defun apropos (apropos-regexp &optional do-all)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 "Show all bound symbols whose names match REGEXP.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 With optional prefix ARG or if `apropos-do-all' is non-nil, also show unbound
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 symbols and key bindings, which is a little more time-consuming.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 Returns list of symbols and documentation found."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (interactive "sApropos symbol (regexp): \nP")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 ;; XEmacs change: hitting ENTER by mistake is a common mess-up and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 ;; shouldn't make Emacs hang for a long time trying to list all symbols.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (or (> (length apropos-regexp) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (error "Must pass non-empty regexp to `apropos'"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (setq apropos-accumulator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (apropos-internal apropos-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (and (not do-all)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (not apropos-do-all)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (lambda (symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (or (fboundp symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (boundp symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (symbol-plist symbol))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (apropos-print
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (or do-all apropos-do-all)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (lambda (p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (let (symbol doc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (while p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (setcar p (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (setq symbol (car p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (if (fboundp symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (if (setq doc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 ;; XEmacs change: if obsolete,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 ;; only mention that.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (or (function-obsoleteness-doc symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (documentation symbol t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (substring doc 0 (string-match "\n" doc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 "(not documented)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (if (boundp symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (if (setq doc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 ;; XEmacs change: if obsolete,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 ;; only mention that.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (variable-obsoleteness-doc symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (documentation-property
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 symbol 'variable-documentation t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (substring doc 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (string-match "\n" doc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 "(not documented)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (if (setq doc (symbol-plist symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (if (eq (/ (length doc) 2) 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (format "1 property (%s)" (car doc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (concat (/ (length doc) 2) " properties")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (setq p (cdr p)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (defun apropos-value (apropos-regexp &optional do-all)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 "Show all symbols whose value's printed image matches REGEXP.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 With optional prefix ARG or if `apropos-do-all' is non-nil, also looks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 at the function and at the names and values of properties.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 Returns list of symbols and values found."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (interactive "sApropos value (regexp): \nP")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (or do-all (setq do-all apropos-do-all))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (setq apropos-accumulator ())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (let (f v p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (mapatoms
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (lambda (symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (setq f nil v nil p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (or (memq symbol '(apropos-regexp do-all apropos-accumulator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 symbol f v p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (setq v (apropos-value-internal 'boundp symbol 'symbol-value)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (if do-all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (setq f (apropos-value-internal 'fboundp symbol 'symbol-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 p (apropos-format-plist symbol "\n " t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (if (or f v p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (setq apropos-accumulator (cons (list symbol f v p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 apropos-accumulator))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (apropos-print nil nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (defun apropos-documentation (apropos-regexp &optional do-all)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 "Show symbols whose documentation contain matches for REGEXP.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 With optional prefix ARG or if `apropos-do-all' is non-nil, also use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 documentation that is not stored in the documentation file and show key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 bindings.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 Returns list of symbols and documentation found."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (interactive "sApropos documentation (regexp): \nP")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (or do-all (setq do-all apropos-do-all))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (setq apropos-accumulator () apropos-files-scanned ())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (let ((standard-input (get-buffer-create " apropos-temp"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 f v)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (set-buffer standard-input)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (apropos-documentation-check-doc-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (if do-all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (mapatoms
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (lambda (symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (setq f (apropos-safe-documentation symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 v (get symbol 'variable-documentation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (if (integerp v) (setq v))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (setq f (apropos-documentation-internal f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 v (apropos-documentation-internal v))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (if (or f v)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (if (setq apropos-item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (cdr (assq symbol apropos-accumulator)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (if f
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (setcar apropos-item f))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (if v
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (setcar (cdr apropos-item) v)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (setq apropos-accumulator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (cons (list symbol f v)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 apropos-accumulator)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (apropos-print nil nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (kill-buffer standard-input))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (defun apropos-value-internal (predicate symbol function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (if (funcall predicate symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (setq symbol (prin1-to-string (funcall function symbol)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (if (string-match apropos-regexp symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (if apropos-match-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (put-text-property (match-beginning 0) (match-end 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 'face apropos-match-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 symbol)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (defun apropos-documentation-internal (doc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (if (consp doc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (apropos-documentation-check-elc-file (car doc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (and doc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (string-match apropos-regexp doc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (if apropos-match-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (put-text-property (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (match-end 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 'face apropos-match-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (setq doc (copy-sequence doc))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 doc))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (defun apropos-format-plist (pl sep &optional compare)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (setq pl (symbol-plist pl))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (let (p p-out)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (while pl
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (setq p (format "%s %S" (car pl) (nth 1 pl)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (if (or (not compare) (string-match apropos-regexp p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (if apropos-property-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (put-text-property 0 (length (symbol-name (car pl)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 'face apropos-property-face p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (setq p nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (if p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (and compare apropos-match-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (put-text-property (match-beginning 0) (match-end 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 'face apropos-match-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (setq p-out (concat p-out (if p-out sep) p))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (setq pl (nthcdr 2 pl)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 p-out))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 ;; Finds all documentation related to APROPOS-REGEXP in internal-doc-file-name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (defun apropos-documentation-check-doc-file ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (let (type symbol (sepa 2) sepb beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (insert ?\^_)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (backward-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (insert-file-contents (concat doc-directory internal-doc-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (forward-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (while (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (setq sepb (search-forward "\^_"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (not (eobp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (beginning-of-line 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (if (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (narrow-to-region (point) (1- sepb))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (re-search-forward apropos-regexp nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (setq beg (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (goto-char (1+ sepa))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (or (setq type (if (eq ?F (preceding-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 1 ; function documentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 2) ; variable documentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 symbol (read)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 beg (- beg (point) 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 end (- end (point) 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 doc (buffer-substring (1+ (point)) (1- sepb))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 apropos-item (assq symbol apropos-accumulator))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (setq apropos-item (list symbol nil nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 apropos-accumulator (cons apropos-item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 apropos-accumulator)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (if apropos-match-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (put-text-property beg end 'face apropos-match-face doc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (setcar (nthcdr type apropos-item) doc)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (setq sepa (goto-char sepb)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (defun apropos-documentation-check-elc-file (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (if (member file apropos-files-scanned)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (let (symbol doc beg end this-is-a-variable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (setq apropos-files-scanned (cons file apropos-files-scanned))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (insert-file-contents file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (while (search-forward "\n#@" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 ;; Read the comment length, and advance over it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (setq end (read)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 beg (1+ (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 end (+ (point) end -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (forward-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (if (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 ;; match ^ and $ relative to doc string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (narrow-to-region beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (re-search-forward apropos-regexp nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (goto-char (+ end 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (setq doc (buffer-substring beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 end (- (match-end 0) beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 beg (- (match-beginning 0) beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 this-is-a-variable (looking-at "(def\\(var\\|const\\) ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 symbol (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (skip-chars-forward "(a-z")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (forward-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (read))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 symbol (if (consp symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (nth 1 symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (if (if this-is-a-variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (get symbol 'variable-documentation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (and (fboundp symbol) (apropos-safe-documentation symbol)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (or (setq apropos-item (assq symbol apropos-accumulator))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (setq apropos-item (list symbol nil nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 apropos-accumulator (cons apropos-item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 apropos-accumulator)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (if apropos-match-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (put-text-property beg end 'face apropos-match-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 doc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (setcar (nthcdr (if this-is-a-variable 2 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 apropos-item)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 doc)))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (defun apropos-safe-documentation (function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 "Like documentation, except it avoids calling `get_doc_string'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 Will return nil instead."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (while (and function (symbolp function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (setq function (if (fboundp function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (symbol-function function))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (if (eq (car-safe function) 'macro)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (setq function (cdr function)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 ;; XEmacs change from: (setq function (if (byte-code-function-p function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (setq function (if (compiled-function-p function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (if (> (length function) 4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (aref function 4))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (if (eq (car-safe function) 'autoload)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (nth 2 function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (if (eq (car-safe function) 'lambda)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (if (stringp (nth 2 function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (nth 2 function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (if (stringp (nth 3 function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (nth 3 function)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (if (integerp function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (defun apropos-print (do-keys doc-fn spacing)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 "Output result of various apropos commands with `apropos-regexp'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 APROPOS-ACCUMULATOR is a list. Optional DOC-FN is called for each element
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 of apropos-accumulator and may modify it resulting in (symbol fn-doc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 var-doc [plist-doc]). Returns sorted list of symbols and documentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 found."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (if (null apropos-accumulator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (message "No apropos matches for `%s'" apropos-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (if doc-fn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (funcall doc-fn apropos-accumulator))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (setq apropos-accumulator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (sort apropos-accumulator (lambda (a b)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (string-lessp (car a) (car b)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (and apropos-label-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (symbolp apropos-label-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (setq apropos-label-face `(face ,apropos-label-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 mouse-face highlight)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (with-output-to-temp-buffer "*Apropos*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (let ((p apropos-accumulator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (old-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 symbol item point1 point2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (set-buffer standard-output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (apropos-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 ;; XEmacs change from (if window-system
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (if (device-on-window-system-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (insert "If you move the mouse over text that changes color,\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (substitute-command-keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 "you can click \\[apropos-mouse-follow] to get more information.\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (insert (substitute-command-keys
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
479 "Type \\[apropos-follow] in this buffer to get full documentation.\n\n"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (while (consp p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (or (not spacing) (bobp) (terpri))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (setq apropos-item (car p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 symbol (car apropos-item)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 p (cdr p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 point1 (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (princ symbol) ; print symbol name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (setq point2 (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 ;; Calculate key-bindings if we want them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (and do-keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 (commandp symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (indent-to 30 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 (if (let ((keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 (set-buffer old-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 (where-is-internal symbol)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 filtered)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 ;; Copy over the list of key sequences,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 ;; omitting any that contain a buffer or a frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (while keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (let ((key (car keys))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (i 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 loser)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (while (< i (length key))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (if (or (framep (aref key i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (bufferp (aref key i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (setq loser t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (setq i (1+ i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (or loser
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (setq filtered (cons key filtered))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (setq keys (cdr keys)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (setq item filtered))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 ;; Convert the remaining keys to a string and insert.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (mapconcat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 (lambda (key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (setq key (key-description key))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (if apropos-keybinding-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (put-text-property 0 (length key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 'face apropos-keybinding-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 key))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 item ", "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (insert "Type ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (insert "M-x")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (put-text-property (- (point) 3) (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 'face apropos-keybinding-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 (insert " " (symbol-name symbol) " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (insert "RET")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (put-text-property (- (point) 3) (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 'face apropos-keybinding-face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (terpri)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 ;; only now so we don't propagate text attributes all over
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (put-text-property point1 point2 'item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (if (eval `(or ,@(cdr apropos-item)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (car apropos-item)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 apropos-item))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (if apropos-symbol-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (put-text-property point1 point2 'face apropos-symbol-face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (apropos-print-doc 'describe-function 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (if (commandp symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 "Command"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (if (apropos-macrop symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 "Macro"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 "Function"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 do-keys)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (apropos-print-doc 'describe-variable 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 "Variable" do-keys)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (apropos-print-doc 'apropos-describe-plist 3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 "Plist" nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (prog1 apropos-accumulator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 (setq apropos-accumulator ()))) ; permit gc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (defun apropos-macrop (symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 "T if SYMBOL is a Lisp macro."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 (and (fboundp symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 (consp (setq symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 (symbol-function symbol)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (or (eq (car symbol) 'macro)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (if (eq (car symbol) 'autoload)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (memq (nth 4 symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 '(macro t))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (defun apropos-print-doc (action i str do-keys)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (if (stringp (setq i (nth i apropos-item)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (insert " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (put-text-property (- (point) 2) (1- (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 'action action)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (insert str ": ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (if apropos-label-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (add-text-properties (- (point) (length str) 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (1- (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 apropos-label-face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (insert (if do-keys (substitute-command-keys i) i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (or (bolp) (terpri)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (defun apropos-mouse-follow (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (let ((other (if (eq (current-buffer) (get-buffer "*Apropos*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 (current-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 ;; XEmacs change from:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 ;; (set-buffer (window-buffer (posn-window (event-start event))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 ;; (goto-char (posn-point (event-start event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 (set-buffer (event-buffer event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 (goto-char (event-closest-point event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 ;; XEmacs change: following code seems useless
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 ;;(or (and (not (eobp)) (get-text-property (point) 'mouse-face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 ;; (and (not (bobp)) (get-text-property (1- (point)) 'mouse-face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 ;; (error "There is nothing to follow here"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (apropos-follow other))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (defun apropos-follow (&optional other)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (let* (;; Properties are always found at the beginning of the line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 (bol (save-excursion (beginning-of-line) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 ;; If there is no `item' property here, look behind us.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (item (get-text-property bol 'item))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (item-at (if item nil (previous-single-property-change bol 'item)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 ;; Likewise, if there is no `action' property here, look in front.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (action (get-text-property bol 'action))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 (action-at (if action nil (next-single-property-change bol 'action))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (and (null item) item-at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (setq item (get-text-property (1- item-at) 'item)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (and (null action) action-at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (setq action (get-text-property action-at 'action)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (if (not (and item action))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 (error "There is nothing to follow here"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 (if (consp item) (error "There is nothing to follow in `%s'" (car item)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (if other (set-buffer other))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 (funcall action item)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (defun apropos-describe-plist (symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 "Display a pretty listing of SYMBOL's plist."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 (with-output-to-temp-buffer "*Help*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 (set-buffer standard-output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 (princ "Symbol ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 (prin1 symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 (princ "'s plist is\n (")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 (if apropos-symbol-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 (put-text-property 8 (- (point) 14) 'face apropos-symbol-face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (insert (apropos-format-plist symbol "\n "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (princ ")")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 (print-help-return-message)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 ;;; apropos.el ends here