annotate lisp/apropos.el @ 20892:18f3cb26243f before-miles-orphaned-changes gcc-2_8_1-980401 gcc-2_8_1-980407 gcc-2_8_1-980412 gcc-2_8_1-980413 gcc-2_8_1-RELEASE gcc_2_8_1-980315 libc-980214 libc-980215 libc-980216 libc-980217 libc-980218 libc-980219 libc-980220 libc-980221 libc-980222 libc-980223 libc-980224 libc-980225 libc-980226 libc-980227 libc-980228 libc-980301 libc-980302 libc-980303 libc-980304 libc-980306 libc-980307 libc-980308 libc-980309 libc-980310 libc-980311 libc-980312 libc-980313 libc-980314 libc-980315 libc-980316 libc-980317 libc-980318 libc-980319 libc-980320 libc-980321 libc-980322 libc-980323 libc-980324 libc-980325 libc-980326 libc-980327 libc-980328 libc-980329 libc-980330 libc-980331 libc-980401 libc-980402 libc-980403 libc-980404 libc-980405 libc-980406 libc-980407 libc-980408 libc-980409 libc-980410 libc-980411 libc-980412 libc-980413 libc-980414 libc-980428 libc-980429 libc-980430 libc-980501 libc-980502 libc-980503 libc-980504 libc-980505 libc-980506 libc-980507 libc-980508 libc-980509 libc-980510 libc-980512 libc-980513 libc-980514 libc-980515 libc-980516 libc-980517 libc-980518 libc-980519 libc-980520 libc-980521 libc-980522 libc-980523 libc-980524 libc-980525 libc-980526 libc-980527 libc-980528 libc-980529 libc-980530 libc-980531 libc-980601 libc-980602 libc-980603 libc-980604 libc-980605 libc-980606 libc-980607 libc-980608 libc-980609 libc-980610 libc-980611 libc-980612 libc-980613

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