annotate lisp/apropos.el @ 217:d44af0c54775 r20-4b7

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