annotate lisp/apropos.el @ 45482:7928b3acfb90

(apropos-show-scores, apropos-orig-regexp) (apropos-all-regexp, apropos-synonyms, apropos-words) (apropos-all-words): New variables. (aprpos-words-to-regexp, apropos-rewrite-regexp) (apropos-calc-scores, apropos-score-str, apropos-score-doc) (apropos-score-symbol): New functions. (apropos-command, apropos, apropos-value, apropos-documentation): Allow keywords in addition to regexp. Added scoring. (apropos-documentation-check-doc-file) (apropos-documentation-check-elc-file): Added scoring. (apropos-print): Sort according to score.
author Kim F. Storm <storm@cua.dk>
date Thu, 23 May 2002 10:19:46 +0000
parents 237374f1a28e
children 642d016eb216
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
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
3 ;; Copyright (C) 1989, 1994, 1995, 2001, 2002 Free Software Foundation, Inc.
845
213978acbc1e entered into RCS
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 811
diff changeset
4
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
5 ;; Author: Joe Wells <jbw@bigbird.bu.edu>
23867
9c1495be5676 Update address.
Karl Heuer <kwzh@gnu.org>
parents: 23386
diff changeset
6 ;; Rewritten: Daniel Pfeiffer <occitan@esperanto.org>
2247
2c7997f249eb Add or correct keywords
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1894
diff changeset
7 ;; Keywords: help
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
8
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;; any later version.
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; GNU General Public License for more details.
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14150
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14150
diff changeset
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14150
diff changeset
24 ;; Boston, MA 02111-1307, USA.
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
26 ;;; Commentary:
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 ;; The ideas for this package were derived from the C code in
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;; src/keymap.c and elsewhere. The functions in this file should
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 ;; always be byte-compiled for speed. Someone should rewrite this in
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 ;; C (as part of src/keymap.c) for speed.
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 ;; The idea for super-apropos is based on the original implementation
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 ;; by Lynn Slater <lrs@esl.com>.
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 ;; History:
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 ;; Fixed bug, current-local-map can return nil.
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 ;; Change, doesn't calculate key-bindings unless needed.
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 ;; Added super-apropos capability, changed print functions.
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
40 ;;; Made fast-apropos and super-apropos share code.
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
41 ;;; Sped up fast-apropos again.
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 ;; Added apropos-do-all option.
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
43 ;;; Added fast-command-apropos.
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 ;; Changed doc strings to comments for helping functions.
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
45 ;;; Made doc file buffer read-only, buried it.
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 ;; Only call substitute-command-keys if do-all set.
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
48 ;; Optionally use configurable faces to make the output more legible.
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
49 ;; Differentiate between command, function and macro.
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
50 ;; Apropos-command (ex command-apropos) does cmd and optionally user var.
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
51 ;; Apropos shows all 3 aspects of symbols (fn, var and plist)
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
52 ;; Apropos-documentation (ex super-apropos) now finds all it should.
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
53 ;; New apropos-value snoops through all values and optionally plists.
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
54 ;; Reading DOC file doesn't load nroff.
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
55 ;; Added hypertext following of documentation, mouse-2 on variable gives value
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
56 ;; from buffer in active window.
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
57
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
58 ;;; Code:
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
59
39730
620762a412a6 (button): New require.
Miles Bader <miles@gnu.org>
parents: 39706
diff changeset
60 (require 'button)
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
3fcfe59102ac Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18815
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
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
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
bb28bbb732db (apropos-symbol-face): Non-nil even for ttys.
Richard M. Stallman <rms@gnu.org>
parents: 25297
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
bb28bbb732db (apropos-symbol-face): Non-nil even for ttys.
Richard M. Stallman <rms@gnu.org>
parents: 25297
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
25752
bb28bbb732db (apropos-symbol-face): Non-nil even for ttys.
Richard M. Stallman <rms@gnu.org>
parents: 25297
diff changeset
86 (defcustom apropos-label-face 'italic
bb28bbb732db (apropos-symbol-face): Non-nil even for ttys.
Richard M. Stallman <rms@gnu.org>
parents: 25297
diff changeset
87 "*Face for label (`Command', `Variable' ...) in Apropos output.
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
bb28bbb732db (apropos-symbol-face): Non-nil even for ttys.
Richard M. Stallman <rms@gnu.org>
parents: 25297
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
25752
bb28bbb732db (apropos-symbol-face): Non-nil even for ttys.
Richard M. Stallman <rms@gnu.org>
parents: 25297
diff changeset
98 (defcustom apropos-match-face 'secondary-selection
bb28bbb732db (apropos-symbol-face): Non-nil even for ttys.
Richard M. Stallman <rms@gnu.org>
parents: 25297
diff changeset
99 "*Face for matching text in Apropos documentation/value, or nil for none.
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
bb28bbb732db (apropos-symbol-face): Non-nil even for ttys.
Richard M. Stallman <rms@gnu.org>
parents: 25297
diff changeset
101 for the regexp; 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
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
105
13752
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
106 (defvar apropos-mode-map
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
107 (let ((map (make-sparse-keymap)))
39649
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
108 (set-keymap-parent map button-buffer-map)
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
109 ;; 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
110 ;; 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
111 ;; 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
112 (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
113 (define-key map " " 'scroll-up)
7f104a4fc567 (apropos-mode-map): Bind q to quit-window.
Richard M. Stallman <rms@gnu.org>
parents: 20508
diff changeset
114 (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
115 (define-key map "q" 'quit-window)
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
116 map)
13752
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
117 "Keymap used in Apropos mode.")
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
118
29498
4b79925ce8fa *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents: 29199
diff changeset
119 (defvar apropos-mode-hook nil
4b79925ce8fa *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents: 29199
diff changeset
120 "*Hook run when mode is turned on.")
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
121
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
122 (defvar apropos-show-scores nil
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
123 "*Show apropos scores if non-nil.")
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
124
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
125 (defvar apropos-regexp nil
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
126 "Regexp used in current apropos run.")
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
128 (defvar apropos-orig-regexp nil
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
129 "Regexp as entered by user.")
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
130
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
131 (defvar apropos-all-regexp nil
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
132 "Regexp matching apropos-all-words.")
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
133
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
134 (defvar apropos-files-scanned ()
13965
3453c54100b5 (apropos-files-scanned): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 13752
diff changeset
135 "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
136
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
137 (defvar apropos-accumulator ()
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
138 "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
139
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
140 (defvar apropos-item ()
29764
dbfcedec53b3 Doc fixes.
Dave Love <fx@gnu.org>
parents: 29498
diff changeset
141 "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
142
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
143 (defvar apropos-synonyms '(
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
144 ("find" "open" "edit")
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
145 ("kill" "cut")
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
146 ("yank" "paste"))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
147 "List of synonyms known by apropos.
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
148 Each element is a list of words where the first word is the standard emacs
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
149 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
150
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
151 (defvar apropos-words ()
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
152 "Current list of words.")
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
153
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
154 (defvar apropos-all-words ()
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
155 "Current list of words and synonyms.")
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
156
39649
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
157
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
158 ;;; Button types used by apropos
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
159
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
160 (define-button-type 'apropos-symbol
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
161 'face apropos-symbol-face
39677
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
162 'help-echo "mouse-2, RET: Display more help on this symbol"
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
163 'action #'apropos-symbol-button-display-help
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
164 'skip t)
39649
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
165
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
166 (defun apropos-symbol-button-display-help (button)
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
167 "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
168 (button-activate
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
169 (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
170 (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
171
39677
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
172 (define-button-type 'apropos-function
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
173 'apropos-label "Function"
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
174 'action (lambda (button)
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
175 (describe-function (button-get button 'apropos-symbol)))
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
176 'help-echo "mouse-2, RET: Display more help on this function")
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
177 (define-button-type 'apropos-macro
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
178 'apropos-label "Macro"
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
179 'action (lambda (button)
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
180 (describe-function (button-get button 'apropos-symbol)))
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
181 'help-echo "mouse-2, RET: Display more help on this macro")
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
182 (define-button-type 'apropos-command
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
183 'apropos-label "Command"
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
184 'action (lambda (button)
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
185 (describe-function (button-get button 'apropos-symbol)))
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
186 'help-echo "mouse-2, RET: Display more help on this command")
42560
099200f97432 Remove unnecessary whitespaces.
Pavel Janík <Pavel@Janik.cz>
parents: 42256
diff changeset
187
39677
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
188 ;; 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
189 ;; 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
190 ;; 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
191 ;; button in that buffer, if he wants to.
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
192 ;; Likewise for `customize-face-other-window'.
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
193 (define-button-type 'apropos-variable
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
194 'apropos-label "Variable"
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
195 'help-echo "mouse-2, RET: Display more help on this variable"
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
196 'action (lambda (button)
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
197 (describe-variable (button-get button 'apropos-symbol))))
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
198
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
199 (define-button-type 'apropos-face
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
200 'apropos-label "Face"
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
201 'help-echo "mouse-2, RET: Display more help on this face"
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
202 'action (lambda (button)
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
203 (describe-face (button-get button 'apropos-symbol))))
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
204
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
205 (define-button-type 'apropos-group
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
206 'apropos-label "Group"
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
207 'help-echo "mouse-2, RET: Display more help on this group"
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
208 'action (lambda (button)
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
209 (customize-variable-other-window
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
210 (button-get button 'apropos-symbol))))
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
211
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
212 (define-button-type 'apropos-widget
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
213 'apropos-label "Widget"
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
214 'help-echo "mouse-2, RET: Display more help on this widget"
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
215 'action (lambda (button)
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
216 (widget-browse-other-window (button-get button 'apropos-symbol))))
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
217
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
218 (define-button-type 'apropos-plist
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
219 'apropos-label "Plist"
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
220 'help-echo "mouse-2, RET: Display more help on this plist"
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
221 'action (lambda (button)
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
222 (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
223
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
224 (defun apropos-next-label-button (pos)
41154
dfe41fbdcaa0 (apropos-next-label-button): Doc fix.
Pavel Janík <Pavel@Janik.cz>
parents: 39730
diff changeset
225 "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
226 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
227 before finding a label."
39669
149659ed7eca (apropos-next-label-button): Update arguments to `next-button'.
Miles Bader <miles@gnu.org>
parents: 39649
diff changeset
228 (let* ((button (next-button pos t))
39649
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
229 (already-hit-symbol nil)
39706
4825323bc19f (apropos-next-label-button): Use the presence of a
Miles Bader <miles@gnu.org>
parents: 39677
diff changeset
230 (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
231 (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
232 (while (and button
39706
4825323bc19f (apropos-next-label-button): Use the presence of a
Miles Bader <miles@gnu.org>
parents: 39677
diff changeset
233 (not label)
4825323bc19f (apropos-next-label-button): Use the presence of a
Miles Bader <miles@gnu.org>
parents: 39677
diff changeset
234 (or (not (eq type 'apropos-symbol))
39649
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
235 (not already-hit-symbol)))
39706
4825323bc19f (apropos-next-label-button): Use the presence of a
Miles Bader <miles@gnu.org>
parents: 39677
diff changeset
236 (when (eq type 'apropos-symbol)
39649
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
237 (setq already-hit-symbol t))
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
238 (setq button (next-button (button-start button)))
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
239 (when button
39706
4825323bc19f (apropos-next-label-button): Use the presence of a
Miles Bader <miles@gnu.org>
parents: 39677
diff changeset
240 (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
241 (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
242 (and label button)))
39649
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
243
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
244
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
245 (defun apropos-words-to-regexp (words wild)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
246 "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
247 (concat "\\("
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
248 (mapconcat 'identity words "\\|")
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
249 "\\)" wild
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
250 (if (cdr words)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
251 (concat "\\("
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
252 (mapconcat 'identity words "\\|")
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
253 "\\)")
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
254 "")))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
255
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
256 (defun apropos-rewrite-regexp (regexp)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
257 "Rewrite a list of words to a regexp matching all permutations.
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
258 If REGEXP is already a regexp, don't modify it."
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
259 (setq apropos-orig-regexp regexp)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
260 (setq apropos-words () apropos-all-words ())
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
261 (if (string-equal (regexp-quote regexp) regexp)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
262 ;; 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
263 ;; 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
264 ;; 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
265 ;; (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
266 ;; but as long as it also gives the right ones, that's ok.
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
267 (let ((words (split-string regexp "[ \t]+")))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
268 (dolist (word words)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
269 (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
270 (while syn
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
271 (if (member word (car syn))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
272 (progn
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
273 (setq a (mapconcat 'identity (car syn) "\\|"))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
274 (if (member word (cdr (car syn)))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
275 (setq s a))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
276 (setq syn nil))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
277 (setq syn (cdr syn))))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
278 (setq apropos-words (cons s apropos-words)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
279 apropos-all-words (cons a apropos-all-words))))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
280 (setq apropos-all-regexp (apropos-words-to-regexp apropos-all-words ".+"))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
281 (apropos-words-to-regexp apropos-words ".*?"))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
282 (setq apropos-all-regexp regexp)))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
283
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
284 (defun apropos-calc-scores (str words)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
285 "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
286 Value is a list of offsets of the words into the string."
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
287 (let ((scores ())
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
288 i)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
289 (if words
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
290 (dolist (word words scores)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
291 (if (setq i (string-match word str))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
292 (setq scores (cons i scores))))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
293 ;; Return list of start and end position of regexp
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
294 (string-match apropos-regexp str)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
295 (list (match-beginning 0) (match-end 0)))))
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 (defun apropos-score-str (str)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
298 "Return apropos score for string STR."
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
299 (if str
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
300 (let ((score 0)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
301 (l (length str))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
302 i)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
303 (dolist (s (apropos-calc-scores str apropos-all-words) score)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
304 (setq score (+ score 1000 (- (/ l 10)) (/ (* (- l s) 1000) l)))))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
305 0))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
306
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
307 (defun apropos-score-doc (doc)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
308 "Return apropos score for documentation string DOC."
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
309 (if doc
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
310 (let ((score 0)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
311 (l (length doc))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
312 i)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
313 (dolist (s (apropos-calc-scores doc apropos-all-words) score)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
314 (setq score (+ score 50 (/ (* (- l s) 50) l)))))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
315 0))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
316
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
317 (defun apropos-score-symbol (symbol &optional weight)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
318 "Return apropos score for SYMBOL."
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
319 (setq symbol (symbol-name symbol))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
320 (let ((score 0)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
321 (l (length symbol))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
322 i)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
323 (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
324 (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
325
26719
8a6fd8991465 (apropos-mode): Add autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents: 25752
diff changeset
326 ;;;###autoload
32147
f7c3f0fff3e7 (apropos-mode): Use define-derived-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 29764
diff changeset
327 (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
328 "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
329
32147
f7c3f0fff3e7 (apropos-mode): Use define-derived-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 29764
diff changeset
330 \\{apropos-mode-map}")
13752
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
331
20335
445110a43268 (apropos-variable): New command.
Richard M. Stallman <rms@gnu.org>
parents: 20208
diff changeset
332 ;;;###autoload
22218
eb4deede0c5a (apropos-command): Change 3rd arg to VAR-PREDICATE
Richard M. Stallman <rms@gnu.org>
parents: 22182
diff changeset
333 (defun apropos-variable (regexp &optional do-all)
eb4deede0c5a (apropos-command): Change 3rd arg to VAR-PREDICATE
Richard M. Stallman <rms@gnu.org>
parents: 22182
diff changeset
334 "Show user variables that match REGEXP.
29764
dbfcedec53b3 Doc fixes.
Dave Love <fx@gnu.org>
parents: 29498
diff changeset
335 With optional prefix DO-ALL 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
336 normal variables."
eb4deede0c5a (apropos-command): Change 3rd arg to VAR-PREDICATE
Richard M. Stallman <rms@gnu.org>
parents: 22182
diff changeset
337 (interactive (list (read-string
eb4deede0c5a (apropos-command): Change 3rd arg to VAR-PREDICATE
Richard M. Stallman <rms@gnu.org>
parents: 22182
diff changeset
338 (concat "Apropos "
eb4deede0c5a (apropos-command): Change 3rd arg to VAR-PREDICATE
Richard M. Stallman <rms@gnu.org>
parents: 22182
diff changeset
339 (if (or current-prefix-arg apropos-do-all)
eb4deede0c5a (apropos-command): Change 3rd arg to VAR-PREDICATE
Richard M. Stallman <rms@gnu.org>
parents: 22182
diff changeset
340 "variable"
eb4deede0c5a (apropos-command): Change 3rd arg to VAR-PREDICATE
Richard M. Stallman <rms@gnu.org>
parents: 22182
diff changeset
341 "user option")
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
342 " (regexp or words): "))
22218
eb4deede0c5a (apropos-command): Change 3rd arg to VAR-PREDICATE
Richard M. Stallman <rms@gnu.org>
parents: 22182
diff changeset
343 current-prefix-arg))
eb4deede0c5a (apropos-command): Change 3rd arg to VAR-PREDICATE
Richard M. Stallman <rms@gnu.org>
parents: 22182
diff changeset
344 (apropos-command regexp nil
22326
a049e7c748d9 (apropos-variable): Fixed argument to apropos-command.
Karl Heuer <kwzh@gnu.org>
parents: 22219
diff changeset
345 (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
346 #'(lambda (symbol)
eb4deede0c5a (apropos-command): Change 3rd arg to VAR-PREDICATE
Richard M. Stallman <rms@gnu.org>
parents: 22182
diff changeset
347 (and (boundp symbol)
eb4deede0c5a (apropos-command): Change 3rd arg to VAR-PREDICATE
Richard M. Stallman <rms@gnu.org>
parents: 22182
diff changeset
348 (get symbol 'variable-documentation)))
eb4deede0c5a (apropos-command): Change 3rd arg to VAR-PREDICATE
Richard M. Stallman <rms@gnu.org>
parents: 22182
diff changeset
349 'user-variable-p)))
13752
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
350
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
351 ;; For auld lang syne:
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
352 ;;;###autoload
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
353 (fset 'command-apropos 'apropos-command)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
354 ;;;###autoload
22218
eb4deede0c5a (apropos-command): Change 3rd arg to VAR-PREDICATE
Richard M. Stallman <rms@gnu.org>
parents: 22182
diff changeset
355 (defun apropos-command (apropos-regexp &optional do-all var-predicate)
29764
dbfcedec53b3 Doc fixes.
Dave Love <fx@gnu.org>
parents: 29498
diff changeset
356 "Show commands (interactively callable functions) that match APROPOS-REGEXP.
dbfcedec53b3 Doc fixes.
Dave Love <fx@gnu.org>
parents: 29498
diff changeset
357 With optional prefix DO-ALL, 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
358 noninteractive functions.
22218
eb4deede0c5a (apropos-command): Change 3rd arg to VAR-PREDICATE
Richard M. Stallman <rms@gnu.org>
parents: 22182
diff changeset
359
22219
0d635ed37f07 (apropos-command): If DO-ALL is set, search functions, not variables.
Richard M. Stallman <rms@gnu.org>
parents: 22218
diff changeset
360 If VAR-PREDICATE is non-nil, show only variables, and only those that
22218
eb4deede0c5a (apropos-command): Change 3rd arg to VAR-PREDICATE
Richard M. Stallman <rms@gnu.org>
parents: 22182
diff changeset
361 satisfy the predicate VAR-PREDICATE."
20335
445110a43268 (apropos-variable): New command.
Richard M. Stallman <rms@gnu.org>
parents: 20208
diff changeset
362 (interactive (list (read-string (concat
445110a43268 (apropos-variable): New command.
Richard M. Stallman <rms@gnu.org>
parents: 20208
diff changeset
363 "Apropos command "
445110a43268 (apropos-variable): New command.
Richard M. Stallman <rms@gnu.org>
parents: 20208
diff changeset
364 (if (or current-prefix-arg
445110a43268 (apropos-variable): New command.
Richard M. Stallman <rms@gnu.org>
parents: 20208
diff changeset
365 apropos-do-all)
22219
0d635ed37f07 (apropos-command): If DO-ALL is set, search functions, not variables.
Richard M. Stallman <rms@gnu.org>
parents: 22218
diff changeset
366 "or function ")
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
367 "(regexp or words): "))
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
368 current-prefix-arg))
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
369 (setq apropos-regexp (apropos-rewrite-regexp apropos-regexp))
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
370 (let ((message
13752
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
371 (let ((standard-output (get-buffer-create "*Apropos*")))
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
372 (print-help-return-message 'identity))))
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
373 (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
374 (setq apropos-accumulator
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
375 (apropos-internal apropos-regexp
22326
a049e7c748d9 (apropos-variable): Fixed argument to apropos-command.
Karl Heuer <kwzh@gnu.org>
parents: 22219
diff changeset
376 (or var-predicate
a049e7c748d9 (apropos-variable): Fixed argument to apropos-command.
Karl Heuer <kwzh@gnu.org>
parents: 22219
diff changeset
377 (if do-all 'functionp 'commandp))))
20480
048c8ad9bcaa (apropos, apropos-command): Ignore symbols that have apropos-inhibit property.
Richard M. Stallman <rms@gnu.org>
parents: 20335
diff changeset
378 (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
379 (while tem
048c8ad9bcaa (apropos, apropos-command): Ignore symbols that have apropos-inhibit property.
Richard M. Stallman <rms@gnu.org>
parents: 20335
diff changeset
380 (if (get (car tem) 'apropos-inhibit)
048c8ad9bcaa (apropos, apropos-command): Ignore symbols that have apropos-inhibit property.
Richard M. Stallman <rms@gnu.org>
parents: 20335
diff changeset
381 (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
382 (setq tem (cdr tem))))
22532
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
383 (let ((p apropos-accumulator)
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
384 doc symbol score)
22532
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
385 (while p
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
386 (setcar p (list
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
387 (setq symbol (car p))
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
388 (setq score (apropos-score-symbol symbol))
22532
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
389 (unless var-predicate
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
390 (if (functionp symbol)
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
391 (if (setq doc (documentation symbol t))
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
392 (progn
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
393 (setq score (+ score (apropos-score-doc doc)))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
394 (substring doc 0 (string-match "\n" doc)))
22532
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
395 "(not documented)")))
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
396 (and var-predicate
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
397 (funcall var-predicate symbol)
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
398 (if (setq doc (documentation-property
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
399 symbol 'variable-documentation t))
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
400 (progn
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
401 (setq score (+ score (apropos-score-doc doc)))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
402 (substring doc 0
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
403 (string-match "\n" doc)))))))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
404 (setcar (cdr (car p)) score)
22532
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
405 (setq p (cdr p))))
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
406 (and (apropos-print t nil)
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
407 message
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
408 (message message))))
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
409
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
410
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
411 ;;;###autoload
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
412 (defun apropos (apropos-regexp &optional do-all)
29764
dbfcedec53b3 Doc fixes.
Dave Love <fx@gnu.org>
parents: 29498
diff changeset
413 "Show all bound symbols whose names match APROPOS-REGEXP.
dbfcedec53b3 Doc fixes.
Dave Love <fx@gnu.org>
parents: 29498
diff changeset
414 With optional prefix DO-ALL or if `apropos-do-all' is non-nil, also
dbfcedec53b3 Doc fixes.
Dave Love <fx@gnu.org>
parents: 29498
diff changeset
415 show unbound symbols and key bindings, which is a little more
dbfcedec53b3 Doc fixes.
Dave Love <fx@gnu.org>
parents: 29498
diff changeset
416 time-consuming. Returns list of symbols and documentation found."
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
417 (interactive "sApropos symbol (regexp or words): \nP")
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
418 (setq apropos-regexp (apropos-rewrite-regexp apropos-regexp))
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
419 (setq apropos-accumulator
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
420 (apropos-internal apropos-regexp
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
421 (and (not do-all)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
422 (not apropos-do-all)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
423 (lambda (symbol)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
424 (or (fboundp symbol)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
425 (boundp symbol)
17417
c351a7e1880c (apropos): Add support for faces, widgets, and user options.
Richard M. Stallman <rms@gnu.org>
parents: 17167
diff changeset
426 (facep symbol)
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
427 (symbol-plist symbol))))))
20480
048c8ad9bcaa (apropos, apropos-command): Ignore symbols that have apropos-inhibit property.
Richard M. Stallman <rms@gnu.org>
parents: 20335
diff changeset
428 (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
429 (while tem
048c8ad9bcaa (apropos, apropos-command): Ignore symbols that have apropos-inhibit property.
Richard M. Stallman <rms@gnu.org>
parents: 20335
diff changeset
430 (if (get (car tem) 'apropos-inhibit)
048c8ad9bcaa (apropos, apropos-command): Ignore symbols that have apropos-inhibit property.
Richard M. Stallman <rms@gnu.org>
parents: 20335
diff changeset
431 (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
432 (setq tem (cdr tem))))
22532
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
433 (let ((p apropos-accumulator)
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
434 symbol doc properties)
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
435 (while p
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
436 (setcar p (list
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
437 (setq symbol (car p))
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
438 0
22532
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
439 (when (fboundp symbol)
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
440 (if (setq doc (condition-case nil
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
441 (documentation symbol t)
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
442 (void-function
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
443 "(alias for undefined function)")))
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
444 (substring doc 0 (string-match "\n" doc))
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
445 "(not documented)"))
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
446 (when (boundp symbol)
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
447 (if (setq doc (documentation-property
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
448 symbol 'variable-documentation t))
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
449 (substring doc 0 (string-match "\n" doc))
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
450 "(not documented)"))
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
451 (when (setq properties (symbol-plist symbol))
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
452 (setq doc (list (car properties)))
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
453 (while (setq properties (cdr (cdr properties)))
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
454 (setq doc (cons (car properties) doc)))
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
455 (mapconcat #'symbol-name (nreverse doc) " "))
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
456 (when (get symbol 'widget-type)
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
457 (if (setq doc (documentation-property
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
458 symbol 'widget-documentation t))
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
459 (substring doc 0
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
460 (string-match "\n" doc))
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
461 "(not documented)"))
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
462 (when (facep symbol)
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
463 (if (setq doc (documentation-property
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
464 symbol 'face-documentation t))
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
465 (substring doc 0
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
466 (string-match "\n" doc))
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
467 "(not documented)"))
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
468 (when (get symbol 'custom-group)
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
469 (if (setq doc (documentation-property
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
470 symbol 'group-documentation t))
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
471 (substring doc 0
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
472 (string-match "\n" doc))
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
473 "(not documented)"))))
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
474 (setq p (cdr p))))
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
475 (apropos-print
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
476 (or do-all apropos-do-all)
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
477 nil))
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
478
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
479
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
480 ;;;###autoload
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
481 (defun apropos-value (apropos-regexp &optional do-all)
29764
dbfcedec53b3 Doc fixes.
Dave Love <fx@gnu.org>
parents: 29498
diff changeset
482 "Show all symbols whose value's printed image matches APROPOS-REGEXP.
dbfcedec53b3 Doc fixes.
Dave Love <fx@gnu.org>
parents: 29498
diff changeset
483 With optional prefix DO-ALL 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
484 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
485 Returns list of symbols and values found."
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
486 (interactive "sApropos value (regexp or words): \nP")
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
487 (setq apropos-regexp (apropos-rewrite-regexp apropos-regexp))
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
488 (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
489 (setq apropos-accumulator ())
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
490 (let (f v p)
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
491 (mapatoms
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
492 (lambda (symbol)
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
493 (setq f nil v nil p nil)
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
494 (or (memq symbol '(apropos-regexp
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
495 apropos-orig-regexp apropos-all-regexp
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
496 apropos-words apropos-all-words
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
497 do-all apropos-accumulator
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
498 symbol f v p))
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
499 (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
500 (if do-all
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
501 (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
502 p (apropos-format-plist symbol "\n " t)))
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
503 (if (or f v p)
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
504 (setq apropos-accumulator (cons (list symbol
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
505 (+ (apropos-score-str f)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
506 (apropos-score-str v)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
507 (apropos-score-str p))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
508 f v p)
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
509 apropos-accumulator))))))
42256
f06cb3ff301f (apropos-print): SPACING is now nil or a separator string.
Richard M. Stallman <rms@gnu.org>
parents: 41154
diff changeset
510 (apropos-print nil "\n----------------\n"))
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
511
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
512
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
513 ;;;###autoload
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
514 (defun apropos-documentation (apropos-regexp &optional do-all)
29764
dbfcedec53b3 Doc fixes.
Dave Love <fx@gnu.org>
parents: 29498
diff changeset
515 "Show symbols whose documentation contain matches for APROPOS-REGEXP.
dbfcedec53b3 Doc fixes.
Dave Love <fx@gnu.org>
parents: 29498
diff changeset
516 With optional prefix DO-ALL 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
517 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
518 bindings.
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
519 Returns list of symbols and documentation found."
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
520 (interactive "sApropos documentation (regexp or words): \nP")
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
521 (setq apropos-regexp (apropos-rewrite-regexp apropos-regexp))
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
522 (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
523 (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
524 (let ((standard-input (get-buffer-create " apropos-temp"))
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
525 f v sf sv)
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
526 (unwind-protect
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
527 (save-excursion
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
528 (set-buffer standard-input)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
529 (apropos-documentation-check-doc-file)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
530 (if do-all
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
531 (mapatoms
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
532 (lambda (symbol)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
533 (setq f (apropos-safe-documentation symbol)
13752
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
534 v (get symbol 'variable-documentation))
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
535 (if (integerp v) (setq v))
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
536 (setq f (apropos-documentation-internal f)
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
537 v (apropos-documentation-internal v))
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
538 (setq sf (apropos-score-doc f)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
539 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
540 (if (or f v)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
541 (if (setq apropos-item
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
542 (cdr (assq symbol apropos-accumulator)))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
543 (progn
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
544 (if f
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
545 (progn
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
546 (setcar (nthcdr 1 apropos-item) f)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
547 (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
548 (if v
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
549 (progn
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
550 (setcar (nthcdr 2 apropos-item) v)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
551 (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
552 (setq apropos-accumulator
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
553 (cons (list symbol
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
554 (+ (apropos-score-symbol symbol 2) sf sv)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
555 f v)
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
556 apropos-accumulator)))))))
42256
f06cb3ff301f (apropos-print): SPACING is now nil or a separator string.
Richard M. Stallman <rms@gnu.org>
parents: 41154
diff changeset
557 (apropos-print nil "\n----------------\n"))
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
558 (kill-buffer standard-input))))
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
559
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
560
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
561 (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
562 (if (funcall predicate symbol)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
563 (progn
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
564 (setq symbol (prin1-to-string (funcall function symbol)))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
565 (if (string-match apropos-regexp symbol)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
566 (progn
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
567 (if apropos-match-face
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
568 (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
569 'face apropos-match-face
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
570 symbol))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
571 symbol)))))
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
572
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
573 (defun apropos-documentation-internal (doc)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
574 (if (consp doc)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
575 (apropos-documentation-check-elc-file (car doc))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
576 (and doc
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
577 (string-match apropos-all-regexp doc)
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
578 (progn
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
579 (if apropos-match-face
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
580 (put-text-property (match-beginning 0)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
581 (match-end 0)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
582 'face apropos-match-face
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
583 (setq doc (copy-sequence doc))))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
584 doc))))
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
585
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
586 (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
587 (setq pl (symbol-plist pl))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
588 (let (p p-out)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
589 (while pl
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
590 (setq p (format "%s %S" (car pl) (nth 1 pl)))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
591 (if (or (not compare) (string-match apropos-regexp p))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
592 (if apropos-property-face
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
593 (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
594 'face apropos-property-face p))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
595 (setq p nil))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
596 (if p
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
597 (progn
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
598 (and compare apropos-match-face
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
599 (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
600 'face apropos-match-face
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
601 p))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
602 (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
603 (setq pl (nthcdr 2 pl)))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
604 p-out))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
605
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
606
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
607 ;; Finds all documentation related to APROPOS-REGEXP in internal-doc-file-name.
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
608
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
609 (defun apropos-documentation-check-doc-file ()
13752
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
610 (let (type symbol (sepa 2) sepb beg end)
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
611 (insert ?\^_)
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
612 (backward-char)
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
613 (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
614 (forward-char)
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
615 (while (save-excursion
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
616 (setq sepb (search-forward "\^_"))
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
617 (not (eobp)))
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
618 (beginning-of-line 2)
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
619 (if (save-restriction
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
620 (narrow-to-region (point) (1- sepb))
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
621 (re-search-forward apropos-all-regexp nil t))
13752
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
622 (progn
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
623 (setq beg (match-beginning 0)
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
624 end (point))
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
625 (goto-char (1+ sepa))
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
626 (or (and (setq type (if (eq ?F (preceding-char))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
627 2 ; function documentation
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
628 3) ; variable documentation
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
629 symbol (read)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
630 beg (- beg (point) 1)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
631 end (- end (point) 1)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
632 doc (buffer-substring (1+ (point)) (1- sepb))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
633 apropos-item (assq symbol apropos-accumulator))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
634 (setcar (cdr apropos-item)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
635 (+ (cadr apropos-item) (apropos-score-doc doc))))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
636 (setq apropos-item (list symbol
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
637 (+ (apropos-score-symbol symbol 2)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
638 (apropos-score-doc doc))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
639 nil nil)
13752
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
640 apropos-accumulator (cons apropos-item
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
641 apropos-accumulator)))
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
642 (if apropos-match-face
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
643 (put-text-property beg end 'face apropos-match-face doc))
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
644 (setcar (nthcdr type apropos-item) doc)))
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
645 (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
646
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
647 (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
648 (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
649 nil
13752
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
650 (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
651 (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
652 (erase-buffer)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
653 (insert-file-contents file)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
654 (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
655 ;; 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
656 (setq end (read)
13752
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
657 beg (1+ (point))
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
658 end (+ (point) end -1))
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
659 (forward-char)
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
660 (if (save-restriction
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
661 ;; match ^ and $ relative to doc string
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
662 (narrow-to-region beg end)
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
663 (re-search-forward apropos-all-regexp nil t))
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
664 (progn
13752
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
665 (goto-char (+ end 2))
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
666 (setq doc (buffer-substring beg end)
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
667 end (- (match-end 0) beg)
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
668 beg (- (match-beginning 0) beg)
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
669 this-is-a-variable (looking-at "(def\\(var\\|const\\) ")
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
670 symbol (progn
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
671 (skip-chars-forward "(a-z")
13752
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
672 (forward-char)
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
673 (read))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
674 symbol (if (consp symbol)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
675 (nth 1 symbol)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
676 symbol))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
677 (if (if this-is-a-variable
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
678 (get symbol 'variable-documentation)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
679 (and (fboundp symbol) (apropos-safe-documentation symbol)))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
680 (progn
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
681 (or (and (setq apropos-item (assq symbol apropos-accumulator))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
682 (setcar (cdr apropos-item)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
683 (+ (cadr apropos-item) (apropos-score-doc doc))))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
684 (setq apropos-item (list symbol
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
685 (+ (apropos-score-symbol symbol 2)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
686 (apropos-score-doc doc))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
687 nil nil)
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
688 apropos-accumulator (cons apropos-item
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
689 apropos-accumulator)))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
690 (if apropos-match-face
13752
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
691 (put-text-property beg end 'face apropos-match-face
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
692 doc))
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
693 (setcar (nthcdr (if this-is-a-variable 3 2)
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
694 apropos-item)
13752
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
695 doc)))))))))
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
696
10283
1d1c5ea9eb86 (super-apropos-check-elc-file): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10282
diff changeset
697
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
698
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
699 (defun apropos-safe-documentation (function)
29764
dbfcedec53b3 Doc fixes.
Dave Love <fx@gnu.org>
parents: 29498
diff changeset
700 "Like `documentation', except it avoids calling `get_doc_string'.
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
701 Will return nil instead."
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
702 (while (and function (symbolp function))
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
703 (setq function (if (fboundp function)
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
704 (symbol-function function))))
3563
804e4f30b7ce (safe-documentation): Don't crash on byte-compiled macro.
Richard M. Stallman <rms@gnu.org>
parents: 2946
diff changeset
705 (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
706 (setq function (cdr function)))
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
707 (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
708 (if (> (length function) 4)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
709 (aref function 4))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
710 (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
711 (nth 2 function)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
712 (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
713 (if (stringp (nth 2 function))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
714 (nth 2 function)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
715 (if (stringp (nth 3 function))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
716 (nth 3 function)))))))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
717 (if (integerp function)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
718 nil
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
719 function))
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
720
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
721
22532
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
722 (defun apropos-print (do-keys spacing)
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
723 "Output result of apropos searching into buffer `*Apropos*'.
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
724 The value of `apropos-accumulator' is the list of items to output.
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
725 Each element should have the format
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
726 (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
727 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
728 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
729 `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
730
f06cb3ff301f (apropos-print): SPACING is now nil or a separator string.
Richard M. Stallman <rms@gnu.org>
parents: 41154
diff changeset
731 If SPACING is non-nil, it should be a string;
f06cb3ff301f (apropos-print): SPACING is now nil or a separator string.
Richard M. Stallman <rms@gnu.org>
parents: 41154
diff changeset
732 separate items with that string."
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
733 (if (null apropos-accumulator)
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
734 (message "No apropos matches for `%s'" apropos-orig-regexp)
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
735 (setq apropos-accumulator
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
736 (sort apropos-accumulator (lambda (a b)
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
737 (or (> (cadr a) (cadr b))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
738 (and (= (cadr a) (cadr b))
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
739 (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
740 (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
741 (let ((p apropos-accumulator)
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
742 (old-buffer (current-buffer))
39649
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
743 symbol item)
13752
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
744 (set-buffer standard-output)
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
745 (apropos-mode)
29199
cc07870ddb45 (apropos-print): Use display-mouse-p instead of
Eli Zaretskii <eliz@gnu.org>
parents: 28844
diff changeset
746 (if (display-mouse-p)
45115
237374f1a28e (apropos-print): Fix the reference to mouse-2.
Eli Zaretskii <eliz@gnu.org>
parents: 42560
diff changeset
747 (insert
237374f1a28e (apropos-print): Fix the reference to mouse-2.
Eli Zaretskii <eliz@gnu.org>
parents: 42560
diff changeset
748 "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
749 "you can click\n"
237374f1a28e (apropos-print): Fix the reference to mouse-2.
Eli Zaretskii <eliz@gnu.org>
parents: 42560
diff changeset
750 "mouse-2 (second button from right) on that text to "
237374f1a28e (apropos-print): Fix the reference to mouse-2.
Eli Zaretskii <eliz@gnu.org>
parents: 42560
diff changeset
751 "get more information.\n"))
39491
1f81f55f4241 (apropos-print): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 39489
diff changeset
752 (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
753 " or variable,\n"
464552acc8a0 (apropos-print): Make the directions inserted at the
Eli Zaretskii <eliz@gnu.org>
parents: 38436
diff changeset
754 (substitute-command-keys
464552acc8a0 (apropos-print): Make the directions inserted at the
Eli Zaretskii <eliz@gnu.org>
parents: 38436
diff changeset
755 "and type \\[apropos-follow] to get full documentation.\n\n"))
13752
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
756 (while (consp p)
42256
f06cb3ff301f (apropos-print): SPACING is now nil or a separator string.
Richard M. Stallman <rms@gnu.org>
parents: 41154
diff changeset
757 (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
758 (princ spacing))
13752
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
759 (setq apropos-item (car p)
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
760 symbol (car apropos-item)
39649
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
761 p (cdr p))
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
762 (insert-text-button (symbol-name symbol)
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
763 'type 'apropos-symbol
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
764 ;; 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
765 ;; changed the variable!
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
766 ;; Just say `no' to variables containing faces!
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
767 'face apropos-symbol-face)
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
768 (if apropos-show-scores
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
769 (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
770 ;; Calculate key-bindings if we want them.
13752
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
771 (and do-keys
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
772 (commandp symbol)
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
773 (indent-to 30 1)
14395
8e97dadccf2b (apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
774 (if (let ((keys
8e97dadccf2b (apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
775 (save-excursion
8e97dadccf2b (apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
776 (set-buffer old-buffer)
8e97dadccf2b (apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
777 (where-is-internal symbol)))
8e97dadccf2b (apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
778 filtered)
8e97dadccf2b (apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
779 ;; Copy over the list of key sequences,
8e97dadccf2b (apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
780 ;; omitting any that contain a buffer or a frame.
8e97dadccf2b (apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
781 (while keys
8e97dadccf2b (apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
782 (let ((key (car keys))
8e97dadccf2b (apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
783 (i 0)
8e97dadccf2b (apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
784 loser)
8e97dadccf2b (apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
785 (while (< i (length key))
8e97dadccf2b (apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
786 (if (or (framep (aref key i))
8e97dadccf2b (apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
787 (bufferp (aref key i)))
8e97dadccf2b (apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
788 (setq loser t))
8e97dadccf2b (apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
789 (setq i (1+ i)))
8e97dadccf2b (apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
790 (or loser
8e97dadccf2b (apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
791 (setq filtered (cons key filtered))))
8e97dadccf2b (apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
792 (setq keys (cdr keys)))
8e97dadccf2b (apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
793 (setq item filtered))
8e97dadccf2b (apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
794 ;; Convert the remaining keys to a string and insert.
8e97dadccf2b (apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
795 (insert
13752
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
796 (mapconcat
14395
8e97dadccf2b (apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
797 (lambda (key)
29764
dbfcedec53b3 Doc fixes.
Dave Love <fx@gnu.org>
parents: 29498
diff changeset
798 (setq key (condition-case ()
23386
ac8f85b1733c (apropos-print): control invalid characters.
Karl Heuer <kwzh@gnu.org>
parents: 22532
diff changeset
799 (key-description key)
ac8f85b1733c (apropos-print): control invalid characters.
Karl Heuer <kwzh@gnu.org>
parents: 22532
diff changeset
800 (error)))
14395
8e97dadccf2b (apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
801 (if apropos-keybinding-face
13752
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
802 (put-text-property 0 (length key)
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
803 'face apropos-keybinding-face
14395
8e97dadccf2b (apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
804 key))
8e97dadccf2b (apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
805 key)
8e97dadccf2b (apropos-print): Omit key sequences that contain a frame.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
806 item ", "))
15159
b22de331ee43 (apropos-print): If command has no key bindings, say how to run it with M-x.
Richard M. Stallman <rms@gnu.org>
parents: 14400
diff changeset
807 (insert "M-x")
b22de331ee43 (apropos-print): If command has no key bindings, say how to run it with M-x.
Richard M. Stallman <rms@gnu.org>
parents: 14400
diff changeset
808 (put-text-property (- (point) 3) (point)
b22de331ee43 (apropos-print): If command has no key bindings, say how to run it with M-x.
Richard M. Stallman <rms@gnu.org>
parents: 14400
diff changeset
809 'face apropos-keybinding-face)
b22de331ee43 (apropos-print): If command has no key bindings, say how to run it with M-x.
Richard M. Stallman <rms@gnu.org>
parents: 14400
diff changeset
810 (insert " " (symbol-name symbol) " ")
b22de331ee43 (apropos-print): If command has no key bindings, say how to run it with M-x.
Richard M. Stallman <rms@gnu.org>
parents: 14400
diff changeset
811 (insert "RET")
b22de331ee43 (apropos-print): If command has no key bindings, say how to run it with M-x.
Richard M. Stallman <rms@gnu.org>
parents: 14400
diff changeset
812 (put-text-property (- (point) 3) (point)
b22de331ee43 (apropos-print): If command has no key bindings, say how to run it with M-x.
Richard M. Stallman <rms@gnu.org>
parents: 14400
diff changeset
813 'face apropos-keybinding-face)))
13752
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
814 (terpri)
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
815 (apropos-print-doc 2
13752
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
816 (if (commandp symbol)
39677
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
817 'apropos-command
13752
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
818 (if (apropos-macrop symbol)
39677
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
819 'apropos-macro
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
820 'apropos-function))
20508
16f1fd128350 (apropos-print): Pass t instead of DO-KEYS
Richard M. Stallman <rms@gnu.org>
parents: 20480
diff changeset
821 t)
45482
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
822 (apropos-print-doc 3 'apropos-variable t)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
823 (apropos-print-doc 7 'apropos-group t)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
824 (apropos-print-doc 6 'apropos-face t)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
825 (apropos-print-doc 5 'apropos-widget t)
7928b3acfb90 (apropos-show-scores, apropos-orig-regexp)
Kim F. Storm <storm@cua.dk>
parents: 45115
diff changeset
826 (apropos-print-doc 4 'apropos-plist nil))
22532
5a83f0f3b29d (apropos-print): Delete arg DOC-FN.
Karl Heuer <kwzh@gnu.org>
parents: 22408
diff changeset
827 (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
828 (prog1 apropos-accumulator
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
829 (setq apropos-accumulator ()))) ; permit gc
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
830
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
831
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
832 (defun apropos-macrop (symbol)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
833 "T if SYMBOL is a Lisp macro."
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
834 (and (fboundp symbol)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
835 (consp (setq symbol
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
836 (symbol-function symbol)))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
837 (or (eq (car symbol) 'macro)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
838 (if (eq (car symbol) 'autoload)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
839 (memq (nth 4 symbol)
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
840 '(macro t))))))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
841
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
842
39677
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
843 (defun apropos-print-doc (i type do-keys)
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
844 (if (stringp (setq i (nth i apropos-item)))
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
845 (progn
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
846 (insert " ")
39677
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
847 (insert-text-button (button-type-get type 'apropos-label)
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
848 'type type
39649
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
849 ;; Can't use the default button face, since
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
850 ;; user may have changed the variable!
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
851 ;; Just say `no' to variables containing faces!
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
852 'face apropos-label-face
39677
05b7a0e7b426 (apropos-symbol): Add `skip' property.
Miles Bader <miles@gnu.org>
parents: 39669
diff changeset
853 'apropos-symbol (car apropos-item))
39649
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
854 (insert ": ")
12640
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
855 (insert (if do-keys (substitute-command-keys i) i))
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
856 (or (bolp) (terpri)))))
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
857
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
858
39649
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
859 (defun apropos-follow ()
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
860 "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
861 (interactive)
39649
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
862 (button-activate
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
863 (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
864 (error "There is nothing to follow here"))))
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
865
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
866
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
867 (defun apropos-describe-plist (symbol)
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
868 "Display a pretty listing of SYMBOL's plist."
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
869 (with-output-to-temp-buffer "*Help*"
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
870 (set-buffer standard-output)
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
871 (princ "Symbol ")
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
872 (prin1 symbol)
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
873 (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
874 (if apropos-symbol-face
d194c63cb75c Add latest changes of old library and some more.
Karl Heuer <kwzh@gnu.org>
parents: 12498
diff changeset
875 (put-text-property 8 (- (point) 14) 'face apropos-symbol-face))
12498
9fb6a9b6658b Restructured, largely rewritten and extended.
Karl Heuer <kwzh@gnu.org>
parents: 11190
diff changeset
876 (insert (apropos-format-plist symbol "\n "))
13752
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
877 (princ ")")
e3b945c8141e (apropos-match-face): Use `secondary-selection' rather
Karl Heuer <kwzh@gnu.org>
parents: 13656
diff changeset
878 (print-help-return-message)))
367
6c230193acf9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
879
39649
7edeec63e660 (apropos-symbol, apropos-label): New button types.
Miles Bader <miles@gnu.org>
parents: 39491
diff changeset
880
18383
11218164bc54 Add provide call.
Richard M. Stallman <rms@gnu.org>
parents: 17559
diff changeset
881 (provide 'apropos)
11218164bc54 Add provide call.
Richard M. Stallman <rms@gnu.org>
parents: 17559
diff changeset
882
662
8a533acedb77 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 444
diff changeset
883 ;;; apropos.el ends here