annotate lisp/apropos.el @ 13146:6182d95acd14

(read1): Handle chartables and boolvectors.
author Richard M. Stallman <rms@gnu.org>
date Sat, 07 Oct 1995 22:01:39 +0000
parents d194c63cb75c
children 0bfd3ae57234
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
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
25 ;;; Commentary:
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 ;; The ideas for this package were derived from the C code in
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 ;; src/keymap.c and elsewhere. The functions in this file should
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;; always be byte-compiled for speed. Someone should rewrite this in
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 ;; C (as part of src/keymap.c) for speed.
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 ;; The idea for super-apropos is based on the original implementation
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 ;; by Lynn Slater <lrs@esl.com>.
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 ;; History:
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 ;; Fixed bug, current-local-map can return nil.
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 ;; Change, doesn't calculate key-bindings unless needed.
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 ;; Added super-apropos capability, changed print functions.
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
39 ;;; Made fast-apropos and super-apropos share code.
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
40 ;;; Sped up fast-apropos again.
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 ;; Added apropos-do-all option.
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
42 ;;; Added fast-command-apropos.
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 ;; Changed doc strings to comments for helping functions.
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
44 ;;; Made doc file buffer read-only, buried it.
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 ;; Only call substitute-command-keys if do-all set.
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
47 ;; 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
48 ;; Differentiate between command, function and macro.
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
49 ;; 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
50 ;; 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
51 ;; 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
52 ;; 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
53 ;; Reading DOC file doesn't load nroff.
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
54 ;; 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
55 ;; from buffer in active window.
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
56
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
57 ;;; Code:
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
58
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
59 ;; I see a degradation of maybe 10-20% only.
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 (defvar apropos-do-all nil
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
61 "*Whether the apropos commands should do more.
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
62 Slows them down more or less. Set this non-nil if you have a fast machine.")
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
63
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
64
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
65 (defvar apropos-symbol-face (if window-system 'bold)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
66 "*Face for symbol name in apropos output or `nil'.
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
67 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
68
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
69 (defvar apropos-keybinding-face (if window-system 'underline)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
70 "*Face for keybinding display in apropos output or `nil'.
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
71 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
72
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
73 (defvar apropos-label-face (if window-system 'italic)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
74 "*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
75 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
76 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
77 When this is a face name, as it is initially, it gets transformed to a
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
78 text-property list for efficiency.")
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
79
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
80 (defvar apropos-property-face (if window-system 'bold-italic)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
81 "*Face for property name in apropos output or `nil'.
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
82 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
83
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
84 (defvar apropos-match-face (if window-system 'highlight)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
85 "*Face for matching part in apropos-documentation/value output or `nil'.
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
86 This looks good, but slows down the commands several times.")
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
87
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
88
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
89 (defvar apropos-local-map
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
90 (let ((map (make-sparse-keymap)))
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
91 (define-key map "\C-m" 'apropos-follow)
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
92 (define-key map [mouse-2] 'apropos-mouse-follow)
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
93 (define-key map [down-mouse-2] nil)
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
94 map)
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
95 "Local map active when displaying apropos output.")
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
96
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
97
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
98 (defvar apropos-regexp nil
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
99 "Regexp used in current apropos run.")
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
101 (defvar apropos-files-scanned ()
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
102 "List of elc files already scanned in current run of `apropos-documentaion'.")
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
103
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
104 (defvar apropos-accumulator ()
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
105 "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
106
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
107 (defvar apropos-item ()
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
108 "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
109
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
110 ;; For auld lang syne:
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
111 ;;;###autoload
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
112 (fset 'command-apropos 'apropos-command)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
113 ;;;###autoload
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
114 (defun apropos-command (apropos-regexp &optional do-all)
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
115 "Shows commands (interactively callable functions) that match REGEXP.
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
116 With optional prefix ARG or if `apropos-do-all' is non-nil, also show
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
117 variables."
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
118 (interactive (list (read-string (concat "Apropos command "
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
119 (if (or current-prefix-arg
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
120 apropos-do-all)
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
121 "or variable ")
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
122 "(regexp): "))
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
123 current-prefix-arg))
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
124 (let ((message
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
125 (let ((standard-output (get-buffer-create "*Help*")))
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
126 (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
127 (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
128 (setq apropos-accumulator
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
129 (apropos-internal apropos-regexp
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
130 (if do-all
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
131 (lambda (symbol) (or (commandp symbol)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
132 (user-variable-p symbol)))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
133 'commandp)))
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
134 (if (apropos-print
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
135 t
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
136 (lambda (p)
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
137 (let (doc symbol)
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
138 (while p
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
139 (setcar p (list
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
140 (setq symbol (car p))
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
141 (if (commandp symbol)
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
142 (if (setq doc (documentation symbol t))
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
143 (substring doc 0 (string-match "\n" doc))
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
144 "(not documented)"))
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
145 (and do-all
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
146 (user-variable-p symbol)
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
147 (if (setq doc (documentation-property
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
148 symbol 'variable-documentation t))
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
149 (substring doc 0
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
150 (string-match "\n" doc))))))
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
151 (setq p (cdr p)))))
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
152 nil)
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
153 (and message (message message)))))
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
154
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
155
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156 ;;;###autoload
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
157 (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
158 "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
159 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
160 symbols and key bindings, which is a little more time-consuming.
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 Returns list of symbols and documentation found."
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
162 (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
163 (setq apropos-accumulator
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
164 (apropos-internal apropos-regexp
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
165 (and (not do-all)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
166 (not apropos-do-all)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
167 (lambda (symbol)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
168 (or (fboundp symbol)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
169 (boundp symbol)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
170 (symbol-plist symbol))))))
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
171 (apropos-print
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
172 (or do-all apropos-do-all)
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
173 (lambda (p)
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
174 (let (symbol doc)
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
175 (while p
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
176 (setcar p (list
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
177 (setq symbol (car p))
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
178 (if (fboundp symbol)
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
179 (if (setq doc (documentation symbol t))
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
180 (substring doc 0 (string-match "\n" doc))
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
181 "(not documented)"))
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
182 (if (boundp symbol)
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
183 (if (setq doc (documentation-property
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
184 symbol 'variable-documentation t))
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
185 (substring doc 0
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
186 (string-match "\n" doc))
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
187 "(not documented)"))
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
188 (if (setq doc (symbol-plist symbol))
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
189 (if (eq (setq doc (/ (length doc) 2)) 1)
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
190 "1 property"
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
191 (concat doc " properties")))))
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
192 (setq p (cdr p)))))
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
193 nil))
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 ;;;###autoload
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
197 (defun apropos-value (apropos-regexp &optional do-all)
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
198 "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
199 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
200 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
201 Returns list of symbols and values found."
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
202 (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
203 (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
204 (setq apropos-accumulator ())
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
205 (let (f v p)
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
206 (mapatoms
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
207 (lambda (symbol)
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
208 (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
209 (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
210 symbol f v p))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
211 (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
212 (if do-all
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
213 (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
214 p (apropos-format-plist symbol "\n " t)))
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
215 (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
216 (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
217 apropos-accumulator))))))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
218 (apropos-print nil nil t))
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
219
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
220
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
221 ;;;###autoload
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
222 (defun apropos-documentation (apropos-regexp &optional do-all)
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
223 "Show symbols whose names or documentation contain matches for REGEXP.
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
224 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
225 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
226 bindings.
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
227 Returns list of symbols and documentation found."
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
228 (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
229 (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
230 (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
231 (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
232 f v)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
233 (unwind-protect
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
234 (save-excursion
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
235 (set-buffer standard-input)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
236 (apropos-documentation-check-doc-file)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
237 (if do-all
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
238 (mapatoms
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
239 (lambda (symbol)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
240 (setq f (apropos-safe-documentation symbol)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
241 v (get symbol 'variable-documentation)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
242 v (if (integerp v) nil v))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
243 (or (string-match apropos-regexp (symbol-name symbol))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
244 (setq f (apropos-documentation-internal f)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
245 v (apropos-documentation-internal v)))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
246 (if (or f v)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
247 (if (setq apropos-item
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
248 (cdr (assq symbol apropos-accumulator)))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
249 (progn
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
250 (if f
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
251 (setcar apropos-item f))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
252 (if v
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
253 (setcar (cdr apropos-item) v)))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
254 (setq apropos-accumulator
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
255 (cons (list symbol f v)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
256 apropos-accumulator)))))))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
257 (apropos-print do-all nil t))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
258 (kill-buffer standard-input))))
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
259
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
260
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
261 (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
262 (if (funcall predicate symbol)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
263 (progn
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
264 (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
265 (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
266 (progn
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
267 (if apropos-match-face
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
268 (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
269 'face apropos-match-face
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
270 symbol))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
271 symbol)))))
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
273 (defun apropos-documentation-internal (doc)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
274 (if (consp doc)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
275 (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
276 (and doc
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
277 (string-match apropos-regexp doc)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
278 (progn
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
279 (if apropos-match-face
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
280 (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
281 (match-end 0)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
282 'face apropos-match-face
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
283 (setq doc (copy-sequence doc))))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
284 doc))))
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
286 (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
287 (setq pl (symbol-plist pl))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
288 (let (p p-out)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
289 (while pl
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
290 (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
291 (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
292 (if apropos-property-face
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
293 (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
294 'face apropos-property-face p))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
295 (setq p nil))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
296 (if p
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
297 (progn
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
298 (and compare apropos-match-face
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
299 (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
300 'face apropos-match-face
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
301 p))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
302 (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
303 (setq pl (nthcdr 2 pl)))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
304 p-out))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
305
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
306
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
307 ;; 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
308
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
309 (defun apropos-documentation-check-doc-file ()
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
310 (let (type symbol beg end)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
311 (insert-file-contents (concat doc-directory internal-doc-file-name))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
312 (while (re-search-forward apropos-regexp nil t)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
313 (setq beg (match-beginning 0)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
314 end (point))
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
315 (search-backward "\C-_")
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
316 (if (> (point) beg)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
317 ()
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
318 (or (setq type (if (eq ?F (char-after (1+ (point))))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
319 1 ;function documentation
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
320 2) ;variable documentation
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
321 symbol (prog2
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
322 (forward-char 2)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
323 (read))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
324 beg (- beg (point) 1)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
325 end (- end (point) 1)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
326 doc (buffer-substring
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
327 (1+ (point))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
328 (if (search-forward "\C-_" nil 'move)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
329 (1- (point))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
330 (point)))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
331 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
332 (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
333 apropos-accumulator (cons apropos-item apropos-accumulator)))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
334 (and apropos-match-face
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
335 (>= beg 0)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
336 (put-text-property beg end 'face apropos-match-face doc))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
337 (setcar (nthcdr type apropos-item) doc)))))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
338
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
339 (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
340 (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
341 nil
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
342 (let (symbol doc beg end end1 this-is-a-variable)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
343 (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
344 (erase-buffer)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
345 (insert-file-contents file)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
346 (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
347 ;; 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
348 (setq end (read)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
349 beg (point)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
350 end (+ (point) end 1))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
351 (if (re-search-forward apropos-regexp end t)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
352 (progn
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
353 (goto-char end)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
354 (setq doc (buffer-substring (1+ beg) (- end 2))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
355 end1 (- (match-end 0) beg 1)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
356 beg (- (match-beginning 0) beg 1)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
357 this-is-a-variable (looking-at "(defvar\\|(defconst")
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
358 symbol (progn
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
359 (skip-chars-forward "(a-z")
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
360 (forward-char 1)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
361 (read))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
362 symbol (if (consp symbol)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
363 (nth 1 symbol)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
364 symbol))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
365 (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
366 (get symbol 'variable-documentation)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
367 (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
368 (progn
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
369 (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
370 (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
371 apropos-accumulator (cons apropos-item
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
372 apropos-accumulator)))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
373 (if apropos-match-face
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
374 (put-text-property beg end1 'face apropos-match-face
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
375 doc))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
376 (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
377 apropos-item)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
378 doc)))))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
379 (goto-char end)))))
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
380
10283
1d1c5ea9eb86 (super-apropos-check-elc-file): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10282
diff changeset
381
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
382
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
383 (defun apropos-safe-documentation (function)
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
384 "Like documentation, except it avoids calling `get_doc_string'.
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
385 Will return nil instead."
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
386 (while (and function (symbolp function))
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
387 (setq function (if (fboundp function)
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
388 (symbol-function function))))
3563
804e4f30b7ce (safe-documentation): Don't crash on byte-compiled macro.
Richard M. Stallman <rms@gnu.org>
parents: 2946
diff changeset
389 (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
390 (setq function (cdr function)))
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
391 (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
392 (if (> (length function) 4)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
393 (aref function 4))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
394 (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
395 (nth 2 function)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
396 (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
397 (if (stringp (nth 2 function))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
398 (nth 2 function)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
399 (if (stringp (nth 3 function))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
400 (nth 3 function)))))))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
401 (if (integerp function)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
402 nil
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
403 function))
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
404
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
405
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
406
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
407 (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
408 "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
409 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
410 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
411 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
412 found."
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
413 (if (null apropos-accumulator)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
414 (message "No apropos matches for `%s'" apropos-regexp)
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
415 (if doc-fn
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
416 (funcall doc-fn apropos-accumulator))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
417 (setq apropos-accumulator
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
418 (sort apropos-accumulator (lambda (a b)
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
419 (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
420 (and apropos-label-face
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
421 (symbolp apropos-label-face)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
422 (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
423 mouse-face highlight)))
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
424 (with-output-to-temp-buffer "*Help*"
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
425 (let ((p apropos-accumulator)
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
426 (old-buffer (current-buffer))
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
427 symbol item point1 point2)
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
428 (save-excursion
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
429 (set-buffer standard-output)
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
430 (if window-system
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
431 (insert (substitute-command-keys
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
432 "Click \\<apropos-local-map>\\[apropos-mouse-follow] to get full documentation.\n")))
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
433 (insert (substitute-command-keys
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
434 "In this buffer, type \\<apropos-local-map>\\[apropos-follow] to get full documentation.\n\n"))
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
435 (while (consp p)
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
436 (or (not spacing) (bobp) (terpri))
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
437 (setq apropos-item (car p)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
438 symbol (car apropos-item)
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
439 p (cdr p)
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
440 point1 (point))
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
441 (princ symbol) ;print symbol name
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
442 (setq point2 (point))
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
443 ;; don't calculate key-bindings unless needed
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
444 (and do-keys
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
445 (commandp symbol)
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
446 (indent-to 30 1)
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
447 (insert
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
448 (if (setq item (save-excursion
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
449 (set-buffer old-buffer)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
450 (where-is-internal symbol)))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
451 (mapconcat
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
452 (if apropos-keybinding-face
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
453 (lambda (key)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
454 (setq key (key-description key))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
455 (put-text-property 0 (length key)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
456 'face apropos-keybinding-face
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
457 key)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
458 key)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
459 'key-description)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
460 item ", ")
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
461 "(not bound to any keys)")))
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
462 (terpri)
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
463 ;; only now so we don't propagate text attributes all over
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
464 (put-text-property point1 (1+ point1) 'item
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
465 (if (eval `(or ,@(cdr apropos-item)))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
466 (car apropos-item)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
467 apropos-item))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
468 (if apropos-symbol-face
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
469 (put-text-property point1 point2 'face apropos-symbol-face))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
470 (apropos-print-doc 'describe-function 1
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
471 (if (commandp symbol)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
472 "Command"
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
473 (if (apropos-macrop symbol)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
474 "Macro"
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
475 "Function"))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
476 do-keys)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
477 (apropos-print-doc 'describe-variable 2
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
478 "Variable" do-keys)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
479 (apropos-print-doc 'apropos-describe-plist 3
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
480 "Plist" nil))
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
481 (put-text-property 1 (point) 'local-map apropos-local-map)))))
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
482 (prog1 apropos-accumulator
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
483 (setq apropos-accumulator ()))) ; permit gc
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
484
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
485
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
486 (defun apropos-macrop (symbol)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
487 "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
488 (and (fboundp symbol)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
489 (consp (setq symbol
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
490 (symbol-function symbol)))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
491 (or (eq (car symbol) 'macro)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
492 (if (eq (car symbol) 'autoload)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
493 (memq (nth 4 symbol)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
494 '(macro t))))))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
495
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
496
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
497 (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
498 (if (stringp (setq i (nth i apropos-item)))
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
499 (progn
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
500 (insert " ")
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
501 (put-text-property (- (point) 2) (1- (point))
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
502 'action action)
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
503 (insert str ": ")
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
504 (if apropos-label-face
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
505 (add-text-properties (- (point) (length str) 2)
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
506 (1- (point))
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
507 apropos-label-face))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
508 (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
509 (or (bolp) (terpri)))))
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
510
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
511
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
512 (defun apropos-mouse-follow (event)
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
513 (interactive "e")
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
514 (let ((other (if (eq (current-buffer) (get-buffer "*Help*"))
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
515 ()
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
516 (current-buffer))))
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
517 (set-buffer (window-buffer (posn-window (event-start event))))
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
518 (goto-char (posn-point (event-start event)))
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
519 ;; somehow when clicking with the point in another window, undoes badly
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
520 (undo-boundary)
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
521 (apropos-follow other)))
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
522
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
523
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
524 (defun apropos-follow (&optional other)
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
525 (interactive)
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
526 (let ((point (point))
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
527 (item (get-text-property (point) 'item))
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
528 action action-point)
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
529 (or item
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
530 (setq item (if (bobp)
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
531 ()
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
532 (previous-single-property-change (point) 'item))
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
533 item (get-text-property
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
534 (1- (goto-char
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
535 (if item
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
536 item
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
537 (1+ (next-single-property-change (point) 'item)))))
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
538 'item)))
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
539 (if (consp item)
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
540 (error "%s is just a lonely smbol." (car item)))
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
541 (while (if (setq action-point
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
542 (next-single-property-change (point) 'action))
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
543 (<= action-point point))
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
544 (goto-char (1+ action-point))
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
545 (setq action action-point))
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
546 (funcall
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
547 (prog1 (get-text-property (or action action-point (point)) 'action)
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
548 (if other (set-buffer other)))
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
549 item))
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
550 (message "%sype %s (undo) to get back to apropos-listing."
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
551 (if other "In *Help* buffer t" "T")
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
552 (key-description (where-is-internal 'undo nil 1))))
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
553
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
554
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
555
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
556 (defun apropos-describe-plist (symbol)
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
557 "Display a pretty listing of SYMBOL's plist."
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
558 (with-output-to-temp-buffer "*Help*"
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
559 (set-buffer standard-output)
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
560 (princ "Symbol ")
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
561 (prin1 symbol)
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
562 (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
563 (if apropos-symbol-face
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
564 (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
565 (insert (apropos-format-plist symbol "\n "))
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
566 (princ ")")))
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
567
662
8a533acedb77 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 444
diff changeset
568 ;;; apropos.el ends here