annotate lisp/apropos.el @ 109460:597339bd6bef

SQL Mode V2.2 - Added sql-connect and sql-connection-alist
author Michael Mauger <mmaug@yahoo.com>
date Sun, 18 Jul 2010 14:44:32 -0400
parents 1d1d5d9bd884
children a3e1f7134e6e 376148b31b5e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38436
b174db545cfd Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 33921
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
102155
c0cacccaa351 Comment (reformat header).
Glenn Morris <rgm@gnu.org>
parents: 102144
diff changeset
3 ;; Copyright (C) 1989, 1994, 1995, 2001, 2002, 2003, 2004, 2005, 2006,
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 105994
diff changeset
4 ;; 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
845
213978acbc1e entered into RCS
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 811
diff changeset
5
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
6 ;; Author: Joe Wells <jbw@bigbird.bu.edu>
102155
c0cacccaa351 Comment (reformat header).
Glenn Morris <rgm@gnu.org>
parents: 102144
diff changeset
7 ;; Daniel Pfeiffer <occitan@esperanto.org> (rewrite)
2247
2c7997f249eb Add or correct keywords
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1894
diff changeset
8 ;; Keywords: help
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
9
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
14 ;; the Free Software Foundation, either version 3 of the License, or
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
15 ;; (at your option) any later version.
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; GNU General Public License for more details.
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
367
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
39730
620762a412a6 (button): New require.
Miles Bader <miles@gnu.org>
parents: 39706
diff changeset
59 (require 'button)
54582
91f663907945 (apropos-mode): Don't autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
60 (eval-when-compile (require 'cl))
39730
620762a412a6 (button): New require.
Miles Bader <miles@gnu.org>
parents: 39706
diff changeset
61
18941
3fcfe59102ac Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18815
diff changeset
62 (defgroup apropos nil
63999
7c759dd7ab37 (apropos): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents: 60483
diff changeset
63 "Apropos commands for users and programmers."
25297
bbfc1bd58fcc Don't capitalize custom group name.
Dave Love <fx@gnu.org>
parents: 23867
diff changeset
64 :group 'help
18941
3fcfe59102ac Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18815
diff changeset
65 :prefix "apropos")
3fcfe59102ac Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18815
diff changeset
66
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
67 ;; I see a degradation of maybe 10-20% only.
18941
3fcfe59102ac Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18815
diff changeset
68 (defcustom apropos-do-all nil
95644
0e6597218883 Remove spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
69 "Whether the apropos commands should do more.
18941
3fcfe59102ac Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18815
diff changeset
70
3fcfe59102ac Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18815
diff changeset
71 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
72 :group 'apropos
3fcfe59102ac Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18815
diff changeset
73 :type 'boolean)
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
74
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
75
25752
bb28bbb732db (apropos-symbol-face): Non-nil even for ttys.
Richard M. Stallman <rms@gnu.org>
parents: 25297
diff changeset
76 (defcustom apropos-symbol-face 'bold
95644
0e6597218883 Remove spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
77 "Face for symbol name in Apropos output, or nil for none."
18941
3fcfe59102ac Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18815
diff changeset
78 :group 'apropos
3fcfe59102ac Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18815
diff changeset
79 :type 'face)
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
80
25752
bb28bbb732db (apropos-symbol-face): Non-nil even for ttys.
Richard M. Stallman <rms@gnu.org>
parents: 25297
diff changeset
81 (defcustom apropos-keybinding-face 'underline
95644
0e6597218883 Remove spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
82 "Face for lists of keybinding in Apropos output, or nil for none."
18941
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
95644
0e6597218883 Remove spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
86 (defcustom apropos-label-face '(italic variable-pitch)
0e6597218883 Remove spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
87 "Face for label (`Command', `Variable' ...) in Apropos output.
25752
bb28bbb732db (apropos-symbol-face): Non-nil even for ttys.
Richard M. Stallman <rms@gnu.org>
parents: 25297
diff changeset
88 A value of nil means don't use any special font for them, and also
bb28bbb732db (apropos-symbol-face): Non-nil even for ttys.
Richard M. Stallman <rms@gnu.org>
parents: 25297
diff changeset
89 turns off mouse highlighting."
18941
3fcfe59102ac Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18815
diff changeset
90 :group 'apropos
3fcfe59102ac Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18815
diff changeset
91 :type 'face)
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
92
25752
bb28bbb732db (apropos-symbol-face): Non-nil even for ttys.
Richard M. Stallman <rms@gnu.org>
parents: 25297
diff changeset
93 (defcustom apropos-property-face 'bold-italic
95644
0e6597218883 Remove spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
94 "Face for property name in apropos output, or nil for none."
18941
3fcfe59102ac Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18815
diff changeset
95 :group 'apropos
3fcfe59102ac Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18815
diff changeset
96 :type 'face)
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
97
58989
b41192af5b23 (apropos-match-face): Change default from `secondary-selection' to `match'.
Juri Linkov <juri@jurta.org>
parents: 57750
diff changeset
98 (defcustom apropos-match-face 'match
95644
0e6597218883 Remove spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
99 "Face for matching text in Apropos documentation/value, or nil for none.
25752
bb28bbb732db (apropos-symbol-face): Non-nil even for ttys.
Richard M. Stallman <rms@gnu.org>
parents: 25297
diff changeset
100 This applies when you look for matches in the documentation or variable value
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
101 for the pattern; the part that matches gets displayed in this font."
18941
3fcfe59102ac Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18815
diff changeset
102 :group 'apropos
3fcfe59102ac Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18815
diff changeset
103 :type 'face)
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
104
51933
8604d171445a (apropos-sort-by-scores): Rename from apropos-show-scores.
Kim F. Storm <storm@cua.dk>
parents: 51884
diff changeset
105 (defcustom apropos-sort-by-scores nil
95644
0e6597218883 Remove spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
106 "Non-nil means sort matches by scores; best match is shown first.
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
107 This applies to all `apropos' commands except `apropos-documentation'.
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
108 If value is `verbose', the computed score is shown for each match."
51884
58bf3c3670d8 (apropos-show-scores): Make it customizable. Document new meaning.
Richard M. Stallman <rms@gnu.org>
parents: 49588
diff changeset
109 :group 'apropos
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
110 :type '(choice (const :tag "off" nil)
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
111 (const :tag "on" t)
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
112 (const :tag "show scores" verbose)))
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
113
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
114 (defcustom apropos-documentation-sort-by-scores t
100171
d42aff5ca541 * align.el:
Lute Kamstra <lute@gnu.org>
parents: 97878
diff changeset
115 "Non-nil means sort matches by scores; best match is shown first.
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
116 This applies to `apropos-documentation' only.
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
117 If value is `verbose', the computed score is shown for each match."
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
118 :group 'apropos
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
119 :type '(choice (const :tag "off" nil)
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
120 (const :tag "on" t)
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
121 (const :tag "show scores" verbose)))
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
122
13752
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
123 (defvar apropos-mode-map
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
124 (let ((map (make-sparse-keymap)))
39649
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
125 (set-keymap-parent map button-buffer-map)
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
126 ;; Use `apropos-follow' instead of just using the button
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
127 ;; definition of RET, so that users can use it anywhere in an
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
128 ;; apropos item, not just on top of a button.
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
129 (define-key map "\C-m" 'apropos-follow)
21897
7f104a4fc567 (apropos-mode-map): Bind q to quit-window.
Richard M. Stallman <rms@gnu.org>
parents: 20508
diff changeset
130 (define-key map " " 'scroll-up)
7f104a4fc567 (apropos-mode-map): Bind q to quit-window.
Richard M. Stallman <rms@gnu.org>
parents: 20508
diff changeset
131 (define-key map "\177" 'scroll-down)
7f104a4fc567 (apropos-mode-map): Bind q to quit-window.
Richard M. Stallman <rms@gnu.org>
parents: 20508
diff changeset
132 (define-key map "q" 'quit-window)
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
133 map)
13752
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
134 "Keymap used in Apropos mode.")
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
135
29498
4b79925ce8fa *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents: 29199
diff changeset
136 (defvar apropos-mode-hook nil
95644
0e6597218883 Remove spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
137 "Hook run when mode is turned on.")
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
138
66790
d1d47a44eee5 (apropos-pattern): Renamed from apropos-regexp.
Richard M. Stallman <rms@gnu.org>
parents: 65582
diff changeset
139 (defvar apropos-pattern nil
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
140 "Apropos pattern as entered by user.")
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
141
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
142 (defvar apropos-pattern-quoted nil
73359
0d368dc0e31a (apropos-pattern-quoted): Fix a typo in a doc string.
Eli Zaretskii <eliz@gnu.org>
parents: 70092
diff changeset
143 "Apropos pattern passed through `regexp-quote'.")
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
144
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
145 (defvar apropos-words ()
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
146 "Current list of apropos words extracted from `apropos-pattern'.")
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
147
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
148 (defvar apropos-all-words ()
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
149 "Current list of words and synonyms.")
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
150
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
151 (defvar apropos-regexp nil
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
152 "Regexp used in current apropos run.")
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
154 (defvar apropos-all-words-regexp nil
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
155 "Regexp matching apropos-all-words.")
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
156
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
157 (defvar apropos-files-scanned ()
13965
3453c54100b5 (apropos-files-scanned): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 13752
diff changeset
158 "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
159
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
160 (defvar apropos-accumulator ()
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
161 "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
162
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
163 (defvar apropos-item ()
29764
dbfcedec53b3 Doc fixes.
Dave Love <fx@gnu.org>
parents: 29498
diff changeset
164 "Current item in or for `apropos-accumulator'.")
39649
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
165
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
166 (defvar apropos-synonyms '(
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
167 ("find" "open" "edit")
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
168 ("kill" "cut")
69657
f58d58756723 (apropos-synonyms): Add selection => region.
Kim F. Storm <storm@cua.dk>
parents: 68651
diff changeset
169 ("yank" "paste")
f58d58756723 (apropos-synonyms): Add selection => region.
Kim F. Storm <storm@cua.dk>
parents: 68651
diff changeset
170 ("region" "selection"))
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
171 "List of synonyms known by apropos.
73751
a2208b1d3dfd (apropos-synonyms): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 73359
diff changeset
172 Each element is a list of words where the first word is the standard Emacs
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
173 term, and the rest of the words are alternative terms.")
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
174
39649
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
175
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
176 ;;; Button types used by apropos
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
177
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
178 (define-button-type 'apropos-symbol
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
179 'face apropos-symbol-face
39677
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
180 'help-echo "mouse-2, RET: Display more help on this symbol"
59021
cef0d0d34987 (apropos-symbol, apropos-function, apropos-macro)
Kim F. Storm <storm@cua.dk>
parents: 58989
diff changeset
181 'follow-link t
97183
75a85b06acb3 (apropos-symbol): Don't set button skip by default.
Chong Yidong <cyd@stupidchicken.com>
parents: 95749
diff changeset
182 'action #'apropos-symbol-button-display-help)
39649
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
183
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
184 (defun apropos-symbol-button-display-help (button)
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
185 "Display further help for the `apropos-symbol' button BUTTON."
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
186 (button-activate
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
187 (or (apropos-next-label-button (button-start button))
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
188 (error "There is nothing to follow for `%s'" (button-label button)))))
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
189
39677
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
190 (define-button-type 'apropos-function
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
191 'apropos-label "Function"
95749
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
192 'apropos-short-label "f"
59021
cef0d0d34987 (apropos-symbol, apropos-function, apropos-macro)
Kim F. Storm <storm@cua.dk>
parents: 58989
diff changeset
193 'help-echo "mouse-2, RET: Display more help on this function"
cef0d0d34987 (apropos-symbol, apropos-function, apropos-macro)
Kim F. Storm <storm@cua.dk>
parents: 58989
diff changeset
194 'follow-link t
39677
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
195 'action (lambda (button)
59021
cef0d0d34987 (apropos-symbol, apropos-function, apropos-macro)
Kim F. Storm <storm@cua.dk>
parents: 58989
diff changeset
196 (describe-function (button-get button 'apropos-symbol))))
cef0d0d34987 (apropos-symbol, apropos-function, apropos-macro)
Kim F. Storm <storm@cua.dk>
parents: 58989
diff changeset
197
39677
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
198 (define-button-type 'apropos-macro
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
199 'apropos-label "Macro"
95749
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
200 'apropos-short-label "m"
59021
cef0d0d34987 (apropos-symbol, apropos-function, apropos-macro)
Kim F. Storm <storm@cua.dk>
parents: 58989
diff changeset
201 'help-echo "mouse-2, RET: Display more help on this macro"
cef0d0d34987 (apropos-symbol, apropos-function, apropos-macro)
Kim F. Storm <storm@cua.dk>
parents: 58989
diff changeset
202 'follow-link t
39677
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
203 'action (lambda (button)
59021
cef0d0d34987 (apropos-symbol, apropos-function, apropos-macro)
Kim F. Storm <storm@cua.dk>
parents: 58989
diff changeset
204 (describe-function (button-get button 'apropos-symbol))))
cef0d0d34987 (apropos-symbol, apropos-function, apropos-macro)
Kim F. Storm <storm@cua.dk>
parents: 58989
diff changeset
205
39677
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
206 (define-button-type 'apropos-command
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
207 'apropos-label "Command"
95749
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
208 'apropos-short-label "c"
59021
cef0d0d34987 (apropos-symbol, apropos-function, apropos-macro)
Kim F. Storm <storm@cua.dk>
parents: 58989
diff changeset
209 'help-echo "mouse-2, RET: Display more help on this command"
cef0d0d34987 (apropos-symbol, apropos-function, apropos-macro)
Kim F. Storm <storm@cua.dk>
parents: 58989
diff changeset
210 'follow-link t
39677
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
211 'action (lambda (button)
59021
cef0d0d34987 (apropos-symbol, apropos-function, apropos-macro)
Kim F. Storm <storm@cua.dk>
parents: 58989
diff changeset
212 (describe-function (button-get button 'apropos-symbol))))
42560
099200f97432 Remove unnecessary whitespaces.
Pavel Janík <Pavel@Janik.cz>
parents: 42256
diff changeset
213
39677
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
214 ;; We used to use `customize-variable-other-window' instead for a
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
215 ;; customizable variable, but that is slow. It is better to show an
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
216 ;; ordinary help buffer and let the user click on the customization
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
217 ;; button in that buffer, if he wants to.
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
218 ;; Likewise for `customize-face-other-window'.
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
219 (define-button-type 'apropos-variable
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
220 'apropos-label "Variable"
95749
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
221 'apropos-short-label "v"
39677
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
222 'help-echo "mouse-2, RET: Display more help on this variable"
59021
cef0d0d34987 (apropos-symbol, apropos-function, apropos-macro)
Kim F. Storm <storm@cua.dk>
parents: 58989
diff changeset
223 'follow-link t
39677
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
224 'action (lambda (button)
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
225 (describe-variable (button-get button 'apropos-symbol))))
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
226
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
227 (define-button-type 'apropos-face
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
228 'apropos-label "Face"
95749
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
229 'apropos-short-label "F"
39677
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
230 'help-echo "mouse-2, RET: Display more help on this face"
59021
cef0d0d34987 (apropos-symbol, apropos-function, apropos-macro)
Kim F. Storm <storm@cua.dk>
parents: 58989
diff changeset
231 'follow-link t
39677
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
232 'action (lambda (button)
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
233 (describe-face (button-get button 'apropos-symbol))))
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
234
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
235 (define-button-type 'apropos-group
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
236 'apropos-label "Group"
95749
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
237 'apropos-short-label "g"
39677
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
238 'help-echo "mouse-2, RET: Display more help on this group"
59021
cef0d0d34987 (apropos-symbol, apropos-function, apropos-macro)
Kim F. Storm <storm@cua.dk>
parents: 58989
diff changeset
239 'follow-link t
39677
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
240 'action (lambda (button)
47960
ba7e99fa7b11 (apropos-group): Use customize-group-other-window.
Andreas Schwab <schwab@suse.de>
parents: 47024
diff changeset
241 (customize-group-other-window
39677
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
242 (button-get button 'apropos-symbol))))
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
243
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
244 (define-button-type 'apropos-widget
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
245 'apropos-label "Widget"
95749
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
246 'apropos-short-label "w"
39677
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
247 'help-echo "mouse-2, RET: Display more help on this widget"
59021
cef0d0d34987 (apropos-symbol, apropos-function, apropos-macro)
Kim F. Storm <storm@cua.dk>
parents: 58989
diff changeset
248 'follow-link t
39677
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
249 'action (lambda (button)
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
250 (widget-browse-other-window (button-get button 'apropos-symbol))))
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
251
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
252 (define-button-type 'apropos-plist
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
253 'apropos-label "Plist"
95749
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
254 'apropos-short-label "p"
39677
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
255 'help-echo "mouse-2, RET: Display more help on this plist"
59021
cef0d0d34987 (apropos-symbol, apropos-function, apropos-macro)
Kim F. Storm <storm@cua.dk>
parents: 58989
diff changeset
256 'follow-link t
39677
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
257 'action (lambda (button)
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
258 (apropos-describe-plist (button-get button 'apropos-symbol))))
39649
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
259
95645
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
260 (define-button-type 'apropos-library
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
261 'help-echo "mouse-2, RET: Display more help on this library"
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
262 'follow-link t
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
263 'action (lambda (button)
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
264 (apropos-library (button-get button 'apropos-symbol))))
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
265
39649
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
266 (defun apropos-next-label-button (pos)
41154
dfe41fbdcaa0 (apropos-next-label-button): Doc fix.
Pavel Janík <Pavel@Janik.cz>
parents: 39730
diff changeset
267 "Return the next apropos label button after POS, or nil if there's none.
39649
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
268 Will also return nil if more than one `apropos-symbol' button is encountered
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
269 before finding a label."
39669
149659ed7eca (apropos-next-label-button): Update arguments to `next-button'.
Miles Bader <miles@gnu.org>
parents: 39649
diff changeset
270 (let* ((button (next-button pos t))
39649
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
271 (already-hit-symbol nil)
39706
4825323bc19f (apropos-next-label-button): Use the presence of a
Miles Bader <miles@gnu.org>
parents: 39677
diff changeset
272 (label (and button (button-get button 'apropos-label)))
4825323bc19f (apropos-next-label-button): Use the presence of a
Miles Bader <miles@gnu.org>
parents: 39677
diff changeset
273 (type (and button (button-get button 'type))))
39649
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
274 (while (and button
39706
4825323bc19f (apropos-next-label-button): Use the presence of a
Miles Bader <miles@gnu.org>
parents: 39677
diff changeset
275 (not label)
4825323bc19f (apropos-next-label-button): Use the presence of a
Miles Bader <miles@gnu.org>
parents: 39677
diff changeset
276 (or (not (eq type 'apropos-symbol))
39649
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
277 (not already-hit-symbol)))
39706
4825323bc19f (apropos-next-label-button): Use the presence of a
Miles Bader <miles@gnu.org>
parents: 39677
diff changeset
278 (when (eq type 'apropos-symbol)
39649
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
279 (setq already-hit-symbol t))
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
280 (setq button (next-button (button-start button)))
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
281 (when button
39706
4825323bc19f (apropos-next-label-button): Use the presence of a
Miles Bader <miles@gnu.org>
parents: 39677
diff changeset
282 (setq label (button-get button 'apropos-label))
4825323bc19f (apropos-next-label-button): Use the presence of a
Miles Bader <miles@gnu.org>
parents: 39677
diff changeset
283 (setq type (button-get button 'type))))
4825323bc19f (apropos-next-label-button): Use the presence of a
Miles Bader <miles@gnu.org>
parents: 39677
diff changeset
284 (and label button)))
39649
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
285
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
286
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
287 (defun apropos-words-to-regexp (words wild)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
288 "Make regexp matching any two of the words in WORDS."
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
289 (concat "\\("
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
290 (mapconcat 'identity words "\\|")
52101
f3610e8bfe2d (apropos-words-to-regexp): Only add `wild' if
Andreas Schwab <schwab@suse.de>
parents: 51933
diff changeset
291 "\\)"
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49231
diff changeset
292 (if (cdr words)
52101
f3610e8bfe2d (apropos-words-to-regexp): Only add `wild' if
Andreas Schwab <schwab@suse.de>
parents: 51933
diff changeset
293 (concat wild
f3610e8bfe2d (apropos-words-to-regexp): Only add `wild' if
Andreas Schwab <schwab@suse.de>
parents: 51933
diff changeset
294 "\\("
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
295 (mapconcat 'identity words "\\|")
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
296 "\\)")
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
297 "")))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
298
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
299 ;;;###autoload
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
300 (defun apropos-read-pattern (subject)
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
301 "Read an apropos pattern, either a word list or a regexp.
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
302 Returns the user pattern, either a list of words which are matched
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
303 literally, or a string which is used as a regexp to search for.
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
304
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
305 SUBJECT is a string that is included in the prompt to identify what
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
306 kind of objects to search."
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
307 (let ((pattern
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
308 (read-string (concat "Apropos " subject " (word list or regexp): "))))
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
309 (if (string-equal (regexp-quote pattern) pattern)
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
310 ;; Split into words
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
311 (split-string pattern "[ \t]+")
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
312 pattern)))
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
313
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
314 (defun apropos-parse-pattern (pattern)
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
315 "Rewrite a list of words to a regexp matching all permutations.
67212
51e8cdc7d8a8 (apropos-parse-pattern): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66939
diff changeset
316 If PATTERN is a string, that means it is already a regexp.
51e8cdc7d8a8 (apropos-parse-pattern): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66939
diff changeset
317 This updates variables `apropos-pattern', `apropos-pattern-quoted',
51e8cdc7d8a8 (apropos-parse-pattern): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66939
diff changeset
318 `apropos-regexp', `apropos-words', and `apropos-all-words-regexp'."
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
319 (setq apropos-words nil
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
320 apropos-all-words nil)
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
321 (if (consp pattern)
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
322 ;; We don't actually make a regexp matching all permutations.
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
323 ;; Instead, for e.g. "a b c", we make a regexp matching
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
324 ;; any combination of two or more words like this:
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
325 ;; (a|b|c).*(a|b|c) which may give some false matches,
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
326 ;; but as long as it also gives the right ones, that's ok.
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
327 (let ((words pattern))
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
328 (setq apropos-pattern (mapconcat 'identity pattern " ")
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
329 apropos-pattern-quoted (regexp-quote apropos-pattern))
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
330 (dolist (word words)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
331 (let ((syn apropos-synonyms) (s word) (a word))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
332 (while syn
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
333 (if (member word (car syn))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
334 (progn
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
335 (setq a (mapconcat 'identity (car syn) "\\|"))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
336 (if (member word (cdr (car syn)))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
337 (setq s a))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
338 (setq syn nil))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
339 (setq syn (cdr syn))))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
340 (setq apropos-words (cons s apropos-words)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
341 apropos-all-words (cons a apropos-all-words))))
67212
51e8cdc7d8a8 (apropos-parse-pattern): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66939
diff changeset
342 (setq apropos-all-words-regexp
51e8cdc7d8a8 (apropos-parse-pattern): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66939
diff changeset
343 (apropos-words-to-regexp apropos-all-words ".+"))
51e8cdc7d8a8 (apropos-parse-pattern): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66939
diff changeset
344 (setq apropos-regexp
51e8cdc7d8a8 (apropos-parse-pattern): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66939
diff changeset
345 (apropos-words-to-regexp apropos-words ".*?")))
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
346 (setq apropos-pattern-quoted (regexp-quote pattern)
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
347 apropos-all-words-regexp pattern
67212
51e8cdc7d8a8 (apropos-parse-pattern): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66939
diff changeset
348 apropos-pattern pattern
51e8cdc7d8a8 (apropos-parse-pattern): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66939
diff changeset
349 apropos-regexp pattern)))
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
350
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
351
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
352 (defun apropos-calc-scores (str words)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
353 "Return apropos scores for string STR matching WORDS.
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
354 Value is a list of offsets of the words into the string."
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
355 (let (scores i)
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
356 (if words
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
357 (dolist (word words scores)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
358 (if (setq i (string-match word str))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
359 (setq scores (cons i scores))))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
360 ;; Return list of start and end position of regexp
66939
1a91d2217086 (apropos-calc-scores): Use apropos-pattern.
Richard M. Stallman <rms@gnu.org>
parents: 66821
diff changeset
361 (and (string-match apropos-pattern str)
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
362 (list (match-beginning 0) (match-end 0))))))
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
363
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
364 (defun apropos-score-str (str)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
365 "Return apropos score for string STR."
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
366 (if str
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
367 (let* ((l (length str))
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
368 (score (- (/ l 10))))
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
369 (dolist (s (apropos-calc-scores str apropos-all-words) score)
45484
642d016eb216 Only reduce string score for lengthy strings once.
Kim F. Storm <storm@cua.dk>
parents: 45482
diff changeset
370 (setq score (+ score 1000 (/ (* (- l s) 1000) l)))))
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
371 0))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
372
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
373 (defun apropos-score-doc (doc)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
374 "Return apropos score for documentation string DOC."
60018
253d4187af2d (apropos-score-doc): Prevent division by zero.
Lute Kamstra <lute@gnu.org>
parents: 59021
diff changeset
375 (let ((l (length doc)))
253d4187af2d (apropos-score-doc): Prevent division by zero.
Lute Kamstra <lute@gnu.org>
parents: 59021
diff changeset
376 (if (> l 0)
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
377 (let ((score 0) i)
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
378 (when (setq i (string-match apropos-pattern-quoted doc))
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
379 (setq score 10000))
60018
253d4187af2d (apropos-score-doc): Prevent division by zero.
Lute Kamstra <lute@gnu.org>
parents: 59021
diff changeset
380 (dolist (s (apropos-calc-scores doc apropos-all-words) score)
253d4187af2d (apropos-score-doc): Prevent division by zero.
Lute Kamstra <lute@gnu.org>
parents: 59021
diff changeset
381 (setq score (+ score 50 (/ (* (- l s) 50) l)))))
253d4187af2d (apropos-score-doc): Prevent division by zero.
Lute Kamstra <lute@gnu.org>
parents: 59021
diff changeset
382 0)))
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49231
diff changeset
383
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
384 (defun apropos-score-symbol (symbol &optional weight)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
385 "Return apropos score for SYMBOL."
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
386 (setq symbol (symbol-name symbol))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
387 (let ((score 0)
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
388 (l (length symbol)))
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
389 (dolist (s (apropos-calc-scores symbol apropos-words) (* score (or weight 3)))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
390 (setq score (+ score (- 60 l) (/ (* (- l s) 60) l))))))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
391
45488
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
392 (defun apropos-true-hit (str words)
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
393 "Return t if STR is a genuine hit.
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
394 This may fail if only one of the keywords is matched more than once.
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
395 This requires that at least 2 keywords (unless only one was given)."
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
396 (or (not str)
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
397 (not words)
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
398 (not (cdr words))
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
399 (> (length (apropos-calc-scores str words)) 1)))
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
400
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
401 (defun apropos-false-hit-symbol (symbol)
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
402 "Return t if SYMBOL is not really matched by the current keywords."
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
403 (not (apropos-true-hit (symbol-name symbol) apropos-words)))
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
404
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
405 (defun apropos-false-hit-str (str)
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
406 "Return t if STR is not really matched by the current keywords."
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
407 (not (apropos-true-hit str apropos-words)))
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
408
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
409 (defun apropos-true-hit-doc (doc)
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
410 "Return t if DOC is really matched by the current keywords."
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
411 (apropos-true-hit doc apropos-all-words))
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
412
32147
f7c3f0fff3e7 (apropos-mode): Use define-derived-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 29764
diff changeset
413 (define-derived-mode apropos-mode fundamental-mode "Apropos"
13752
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
414 "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
415
32147
f7c3f0fff3e7 (apropos-mode): Use define-derived-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 29764
diff changeset
416 \\{apropos-mode-map}")
13752
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
417
95749
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
418 (defvar apropos-multi-type t
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
419 "If non-nil, this apropos query concerns multiple types.
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
420 This is used to decide whether to print the result's type or not.")
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
421
20335
445110a43268 (apropos-variable): New command.
Richard M. Stallman <rms@gnu.org>
parents: 20208
diff changeset
422 ;;;###autoload
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
423 (defun apropos-variable (pattern &optional do-all)
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
424 "Show user variables that match PATTERN.
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
425 PATTERN can be a word, a list of words (separated by spaces),
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
426 or a regexp (using some regexp special characters). If it is a word,
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
427 search for matches for that word as a substring. If it is a list of words,
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
428 search for matches for any two (or more) of those words.
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
429
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
430 With \\[universal-argument] prefix, or if `apropos-do-all' is non-nil, also show
22218
eb4deede0c5a (apropos-command): Change 3rd arg to VAR-PREDICATE
Richard M. Stallman <rms@gnu.org>
parents: 22182
diff changeset
431 normal variables."
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
432 (interactive (list (apropos-read-pattern
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
433 (if (or current-prefix-arg apropos-do-all)
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
434 "variable" "user option"))
22218
eb4deede0c5a (apropos-command): Change 3rd arg to VAR-PREDICATE
Richard M. Stallman <rms@gnu.org>
parents: 22182
diff changeset
435 current-prefix-arg))
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
436 (apropos-command pattern nil
22326
a049e7c748d9 (apropos-variable): Fixed argument to apropos-command.
Karl Heuer <kwzh@gnu.org>
parents: 22219
diff changeset
437 (if (or do-all apropos-do-all)
22218
eb4deede0c5a (apropos-command): Change 3rd arg to VAR-PREDICATE
Richard M. Stallman <rms@gnu.org>
parents: 22182
diff changeset
438 #'(lambda (symbol)
eb4deede0c5a (apropos-command): Change 3rd arg to VAR-PREDICATE
Richard M. Stallman <rms@gnu.org>
parents: 22182
diff changeset
439 (and (boundp symbol)
eb4deede0c5a (apropos-command): Change 3rd arg to VAR-PREDICATE
Richard M. Stallman <rms@gnu.org>
parents: 22182
diff changeset
440 (get symbol 'variable-documentation)))
eb4deede0c5a (apropos-command): Change 3rd arg to VAR-PREDICATE
Richard M. Stallman <rms@gnu.org>
parents: 22182
diff changeset
441 'user-variable-p)))
13752
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
442
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
443 ;; For auld lang syne:
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
444 ;;;###autoload
47024
15430c8d0eaa * startup.el (normal-splash-screen): Ensure splash buffer is
John Paul Wallington <jpw@pobox.com>
parents: 45488
diff changeset
445 (defalias 'command-apropos 'apropos-command)
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
446 ;;;###autoload
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
447 (defun apropos-command (pattern &optional do-all var-predicate)
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
448 "Show commands (interactively callable functions) that match PATTERN.
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
449 PATTERN can be a word, a list of words (separated by spaces),
66790
d1d47a44eee5 (apropos-pattern): Renamed from apropos-regexp.
Richard M. Stallman <rms@gnu.org>
parents: 65582
diff changeset
450 or a regexp (using some regexp special characters). If it is a word,
d1d47a44eee5 (apropos-pattern): Renamed from apropos-regexp.
Richard M. Stallman <rms@gnu.org>
parents: 65582
diff changeset
451 search for matches for that word as a substring. If it is a list of words,
d1d47a44eee5 (apropos-pattern): Renamed from apropos-regexp.
Richard M. Stallman <rms@gnu.org>
parents: 65582
diff changeset
452 search for matches for any two (or more) of those words.
d1d47a44eee5 (apropos-pattern): Renamed from apropos-regexp.
Richard M. Stallman <rms@gnu.org>
parents: 65582
diff changeset
453
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
454 With \\[universal-argument] prefix, or if `apropos-do-all' is non-nil, also show
22219
0d635ed37f07 (apropos-command): If DO-ALL is set, search functions, not variables.
Richard M. Stallman <rms@gnu.org>
parents: 22218
diff changeset
455 noninteractive functions.
22218
eb4deede0c5a (apropos-command): Change 3rd arg to VAR-PREDICATE
Richard M. Stallman <rms@gnu.org>
parents: 22182
diff changeset
456
22219
0d635ed37f07 (apropos-command): If DO-ALL is set, search functions, not variables.
Richard M. Stallman <rms@gnu.org>
parents: 22218
diff changeset
457 If VAR-PREDICATE is non-nil, show only variables, and only those that
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
458 satisfy the predicate VAR-PREDICATE.
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
459
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
460 When called from a Lisp program, a string PATTERN is used as a regexp,
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
461 while a list of strings is used as a word list."
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
462 (interactive (list (apropos-read-pattern
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
463 (if (or current-prefix-arg apropos-do-all)
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
464 "command or function" "command"))
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
465 current-prefix-arg))
67212
51e8cdc7d8a8 (apropos-parse-pattern): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66939
diff changeset
466 (apropos-parse-pattern pattern)
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
467 (let ((message
13752
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
468 (let ((standard-output (get-buffer-create "*Apropos*")))
104386
2e0765155e47 Use help-print-return-message rather than the now obsolete alias.
Glenn Morris <rgm@gnu.org>
parents: 102155
diff changeset
469 (help-print-return-message 'identity))))
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
470 (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
471 (setq apropos-accumulator
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
472 (apropos-internal apropos-regexp
22326
a049e7c748d9 (apropos-variable): Fixed argument to apropos-command.
Karl Heuer <kwzh@gnu.org>
parents: 22219
diff changeset
473 (or var-predicate
93233
f86b9c0c87ee (apropos-command): Include macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
474 ;; We used to use `functionp' here, but this
f86b9c0c87ee (apropos-command): Include macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
475 ;; rules out macros. `fboundp' rules in
f86b9c0c87ee (apropos-command): Include macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
476 ;; keymaps, but it seems harmless.
f86b9c0c87ee (apropos-command): Include macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
477 (if do-all 'fboundp 'commandp))))
20480
048c8ad9bcaa (apropos, apropos-command): Ignore symbols that have apropos-inhibit property.
Richard M. Stallman <rms@gnu.org>
parents: 20335
diff changeset
478 (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
479 (while tem
45488
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
480 (if (or (get (car tem) 'apropos-inhibit)
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
481 (apropos-false-hit-symbol (car tem)))
20480
048c8ad9bcaa (apropos, apropos-command): Ignore symbols that have apropos-inhibit property.
Richard M. Stallman <rms@gnu.org>
parents: 20335
diff changeset
482 (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
483 (setq tem (cdr tem))))
22532
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
484 (let ((p apropos-accumulator)
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
485 doc symbol score)
22532
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
486 (while p
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
487 (setcar p (list
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
488 (setq symbol (car p))
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
489 (setq score (apropos-score-symbol symbol))
22532
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
490 (unless var-predicate
93233
f86b9c0c87ee (apropos-command): Include macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
491 (if (fboundp symbol)
97878
45912950adb0 (apropos-command): Report documentation errors, rather than ignoring.
Glenn Morris <rgm@gnu.org>
parents: 97864
diff changeset
492 (if (setq doc (condition-case nil
45912950adb0 (apropos-command): Report documentation errors, rather than ignoring.
Glenn Morris <rgm@gnu.org>
parents: 97864
diff changeset
493 (documentation symbol t)
45912950adb0 (apropos-command): Report documentation errors, rather than ignoring.
Glenn Morris <rgm@gnu.org>
parents: 97864
diff changeset
494 (error 'error)))
45912950adb0 (apropos-command): Report documentation errors, rather than ignoring.
Glenn Morris <rgm@gnu.org>
parents: 97864
diff changeset
495 ;; Eg alias to undefined function.
45912950adb0 (apropos-command): Report documentation errors, rather than ignoring.
Glenn Morris <rgm@gnu.org>
parents: 97864
diff changeset
496 (if (eq doc 'error)
45912950adb0 (apropos-command): Report documentation errors, rather than ignoring.
Glenn Morris <rgm@gnu.org>
parents: 97864
diff changeset
497 "(documentation error)"
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49231
diff changeset
498 (setq score (+ score (apropos-score-doc doc)))
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
499 (substring doc 0 (string-match "\n" doc)))
22532
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
500 "(not documented)")))
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
501 (and var-predicate
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
502 (funcall var-predicate symbol)
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
503 (if (setq doc (documentation-property
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
504 symbol 'variable-documentation t))
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
505 (progn
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
506 (setq score (+ score (apropos-score-doc doc)))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
507 (substring doc 0
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
508 (string-match "\n" doc)))))))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
509 (setcar (cdr (car p)) score)
22532
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
510 (setq p (cdr p))))
95749
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
511 (and (let ((apropos-multi-type do-all))
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
512 (apropos-print t nil nil t))
22532
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
513 message
65582
4d1085b02d64 Message format spec fixes (1)
Deepak Goel <deego@gnufans.org>
parents: 64762
diff changeset
514 (message "%s" message))))
12498
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
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
517 ;;;###autoload
49190
bcb627207749 (apropos-documentation-property): New function.
Richard M. Stallman <rms@gnu.org>
parents: 47960
diff changeset
518 (defun apropos-documentation-property (symbol property raw)
bcb627207749 (apropos-documentation-property): New function.
Richard M. Stallman <rms@gnu.org>
parents: 47960
diff changeset
519 "Like (documentation-property SYMBOL PROPERTY RAW) but handle errors."
bcb627207749 (apropos-documentation-property): New function.
Richard M. Stallman <rms@gnu.org>
parents: 47960
diff changeset
520 (condition-case ()
bcb627207749 (apropos-documentation-property): New function.
Richard M. Stallman <rms@gnu.org>
parents: 47960
diff changeset
521 (let ((doc (documentation-property symbol property raw)))
bcb627207749 (apropos-documentation-property): New function.
Richard M. Stallman <rms@gnu.org>
parents: 47960
diff changeset
522 (if doc (substring doc 0 (string-match "\n" doc))
bcb627207749 (apropos-documentation-property): New function.
Richard M. Stallman <rms@gnu.org>
parents: 47960
diff changeset
523 "(not documented)"))
bcb627207749 (apropos-documentation-property): New function.
Richard M. Stallman <rms@gnu.org>
parents: 47960
diff changeset
524 (error "(error retrieving documentation)")))
bcb627207749 (apropos-documentation-property): New function.
Richard M. Stallman <rms@gnu.org>
parents: 47960
diff changeset
525
49231
1cc18f262eab (apropos): Restore autoload cookie. Fix error
John Paul Wallington <jpw@pobox.com>
parents: 49190
diff changeset
526
1cc18f262eab (apropos): Restore autoload cookie. Fix error
John Paul Wallington <jpw@pobox.com>
parents: 49190
diff changeset
527 ;;;###autoload
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
528 (defun apropos (pattern &optional do-all)
67829
61ed6a33ffff (apropos, apropos-value): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 67212
diff changeset
529 "Show all meaningful Lisp symbols whose names match PATTERN.
61ed6a33ffff (apropos, apropos-value): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 67212
diff changeset
530 Symbols are shown if they are defined as functions, variables, or
61ed6a33ffff (apropos, apropos-value): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 67212
diff changeset
531 faces, or if they have nonempty property lists.
61ed6a33ffff (apropos, apropos-value): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 67212
diff changeset
532
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
533 PATTERN can be a word, a list of words (separated by spaces),
66790
d1d47a44eee5 (apropos-pattern): Renamed from apropos-regexp.
Richard M. Stallman <rms@gnu.org>
parents: 65582
diff changeset
534 or a regexp (using some regexp special characters). If it is a word,
d1d47a44eee5 (apropos-pattern): Renamed from apropos-regexp.
Richard M. Stallman <rms@gnu.org>
parents: 65582
diff changeset
535 search for matches for that word as a substring. If it is a list of words,
d1d47a44eee5 (apropos-pattern): Renamed from apropos-regexp.
Richard M. Stallman <rms@gnu.org>
parents: 65582
diff changeset
536 search for matches for any two (or more) of those words.
d1d47a44eee5 (apropos-pattern): Renamed from apropos-regexp.
Richard M. Stallman <rms@gnu.org>
parents: 65582
diff changeset
537
67830
c18efc46bedd (apropos): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 67829
diff changeset
538 With \\[universal-argument] prefix, or if `apropos-do-all' is non-nil,
c18efc46bedd (apropos): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 67829
diff changeset
539 consider all symbols (if they match PATTERN).
c18efc46bedd (apropos): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 67829
diff changeset
540
c18efc46bedd (apropos): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 67829
diff changeset
541 Returns list of symbols and documentation found."
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
542 (interactive (list (apropos-read-pattern "symbol")
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
543 current-prefix-arg))
67212
51e8cdc7d8a8 (apropos-parse-pattern): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66939
diff changeset
544 (apropos-parse-pattern pattern)
54582
91f663907945 (apropos-mode): Don't autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
545 (apropos-symbols-internal
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
546 (apropos-internal apropos-regexp
67830
c18efc46bedd (apropos): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 67829
diff changeset
547 (and (not do-all)
c18efc46bedd (apropos): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 67829
diff changeset
548 (not apropos-do-all)
c18efc46bedd (apropos): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 67829
diff changeset
549 (lambda (symbol)
c18efc46bedd (apropos): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 67829
diff changeset
550 (or (fboundp symbol)
c18efc46bedd (apropos): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 67829
diff changeset
551 (boundp symbol)
c18efc46bedd (apropos): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 67829
diff changeset
552 (facep symbol)
c18efc46bedd (apropos): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 67829
diff changeset
553 (symbol-plist symbol)))))
54582
91f663907945 (apropos-mode): Don't autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
554 (or do-all apropos-do-all)))
91f663907945 (apropos-mode): Don't autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
555
95645
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
556 (defun apropos-library-button (sym)
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
557 (if (null sym)
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
558 "<nothing>"
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
559 (let ((name (copy-sequence (symbol-name sym))))
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
560 (make-text-button name nil
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
561 'type 'apropos-library
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
562 'face apropos-symbol-face
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
563 'apropos-symbol name)
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
564 name)))
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
565
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
566 ;;;###autoload
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
567 (defun apropos-library (file)
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
568 "List the variables and functions defined by library FILE.
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
569 FILE should be one of the libraries currently loaded and should
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
570 thus be found in `load-history'."
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
571 (interactive
102143
c365db646335 (apropos-library): Remove the element with null filename, if present,
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
572 (let* ((libs (delq nil (mapcar 'car load-history)))
c365db646335 (apropos-library): Remove the element with null filename, if present,
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
573 (libs
c365db646335 (apropos-library): Remove the element with null filename, if present,
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
574 (nconc (delq nil
c365db646335 (apropos-library): Remove the element with null filename, if present,
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
575 (mapcar
c365db646335 (apropos-library): Remove the element with null filename, if present,
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
576 (lambda (l)
c365db646335 (apropos-library): Remove the element with null filename, if present,
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
577 (setq l (file-name-nondirectory l))
c365db646335 (apropos-library): Remove the element with null filename, if present,
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
578 (while
c365db646335 (apropos-library): Remove the element with null filename, if present,
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
579 (not (equal (setq l (file-name-sans-extension l))
c365db646335 (apropos-library): Remove the element with null filename, if present,
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
580 l)))
c365db646335 (apropos-library): Remove the element with null filename, if present,
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
581 l)
c365db646335 (apropos-library): Remove the element with null filename, if present,
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
582 libs))
c365db646335 (apropos-library): Remove the element with null filename, if present,
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
583 libs)))
95645
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
584 (list (completing-read "Describe library: " libs nil t))))
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
585 (let ((symbols nil)
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
586 ;; (autoloads nil)
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
587 (provides nil)
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
588 (requires nil)
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
589 (lh-entry (assoc file load-history)))
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
590 (unless lh-entry
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
591 ;; `file' may be the "shortname".
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
592 (let ((lh load-history)
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
593 (re (concat "\\(?:\\`\\|[\\/]\\)" (regexp-quote file)
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
594 "\\(\\.\\|\\'\\)")))
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
595 (while (and lh (null lh-entry))
102144
1ec88ff720f2 Daniel Jensen <daniel at bigwalter.net> (tiny change)
Glenn Morris <rgm@gnu.org>
parents: 102143
diff changeset
596 (if (and (caar lh) (string-match re (caar lh)))
95645
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
597 (setq lh-entry (car lh))
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
598 (setq lh (cdr lh)))))
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
599 (unless lh-entry (error "Unknown library `%s'" file)))
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
600 (dolist (x (cdr lh-entry))
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
601 (case (car-safe x)
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
602 ;; (autoload (push (cdr x) autoloads))
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
603 (require (push (cdr x) requires))
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
604 (provide (push (cdr x) provides))
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
605 (t (push (or (cdr-safe x) x) symbols))))
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
606 (let ((apropos-pattern "")) ;Dummy binding for apropos-symbols-internal.
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
607 (apropos-symbols-internal
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
608 symbols apropos-do-all
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
609 (concat
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
610 (format "Library `%s' provides: %s\nand requires: %s"
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
611 file
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
612 (mapconcat 'apropos-library-button
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
613 (or provides '(nil)) " and ")
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
614 (mapconcat 'apropos-library-button
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
615 (or requires '(nil)) " and ")))))))
454e3c065a98 (apropos-library): New command and new button.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95644
diff changeset
616
54582
91f663907945 (apropos-mode): Don't autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
617 (defun apropos-symbols-internal (symbols keys &optional text)
91f663907945 (apropos-mode): Don't autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
618 ;; Filter out entries that are marked as apropos-inhibit.
91f663907945 (apropos-mode): Don't autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
619 (let ((all nil))
91f663907945 (apropos-mode): Don't autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
620 (dolist (symbol symbols)
91f663907945 (apropos-mode): Don't autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
621 (unless (get symbol 'apropos-inhibit)
91f663907945 (apropos-mode): Don't autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
622 (push symbol all)))
91f663907945 (apropos-mode): Don't autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
623 (setq symbols all))
91f663907945 (apropos-mode): Don't autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
624 (let ((apropos-accumulator
91f663907945 (apropos-mode): Don't autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
625 (mapcar
91f663907945 (apropos-mode): Don't autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
626 (lambda (symbol)
91f663907945 (apropos-mode): Don't autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
627 (let (doc properties)
91f663907945 (apropos-mode): Don't autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
628 (list
91f663907945 (apropos-mode): Don't autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
629 symbol
91f663907945 (apropos-mode): Don't autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
630 (apropos-score-symbol symbol)
91f663907945 (apropos-mode): Don't autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
631 (when (fboundp symbol)
91f663907945 (apropos-mode): Don't autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
632 (if (setq doc (condition-case nil
91f663907945 (apropos-mode): Don't autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
633 (documentation symbol t)
91f663907945 (apropos-mode): Don't autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
634 (void-function
91f663907945 (apropos-mode): Don't autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
635 "(alias for undefined function)")
91f663907945 (apropos-mode): Don't autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
636 (error
91f663907945 (apropos-mode): Don't autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
637 "(can't retrieve function documentation)")))
91f663907945 (apropos-mode): Don't autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
638 (substring doc 0 (string-match "\n" doc))
91f663907945 (apropos-mode): Don't autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
639 "(not documented)"))
91f663907945 (apropos-mode): Don't autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
640 (when (boundp symbol)
91f663907945 (apropos-mode): Don't autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
641 (apropos-documentation-property
49190
bcb627207749 (apropos-documentation-property): New function.
Richard M. Stallman <rms@gnu.org>
parents: 47960
diff changeset
642 symbol 'variable-documentation t))
22532
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
643 (when (setq properties (symbol-plist symbol))
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
644 (setq doc (list (car properties)))
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
645 (while (setq properties (cdr (cdr properties)))
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
646 (setq doc (cons (car properties) doc)))
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
647 (mapconcat #'symbol-name (nreverse doc) " "))
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
648 (when (get symbol 'widget-type)
49190
bcb627207749 (apropos-documentation-property): New function.
Richard M. Stallman <rms@gnu.org>
parents: 47960
diff changeset
649 (apropos-documentation-property
bcb627207749 (apropos-documentation-property): New function.
Richard M. Stallman <rms@gnu.org>
parents: 47960
diff changeset
650 symbol 'widget-documentation t))
54582
91f663907945 (apropos-mode): Don't autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
651 (when (facep symbol)
104753
8debb6dffc0f (apropos-symbols-internal): Handle (obsolete) face aliases.
Glenn Morris <rgm@gnu.org>
parents: 104386
diff changeset
652 (let ((alias (get symbol 'face-alias)))
8debb6dffc0f (apropos-symbols-internal): Handle (obsolete) face aliases.
Glenn Morris <rgm@gnu.org>
parents: 104386
diff changeset
653 (if alias
8debb6dffc0f (apropos-symbols-internal): Handle (obsolete) face aliases.
Glenn Morris <rgm@gnu.org>
parents: 104386
diff changeset
654 (if (facep alias)
8debb6dffc0f (apropos-symbols-internal): Handle (obsolete) face aliases.
Glenn Morris <rgm@gnu.org>
parents: 104386
diff changeset
655 (format "%slias for the face `%s'."
8debb6dffc0f (apropos-symbols-internal): Handle (obsolete) face aliases.
Glenn Morris <rgm@gnu.org>
parents: 104386
diff changeset
656 (if (get symbol 'obsolete-face)
8debb6dffc0f (apropos-symbols-internal): Handle (obsolete) face aliases.
Glenn Morris <rgm@gnu.org>
parents: 104386
diff changeset
657 "Obsolete a"
8debb6dffc0f (apropos-symbols-internal): Handle (obsolete) face aliases.
Glenn Morris <rgm@gnu.org>
parents: 104386
diff changeset
658 "A")
8debb6dffc0f (apropos-symbols-internal): Handle (obsolete) face aliases.
Glenn Morris <rgm@gnu.org>
parents: 104386
diff changeset
659 alias)
8debb6dffc0f (apropos-symbols-internal): Handle (obsolete) face aliases.
Glenn Morris <rgm@gnu.org>
parents: 104386
diff changeset
660 ;; Never happens in practice because fails
8debb6dffc0f (apropos-symbols-internal): Handle (obsolete) face aliases.
Glenn Morris <rgm@gnu.org>
parents: 104386
diff changeset
661 ;; (facep symbol) test.
8debb6dffc0f (apropos-symbols-internal): Handle (obsolete) face aliases.
Glenn Morris <rgm@gnu.org>
parents: 104386
diff changeset
662 "(alias for undefined face)")
8debb6dffc0f (apropos-symbols-internal): Handle (obsolete) face aliases.
Glenn Morris <rgm@gnu.org>
parents: 104386
diff changeset
663 (apropos-documentation-property
8debb6dffc0f (apropos-symbols-internal): Handle (obsolete) face aliases.
Glenn Morris <rgm@gnu.org>
parents: 104386
diff changeset
664 symbol 'face-documentation t))))
54582
91f663907945 (apropos-mode): Don't autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
665 (when (get symbol 'custom-group)
49190
bcb627207749 (apropos-documentation-property): New function.
Richard M. Stallman <rms@gnu.org>
parents: 47960
diff changeset
666 (apropos-documentation-property
54582
91f663907945 (apropos-mode): Don't autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
667 symbol 'group-documentation t)))))
91f663907945 (apropos-mode): Don't autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
668 symbols)))
91f663907945 (apropos-mode): Don't autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
669 (apropos-print keys nil text)))
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
670
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
671
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
672 ;;;###autoload
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
673 (defun apropos-value (pattern &optional do-all)
67829
61ed6a33ffff (apropos, apropos-value): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 67212
diff changeset
674 "Show all symbols whose value's printed representation matches PATTERN.
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
675 PATTERN can be a word, a list of words (separated by spaces),
66790
d1d47a44eee5 (apropos-pattern): Renamed from apropos-regexp.
Richard M. Stallman <rms@gnu.org>
parents: 65582
diff changeset
676 or a regexp (using some regexp special characters). If it is a word,
d1d47a44eee5 (apropos-pattern): Renamed from apropos-regexp.
Richard M. Stallman <rms@gnu.org>
parents: 65582
diff changeset
677 search for matches for that word as a substring. If it is a list of words,
d1d47a44eee5 (apropos-pattern): Renamed from apropos-regexp.
Richard M. Stallman <rms@gnu.org>
parents: 65582
diff changeset
678 search for matches for any two (or more) of those words.
d1d47a44eee5 (apropos-pattern): Renamed from apropos-regexp.
Richard M. Stallman <rms@gnu.org>
parents: 65582
diff changeset
679
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
680 With \\[universal-argument] prefix, or if `apropos-do-all' is non-nil, also looks
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
681 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
682 Returns list of symbols and values found."
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
683 (interactive (list (apropos-read-pattern "value")
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
684 current-prefix-arg))
67212
51e8cdc7d8a8 (apropos-parse-pattern): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66939
diff changeset
685 (apropos-parse-pattern pattern)
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
686 (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
687 (setq apropos-accumulator ())
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
688 (let (f v p)
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
689 (mapatoms
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
690 (lambda (symbol)
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
691 (setq f nil v nil p nil)
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
692 (or (memq symbol '(apropos-regexp
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
693 apropos-pattern apropos-all-words-regexp
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
694 apropos-words apropos-all-words
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
695 do-all apropos-accumulator
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
696 symbol f v p))
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
697 (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
698 (if do-all
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
699 (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
700 p (apropos-format-plist symbol "\n " t)))
45488
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
701 (if (apropos-false-hit-str v)
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
702 (setq v nil))
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
703 (if (apropos-false-hit-str f)
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
704 (setq f nil))
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
705 (if (apropos-false-hit-str p)
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
706 (setq p nil))
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
707 (if (or f v p)
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49231
diff changeset
708 (setq apropos-accumulator (cons (list symbol
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
709 (+ (apropos-score-str f)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
710 (apropos-score-str v)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
711 (apropos-score-str p))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
712 f v p)
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
713 apropos-accumulator))))))
95749
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
714 (let ((apropos-multi-type do-all))
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
715 (apropos-print nil "\n----------------\n")))
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
716
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
717
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
718 ;;;###autoload
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
719 (defun apropos-documentation (pattern &optional do-all)
67829
61ed6a33ffff (apropos, apropos-value): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 67212
diff changeset
720 "Show symbols whose documentation contains matches for PATTERN.
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
721 PATTERN can be a word, a list of words (separated by spaces),
66790
d1d47a44eee5 (apropos-pattern): Renamed from apropos-regexp.
Richard M. Stallman <rms@gnu.org>
parents: 65582
diff changeset
722 or a regexp (using some regexp special characters). If it is a word,
d1d47a44eee5 (apropos-pattern): Renamed from apropos-regexp.
Richard M. Stallman <rms@gnu.org>
parents: 65582
diff changeset
723 search for matches for that word as a substring. If it is a list of words,
d1d47a44eee5 (apropos-pattern): Renamed from apropos-regexp.
Richard M. Stallman <rms@gnu.org>
parents: 65582
diff changeset
724 search for matches for any two (or more) of those words.
d1d47a44eee5 (apropos-pattern): Renamed from apropos-regexp.
Richard M. Stallman <rms@gnu.org>
parents: 65582
diff changeset
725
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
726 With \\[universal-argument] prefix, or if `apropos-do-all' is non-nil, also use
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
727 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
728 bindings.
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
729 Returns list of symbols and documentation found."
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
730 (interactive (list (apropos-read-pattern "documentation")
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
731 current-prefix-arg))
67212
51e8cdc7d8a8 (apropos-parse-pattern): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66939
diff changeset
732 (apropos-parse-pattern pattern)
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
733 (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
734 (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
735 (let ((standard-input (get-buffer-create " apropos-temp"))
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
736 (apropos-sort-by-scores apropos-documentation-sort-by-scores)
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
737 f v sf sv)
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
738 (unwind-protect
105994
009383a57ce8 * x-dnd.el (x-dnd-maybe-call-test-function):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105372
diff changeset
739 (with-current-buffer standard-input
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
740 (apropos-documentation-check-doc-file)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
741 (if do-all
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
742 (mapatoms
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
743 (lambda (symbol)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
744 (setq f (apropos-safe-documentation symbol)
13752
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
745 v (get symbol 'variable-documentation))
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
746 (if (integerp v) (setq v))
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
747 (setq f (apropos-documentation-internal f)
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
748 v (apropos-documentation-internal v))
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
749 (setq sf (apropos-score-doc f)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
750 sv (apropos-score-doc v))
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
751 (if (or f v)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
752 (if (setq apropos-item
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
753 (cdr (assq symbol apropos-accumulator)))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
754 (progn
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
755 (if f
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
756 (progn
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
757 (setcar (nthcdr 1 apropos-item) f)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
758 (setcar apropos-item (+ (car apropos-item) sf))))
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
759 (if v
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
760 (progn
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
761 (setcar (nthcdr 2 apropos-item) v)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
762 (setcar apropos-item (+ (car apropos-item) sv)))))
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
763 (setq apropos-accumulator
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49231
diff changeset
764 (cons (list symbol
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
765 (+ (apropos-score-symbol symbol 2) sf sv)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
766 f v)
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
767 apropos-accumulator)))))))
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
768 (apropos-print nil "\n----------------\n" nil t))
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
769 (kill-buffer standard-input))))
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
770
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
771
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
772 (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
773 (if (funcall predicate symbol)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
774 (progn
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
775 (setq symbol (prin1-to-string (funcall function symbol)))
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
776 (if (string-match apropos-regexp symbol)
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
777 (progn
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
778 (if apropos-match-face
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
779 (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
780 'face apropos-match-face
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
781 symbol))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
782 symbol)))))
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
783
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
784 (defun apropos-documentation-internal (doc)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
785 (if (consp doc)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
786 (apropos-documentation-check-elc-file (car doc))
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
787 (if (and doc
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
788 (string-match apropos-all-words-regexp doc)
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
789 (apropos-true-hit-doc doc))
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
790 (when apropos-match-face
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
791 (setq doc (substitute-command-keys (copy-sequence doc)))
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
792 (if (or (string-match apropos-pattern-quoted doc)
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
793 (string-match apropos-all-words-regexp doc))
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
794 (put-text-property (match-beginning 0)
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
795 (match-end 0)
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
796 'face apropos-match-face doc))
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
797 doc))))
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
798
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
799 (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
800 (setq pl (symbol-plist pl))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
801 (let (p p-out)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
802 (while pl
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
803 (setq p (format "%s %S" (car pl) (nth 1 pl)))
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
804 (if (or (not compare) (string-match apropos-regexp p))
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
805 (if apropos-property-face
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
806 (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
807 'face apropos-property-face p))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
808 (setq p nil))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
809 (if p
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
810 (progn
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
811 (and compare apropos-match-face
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
812 (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
813 'face apropos-match-face
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
814 p))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
815 (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
816 (setq pl (nthcdr 2 pl)))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
817 p-out))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
818
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
819
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
820 ;; Finds all documentation related to APROPOS-REGEXP in internal-doc-file-name.
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
821
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
822 (defun apropos-documentation-check-doc-file ()
105025
bc7e96c6811f (apropos-documentation-check-doc-file): Avoid assignment to free variable `doc'.
Glenn Morris <rgm@gnu.org>
parents: 104928
diff changeset
823 (let (type symbol (sepa 2) sepb doc)
13752
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
824 (insert ?\^_)
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
825 (backward-char)
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
826 (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
827 (forward-char)
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
828 (while (save-excursion
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
829 (setq sepb (search-forward "\^_"))
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
830 (not (eobp)))
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
831 (beginning-of-line 2)
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
832 (if (save-restriction
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
833 (narrow-to-region (point) (1- sepb))
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
834 (re-search-forward apropos-all-words-regexp nil t))
13752
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
835 (progn
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
836 (goto-char (1+ sepa))
45488
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
837 (setq type (if (eq ?F (preceding-char))
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
838 2 ; function documentation
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
839 3) ; variable documentation
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
840 symbol (read)
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
841 doc (buffer-substring (1+ (point)) (1- sepb)))
104928
5532cc06be89 (apropos-documentation-check-doc-file): Exclude unbound functions and
Glenn Morris <rgm@gnu.org>
parents: 104753
diff changeset
842 (when (and (apropos-true-hit-doc doc)
5532cc06be89 (apropos-documentation-check-doc-file): Exclude unbound functions and
Glenn Morris <rgm@gnu.org>
parents: 104753
diff changeset
843 ;; The DOC file lists all built-in funcs and vars.
5532cc06be89 (apropos-documentation-check-doc-file): Exclude unbound functions and
Glenn Morris <rgm@gnu.org>
parents: 104753
diff changeset
844 ;; If any are not currently bound, they can
5532cc06be89 (apropos-documentation-check-doc-file): Exclude unbound functions and
Glenn Morris <rgm@gnu.org>
parents: 104753
diff changeset
845 ;; only be platform-specific stuff (eg NS) not
5532cc06be89 (apropos-documentation-check-doc-file): Exclude unbound functions and
Glenn Morris <rgm@gnu.org>
parents: 104753
diff changeset
846 ;; in use on the current platform.
5532cc06be89 (apropos-documentation-check-doc-file): Exclude unbound functions and
Glenn Morris <rgm@gnu.org>
parents: 104753
diff changeset
847 ;; So we exclude them.
5532cc06be89 (apropos-documentation-check-doc-file): Exclude unbound functions and
Glenn Morris <rgm@gnu.org>
parents: 104753
diff changeset
848 (cond ((= 3 type) (boundp symbol))
5532cc06be89 (apropos-documentation-check-doc-file): Exclude unbound functions and
Glenn Morris <rgm@gnu.org>
parents: 104753
diff changeset
849 ((= 2 type) (fboundp symbol))))
45488
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
850 (or (and (setq apropos-item (assq symbol apropos-accumulator))
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
851 (setcar (cdr apropos-item)
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
852 (apropos-score-doc doc)))
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49231
diff changeset
853 (setq apropos-item (list symbol
45488
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
854 (+ (apropos-score-symbol symbol 2)
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
855 (apropos-score-doc doc))
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
856 nil nil)
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
857 apropos-accumulator (cons apropos-item
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
858 apropos-accumulator)))
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
859 (when apropos-match-face
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
860 (setq doc (substitute-command-keys doc))
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
861 (if (or (string-match apropos-pattern-quoted doc)
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
862 (string-match apropos-all-words-regexp doc))
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
863 (put-text-property (match-beginning 0)
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
864 (match-end 0)
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
865 'face apropos-match-face doc)))
45488
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
866 (setcar (nthcdr type apropos-item) doc))))
13752
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
867 (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
868
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
869 (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
870 (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
871 nil
13752
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
872 (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
873 (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
874 (erase-buffer)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
875 (insert-file-contents file)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
876 (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
877 ;; 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
878 (setq end (read)
13752
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
879 beg (1+ (point))
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
880 end (+ (point) end -1))
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
881 (forward-char)
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
882 (if (save-restriction
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
883 ;; match ^ and $ relative to doc string
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
884 (narrow-to-region beg end)
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
885 (re-search-forward apropos-all-words-regexp nil t))
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
886 (progn
13752
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
887 (goto-char (+ end 2))
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
888 (setq doc (buffer-substring beg end)
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
889 end (- (match-end 0) beg)
45488
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
890 beg (- (match-beginning 0) beg))
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
891 (when (apropos-true-hit-doc doc)
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
892 (setq this-is-a-variable (looking-at "(def\\(var\\|const\\) ")
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
893 symbol (progn
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
894 (skip-chars-forward "(a-z")
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
895 (forward-char)
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
896 (read))
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
897 symbol (if (consp symbol)
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
898 (nth 1 symbol)
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
899 symbol))
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
900 (if (if this-is-a-variable
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
901 (get symbol 'variable-documentation)
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
902 (and (fboundp symbol) (apropos-safe-documentation symbol)))
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
903 (progn
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
904 (or (and (setq apropos-item (assq symbol apropos-accumulator))
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
905 (setcar (cdr apropos-item)
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
906 (+ (cadr apropos-item) (apropos-score-doc doc))))
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
907 (setq apropos-item (list symbol
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
908 (+ (apropos-score-symbol symbol 2)
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
909 (apropos-score-doc doc))
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
910 nil nil)
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
911 apropos-accumulator (cons apropos-item
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
912 apropos-accumulator)))
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
913 (when apropos-match-face
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
914 (setq doc (substitute-command-keys doc))
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
915 (if (or (string-match apropos-pattern-quoted doc)
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
916 (string-match apropos-all-words-regexp doc))
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
917 (put-text-property (match-beginning 0)
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
918 (match-end 0)
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
919 'face apropos-match-face doc)))
45488
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
920 (setcar (nthcdr (if this-is-a-variable 3 2)
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
921 apropos-item)
7d28e8eeee0d (apropos-true-hit, apropos-false-hit-symbol)
Kim F. Storm <storm@cua.dk>
parents: 45484
diff changeset
922 doc))))))))))
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
923
10283
1d1c5ea9eb86 (super-apropos-check-elc-file): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10282
diff changeset
924
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
925
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
926 (defun apropos-safe-documentation (function)
29764
dbfcedec53b3 Doc fixes.
Dave Love <fx@gnu.org>
parents: 29498
diff changeset
927 "Like `documentation', except it avoids calling `get_doc_string'.
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
928 Will return nil instead."
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
929 (while (and function (symbolp function))
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
930 (setq function (if (fboundp function)
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
931 (symbol-function function))))
3563
804e4f30b7ce (safe-documentation): Don't crash on byte-compiled macro.
Richard M. Stallman <rms@gnu.org>
parents: 2946
diff changeset
932 (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
933 (setq function (cdr function)))
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
934 (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
935 (if (> (length function) 4)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
936 (aref function 4))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
937 (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
938 (nth 2 function)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
939 (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
940 (if (stringp (nth 2 function))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
941 (nth 2 function)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
942 (if (stringp (nth 3 function))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
943 (nth 3 function)))))))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
944 (if (integerp function)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
945 nil
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
946 function))
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
947
95749
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
948 (defcustom apropos-compact-layout nil
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
949 "If non-nil, use a single line per binding."
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
950 :type 'boolean)
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
951
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
952 (defun apropos-print (do-keys spacing &optional text nosubst)
22532
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
953 "Output result of apropos searching into buffer `*Apropos*'.
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
954 The value of `apropos-accumulator' is the list of items to output.
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49231
diff changeset
955 Each element should have the format
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
956 (SYMBOL SCORE FN-DOC VAR-DOC [PLIST-DOC WIDGET-DOC FACE-DOC GROUP-DOC]).
22532
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
957 The return value is the list that was in `apropos-accumulator', sorted
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
958 alphabetically by symbol name; but this function also sets
42256
f06cb3ff301f (apropos-print): SPACING is now nil or a separator string.
Richard M. Stallman <rms@gnu.org>
parents: 41154
diff changeset
959 `apropos-accumulator' to nil before returning.
f06cb3ff301f (apropos-print): SPACING is now nil or a separator string.
Richard M. Stallman <rms@gnu.org>
parents: 41154
diff changeset
960
54582
91f663907945 (apropos-mode): Don't autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
961 If SPACING is non-nil, it should be a string; separate items with that string.
91f663907945 (apropos-mode): Don't autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
962 If non-nil TEXT is a string that will be printed as a heading."
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
963 (if (null apropos-accumulator)
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
964 (message "No apropos matches for `%s'" apropos-pattern)
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
965 (setq apropos-accumulator
51884
58bf3c3670d8 (apropos-show-scores): Make it customizable. Document new meaning.
Richard M. Stallman <rms@gnu.org>
parents: 49588
diff changeset
966 (sort apropos-accumulator
58bf3c3670d8 (apropos-show-scores): Make it customizable. Document new meaning.
Richard M. Stallman <rms@gnu.org>
parents: 49588
diff changeset
967 (lambda (a b)
58bf3c3670d8 (apropos-show-scores): Make it customizable. Document new meaning.
Richard M. Stallman <rms@gnu.org>
parents: 49588
diff changeset
968 ;; Don't sort by score if user can't see the score.
58bf3c3670d8 (apropos-show-scores): Make it customizable. Document new meaning.
Richard M. Stallman <rms@gnu.org>
parents: 49588
diff changeset
969 ;; It would be confusing. -- rms.
51933
8604d171445a (apropos-sort-by-scores): Rename from apropos-show-scores.
Kim F. Storm <storm@cua.dk>
parents: 51884
diff changeset
970 (if apropos-sort-by-scores
51884
58bf3c3670d8 (apropos-show-scores): Make it customizable. Document new meaning.
Richard M. Stallman <rms@gnu.org>
parents: 49588
diff changeset
971 (or (> (cadr a) (cadr b))
58bf3c3670d8 (apropos-show-scores): Make it customizable. Document new meaning.
Richard M. Stallman <rms@gnu.org>
parents: 49588
diff changeset
972 (and (= (cadr a) (cadr b))
58bf3c3670d8 (apropos-show-scores): Make it customizable. Document new meaning.
Richard M. Stallman <rms@gnu.org>
parents: 49588
diff changeset
973 (string-lessp (car a) (car b))))
58bf3c3670d8 (apropos-show-scores): Make it customizable. Document new meaning.
Richard M. Stallman <rms@gnu.org>
parents: 49588
diff changeset
974 (string-lessp (car a) (car b))))))
13470
0bfd3ae57234 (apropos-print): Use buffer *Apropos*, not *Help*.
Richard M. Stallman <rms@gnu.org>
parents: 12640
diff changeset
975 (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
976 (let ((p apropos-accumulator)
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
977 (old-buffer (current-buffer))
39649
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
978 symbol item)
13752
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
979 (set-buffer standard-output)
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
980 (apropos-mode)
29199
cc07870ddb45 (apropos-print): Use display-mouse-p instead of
Eli Zaretskii <eliz@gnu.org>
parents: 28844
diff changeset
981 (if (display-mouse-p)
45115
237374f1a28e (apropos-print): Fix the reference to mouse-2.
Eli Zaretskii <eliz@gnu.org>
parents: 42560
diff changeset
982 (insert
237374f1a28e (apropos-print): Fix the reference to mouse-2.
Eli Zaretskii <eliz@gnu.org>
parents: 42560
diff changeset
983 "If moving the mouse over text changes the text's color, "
237374f1a28e (apropos-print): Fix the reference to mouse-2.
Eli Zaretskii <eliz@gnu.org>
parents: 42560
diff changeset
984 "you can click\n"
104928
5532cc06be89 (apropos-documentation-check-doc-file): Exclude unbound functions and
Glenn Morris <rgm@gnu.org>
parents: 104753
diff changeset
985 "or press return on that text to get more information.\n"))
39491
1f81f55f4241 (apropos-print): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 39489
diff changeset
986 (insert "In this buffer, go to the name of the command, or function,"
39489
464552acc8a0 (apropos-print): Make the directions inserted at the
Eli Zaretskii <eliz@gnu.org>
parents: 38436
diff changeset
987 " or variable,\n"
464552acc8a0 (apropos-print): Make the directions inserted at the
Eli Zaretskii <eliz@gnu.org>
parents: 38436
diff changeset
988 (substitute-command-keys
464552acc8a0 (apropos-print): Make the directions inserted at the
Eli Zaretskii <eliz@gnu.org>
parents: 38436
diff changeset
989 "and type \\[apropos-follow] to get full documentation.\n\n"))
54582
91f663907945 (apropos-mode): Don't autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
990 (if text (insert text "\n\n"))
95644
0e6597218883 Remove spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
991 (dolist (apropos-item p)
42256
f06cb3ff301f (apropos-print): SPACING is now nil or a separator string.
Richard M. Stallman <rms@gnu.org>
parents: 41154
diff changeset
992 (when (and spacing (not (bobp)))
f06cb3ff301f (apropos-print): SPACING is now nil or a separator string.
Richard M. Stallman <rms@gnu.org>
parents: 41154
diff changeset
993 (princ spacing))
95644
0e6597218883 Remove spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
994 (setq symbol (car apropos-item))
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
995 ;; Insert dummy score element for backwards compatibility with 21.x
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
996 ;; apropos-item format.
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
997 (if (not (numberp (cadr apropos-item)))
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
998 (setq apropos-item
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
999 (cons (car apropos-item)
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
1000 (cons nil (cdr apropos-item)))))
39649
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
1001 (insert-text-button (symbol-name symbol)
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
1002 'type 'apropos-symbol
97183
75a85b06acb3 (apropos-symbol): Don't set button skip by default.
Chong Yidong <cyd@stupidchicken.com>
parents: 95749
diff changeset
1003 'skip apropos-multi-type
39649
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
1004 ;; Can't use default, since user may have
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
1005 ;; changed the variable!
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
1006 ;; Just say `no' to variables containing faces!
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
1007 'face apropos-symbol-face)
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
1008 (if (and (eq apropos-sort-by-scores 'verbose)
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
1009 (cadr apropos-item))
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
1010 (insert " (" (number-to-string (cadr apropos-item)) ") "))
14395
8e97dadccf2b (apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
1011 ;; Calculate key-bindings if we want them.
95749
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1012 (unless apropos-compact-layout
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1013 (and do-keys
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1014 (commandp symbol)
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1015 (not (eq symbol 'self-insert-command))
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1016 (indent-to 30 1)
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1017 (if (let ((keys
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1018 (with-current-buffer old-buffer
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1019 (where-is-internal symbol)))
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1020 filtered)
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1021 ;; Copy over the list of key sequences,
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1022 ;; omitting any that contain a buffer or a frame.
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1023 ;; FIXME: Why omit keys that contain buffers and
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1024 ;; frames? This looks like a bad workaround rather
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1025 ;; than a proper fix. Does anybod know what problem
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1026 ;; this is trying to address? --Stef
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1027 (dolist (key keys)
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1028 (let ((i 0)
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1029 loser)
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1030 (while (< i (length key))
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1031 (if (or (framep (aref key i))
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1032 (bufferp (aref key i)))
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1033 (setq loser t))
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1034 (setq i (1+ i)))
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1035 (or loser
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1036 (push key filtered))))
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1037 (setq item filtered))
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1038 ;; Convert the remaining keys to a string and insert.
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1039 (insert
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1040 (mapconcat
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1041 (lambda (key)
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1042 (setq key (condition-case ()
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1043 (key-description key)
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1044 (error)))
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1045 (if apropos-keybinding-face
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1046 (put-text-property 0 (length key)
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1047 'face apropos-keybinding-face
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1048 key))
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1049 key)
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1050 item ", "))
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1051 (insert "M-x ... RET")
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1052 (when apropos-keybinding-face
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1053 (put-text-property (- (point) 11) (- (point) 8)
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1054 'face apropos-keybinding-face)
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1055 (put-text-property (- (point) 3) (point)
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1056 'face apropos-keybinding-face))))
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1057 (terpri))
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
1058 (apropos-print-doc 2
13752
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
1059 (if (commandp symbol)
39677
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
1060 'apropos-command
13752
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
1061 (if (apropos-macrop symbol)
39677
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
1062 'apropos-macro
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
1063 'apropos-function))
66821
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
1064 (not nosubst))
8139e472d52b (apropos-match-face): Doc fix.
Kim F. Storm <storm@cua.dk>
parents: 66803
diff changeset
1065 (apropos-print-doc 3 'apropos-variable (not nosubst))
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
1066 (apropos-print-doc 7 'apropos-group t)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
1067 (apropos-print-doc 6 'apropos-face t)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
1068 (apropos-print-doc 5 'apropos-widget t)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
1069 (apropos-print-doc 4 'apropos-plist nil))
95749
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1070 (set (make-local-variable 'truncate-partial-width-windows) t)
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1071 (set (make-local-variable 'truncate-lines) t)
22532
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
1072 (setq buffer-read-only t))))
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
1073 (prog1 apropos-accumulator
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
1074 (setq apropos-accumulator ()))) ; permit gc
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
1075
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
1076 (defun apropos-macrop (symbol)
57750
5d7aec33a1ba (apropos-macrop): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 54582
diff changeset
1077 "Return t if SYMBOL is a Lisp macro."
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
1078 (and (fboundp symbol)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
1079 (consp (setq symbol
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
1080 (symbol-function symbol)))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
1081 (or (eq (car symbol) 'macro)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
1082 (if (eq (car symbol) 'autoload)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
1083 (memq (nth 4 symbol)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
1084 '(macro t))))))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
1085
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
1086
39677
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
1087 (defun apropos-print-doc (i type do-keys)
95644
0e6597218883 Remove spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1088 (when (stringp (setq i (nth i apropos-item)))
95749
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1089 (if apropos-compact-layout
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1090 (insert (propertize "\t" 'display '(space :align-to 32)) " ")
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1091 (insert " "))
97183
75a85b06acb3 (apropos-symbol): Don't set button skip by default.
Chong Yidong <cyd@stupidchicken.com>
parents: 95749
diff changeset
1092 (if (null apropos-multi-type)
75a85b06acb3 (apropos-symbol): Don't set button skip by default.
Chong Yidong <cyd@stupidchicken.com>
parents: 95749
diff changeset
1093 ;; If the query is only for a single type, there's no point
75a85b06acb3 (apropos-symbol): Don't set button skip by default.
Chong Yidong <cyd@stupidchicken.com>
parents: 95749
diff changeset
1094 ;; writing it over and over again. Insert a blank button, and
75a85b06acb3 (apropos-symbol): Don't set button skip by default.
Chong Yidong <cyd@stupidchicken.com>
parents: 95749
diff changeset
1095 ;; put the 'apropos-label property there (needed by
75a85b06acb3 (apropos-symbol): Don't set button skip by default.
Chong Yidong <cyd@stupidchicken.com>
parents: 95749
diff changeset
1096 ;; apropos-symbol-button-display-help).
75a85b06acb3 (apropos-symbol): Don't set button skip by default.
Chong Yidong <cyd@stupidchicken.com>
parents: 95749
diff changeset
1097 (insert-text-button
75a85b06acb3 (apropos-symbol): Don't set button skip by default.
Chong Yidong <cyd@stupidchicken.com>
parents: 95749
diff changeset
1098 " " 'type type 'skip t
75a85b06acb3 (apropos-symbol): Don't set button skip by default.
Chong Yidong <cyd@stupidchicken.com>
parents: 95749
diff changeset
1099 'face 'default 'apropos-symbol (car apropos-item))
95749
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1100 (insert-text-button
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1101 (if apropos-compact-layout
100196
da8a0a35765c (apropos-print-doc): Fix thinko that caused long labels to
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 100171
diff changeset
1102 (format "<%s>" (button-type-get type 'apropos-short-label))
da8a0a35765c (apropos-print-doc): Fix thinko that caused long labels to
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 100171
diff changeset
1103 (button-type-get type 'apropos-label))
95749
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1104 'type type
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1105 ;; Can't use the default button face, since user may have changed the
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1106 ;; variable! Just say `no' to variables containing faces!
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1107 'face apropos-label-face
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1108 'apropos-symbol (car apropos-item))
7957e6e1f9b6 (apropos-function, apropos-macro, apropos-command)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95645
diff changeset
1109 (insert (if apropos-compact-layout " " ": ")))
97183
75a85b06acb3 (apropos-symbol): Don't set button skip by default.
Chong Yidong <cyd@stupidchicken.com>
parents: 95749
diff changeset
1110 (insert (if do-keys (substitute-command-keys i) i))
95644
0e6597218883 Remove spurious * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94678
diff changeset
1111 (or (bolp) (terpri))))
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
1112
39649
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
1113 (defun apropos-follow ()
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
1114 "Invokes any button at point, otherwise invokes the nearest label button."
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
1115 (interactive)
39649
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
1116 (button-activate
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
1117 (or (apropos-next-label-button (line-beginning-position))
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
1118 (error "There is nothing to follow here"))))
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
1119
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
1120
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
1121 (defun apropos-describe-plist (symbol)
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
1122 "Display a pretty listing of SYMBOL's plist."
105372
bd2966850aac Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents: 105025
diff changeset
1123 (help-setup-xref (list 'apropos-describe-plist symbol)
bd2966850aac Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents: 105025
diff changeset
1124 (called-interactively-p 'interactive))
86007
b8077b8314c5 (apropos-describe-plist):
Martin Rudalics <rudalics@gmx.at>
parents: 78236
diff changeset
1125 (with-help-window (help-buffer)
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
1126 (set-buffer standard-output)
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
1127 (princ "Symbol ")
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
1128 (prin1 symbol)
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
1129 (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
1130 (if apropos-symbol-face
54582
91f663907945 (apropos-mode): Don't autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
1131 (put-text-property (+ (point-min) 7) (- (point) 14)
91f663907945 (apropos-mode): Don't autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
1132 'face apropos-symbol-face))
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
1133 (insert (apropos-format-plist symbol "\n "))
86007
b8077b8314c5 (apropos-describe-plist):
Martin Rudalics <rudalics@gmx.at>
parents: 78236
diff changeset
1134 (princ ")")))
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1135
39649
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
1136
18383
11218164bc54 Add provide call.
Richard M. Stallman <rms@gnu.org>
parents: 17559
diff changeset
1137 (provide 'apropos)
11218164bc54 Add provide call.
Richard M. Stallman <rms@gnu.org>
parents: 17559
diff changeset
1138
93975
1e3a407766b9 Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93233
diff changeset
1139 ;; arch-tag: d56fa2ac-e56b-4ce3-84ff-852f9c0dc66e
662
8a533acedb77 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 444
diff changeset
1140 ;;; apropos.el ends here