annotate lisp/packages/apropos.el @ 0:376386a54a3c r19-14

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