annotate lisp/packages/apropos.el @ 98:0d2f883870bc r20-1b1

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