2001-07-16 12:23:00 +00:00
|
|
|
|
;;; apropos.el --- apropos commands for users and programmers
|
1992-05-30 23:54:21 +00:00
|
|
|
|
|
2012-01-05 09:46:05 +00:00
|
|
|
|
;; Copyright (C) 1989, 1994-1995, 2001-2012 Free Software Foundation, Inc.
|
1992-07-22 04:22:30 +00:00
|
|
|
|
|
1992-07-16 21:47:34 +00:00
|
|
|
|
;; Author: Joe Wells <jbw@bigbird.bu.edu>
|
2009-02-21 03:18:42 +00:00
|
|
|
|
;; Daniel Pfeiffer <occitan@esperanto.org> (rewrite)
|
1993-03-18 21:29:42 +00:00
|
|
|
|
;; Keywords: help
|
2010-08-29 20:10:43 +00:00
|
|
|
|
;; Package: emacs
|
1992-07-16 21:47:34 +00:00
|
|
|
|
|
1991-07-31 02:49:11 +00:00
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
2008-05-06 08:06:51 +00:00
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
1991-07-31 02:49:11 +00:00
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 08:06:51 +00:00
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
1991-07-31 02:49:11 +00:00
|
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2008-05-06 08:06:51 +00:00
|
|
|
|
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
1991-07-31 02:49:11 +00:00
|
|
|
|
|
1992-07-16 21:47:34 +00:00
|
|
|
|
;;; Commentary:
|
1991-07-31 02:49:11 +00:00
|
|
|
|
|
|
|
|
|
;; The ideas for this package were derived from the C code in
|
|
|
|
|
;; src/keymap.c and elsewhere. The functions in this file should
|
|
|
|
|
;; always be byte-compiled for speed. Someone should rewrite this in
|
|
|
|
|
;; C (as part of src/keymap.c) for speed.
|
|
|
|
|
|
|
|
|
|
;; The idea for super-apropos is based on the original implementation
|
|
|
|
|
;; by Lynn Slater <lrs@esl.com>.
|
|
|
|
|
|
|
|
|
|
;; History:
|
|
|
|
|
;; Fixed bug, current-local-map can return nil.
|
|
|
|
|
;; Change, doesn't calculate key-bindings unless needed.
|
|
|
|
|
;; Added super-apropos capability, changed print functions.
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
|
;; Made fast-apropos and super-apropos share code.
|
|
|
|
|
;; Sped up fast-apropos again.
|
1991-07-31 02:49:11 +00:00
|
|
|
|
;; Added apropos-do-all option.
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
|
;; Added fast-command-apropos.
|
1991-07-31 02:49:11 +00:00
|
|
|
|
;; Changed doc strings to comments for helping functions.
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
|
;; Made doc file buffer read-only, buried it.
|
1991-07-31 02:49:11 +00:00
|
|
|
|
;; Only call substitute-command-keys if do-all set.
|
|
|
|
|
|
1995-07-22 15:17:54 +00:00
|
|
|
|
;; Optionally use configurable faces to make the output more legible.
|
|
|
|
|
;; Differentiate between command, function and macro.
|
1995-07-07 18:53:58 +00:00
|
|
|
|
;; Apropos-command (ex command-apropos) does cmd and optionally user var.
|
|
|
|
|
;; Apropos shows all 3 aspects of symbols (fn, var and plist)
|
|
|
|
|
;; Apropos-documentation (ex super-apropos) now finds all it should.
|
|
|
|
|
;; New apropos-value snoops through all values and optionally plists.
|
|
|
|
|
;; Reading DOC file doesn't load nroff.
|
|
|
|
|
;; Added hypertext following of documentation, mouse-2 on variable gives value
|
|
|
|
|
;; from buffer in active window.
|
|
|
|
|
|
1992-07-16 21:47:34 +00:00
|
|
|
|
;;; Code:
|
|
|
|
|
|
2001-10-09 12:09:25 +00:00
|
|
|
|
(require 'button)
|
|
|
|
|
|
1997-07-24 07:43:07 +00:00
|
|
|
|
(defgroup apropos nil
|
2005-07-04 01:46:37 +00:00
|
|
|
|
"Apropos commands for users and programmers."
|
1999-08-16 23:04:07 +00:00
|
|
|
|
:group 'help
|
1997-07-24 07:43:07 +00:00
|
|
|
|
:prefix "apropos")
|
|
|
|
|
|
1995-07-07 18:53:58 +00:00
|
|
|
|
;; I see a degradation of maybe 10-20% only.
|
1997-07-24 07:43:07 +00:00
|
|
|
|
(defcustom apropos-do-all nil
|
2011-11-12 02:13:23 +00:00
|
|
|
|
"Non nil means apropos commands will search more extensively.
|
|
|
|
|
This may be slower. This option affects the following commands:
|
|
|
|
|
|
|
|
|
|
`apropos-variable' will search all variables, not just user variables.
|
|
|
|
|
`apropos-command' will also search non-interactive functions.
|
|
|
|
|
`apropos' will search all symbols, not just functions, variables, faces,
|
|
|
|
|
and those with property lists.
|
|
|
|
|
`apropos-value' will also search in property lists and functions.
|
|
|
|
|
`apropos-documentation' will search all documentation strings, not just
|
|
|
|
|
those in the etc/DOC documentation file.
|
|
|
|
|
|
|
|
|
|
This option only controls the default behavior. Each of the above
|
|
|
|
|
commands also has an optional argument to request a more extensive search.
|
|
|
|
|
|
|
|
|
|
Additionally, this option makes the function `apropos-library'
|
|
|
|
|
include key-binding information in its output."
|
1997-07-24 07:43:07 +00:00
|
|
|
|
:group 'apropos
|
|
|
|
|
:type 'boolean)
|
1995-07-07 18:53:58 +00:00
|
|
|
|
|
Use proper faces in apropos.el.
* lisp/apropos.el (apropos-symbol, apropos-keybinding, apropos-label)
(apropos-property, apropos-function-button)
(apropos-variable-button, apropos-misc-button): New faces.
(apropos-symbol-face, apropos-keybinding-face)
(apropos-label-face, apropos-property-face, apropos-match-face):
Variables removed.
(apropos-library-button, apropos-format-plist, apropos-print)
(apropos-print-doc, apropos-describe-plist): Callers changed.
Fixes: debbugs:8396
2012-04-23 15:38:48 +00:00
|
|
|
|
(defface apropos-symbol
|
|
|
|
|
'((t (:inherit bold)))
|
|
|
|
|
"Face for the symbol name in Apropos output."
|
|
|
|
|
:group 'apropos
|
2012-08-15 16:29:11 +00:00
|
|
|
|
:version "24.3")
|
1995-07-07 18:53:58 +00:00
|
|
|
|
|
Use proper faces in apropos.el.
* lisp/apropos.el (apropos-symbol, apropos-keybinding, apropos-label)
(apropos-property, apropos-function-button)
(apropos-variable-button, apropos-misc-button): New faces.
(apropos-symbol-face, apropos-keybinding-face)
(apropos-label-face, apropos-property-face, apropos-match-face):
Variables removed.
(apropos-library-button, apropos-format-plist, apropos-print)
(apropos-print-doc, apropos-describe-plist): Callers changed.
Fixes: debbugs:8396
2012-04-23 15:38:48 +00:00
|
|
|
|
(defface apropos-keybinding
|
|
|
|
|
'((t (:inherit underline)))
|
|
|
|
|
"Face for lists of keybinding in Apropos output."
|
1997-07-24 07:43:07 +00:00
|
|
|
|
:group 'apropos
|
2012-08-15 16:29:11 +00:00
|
|
|
|
:version "24.3")
|
1995-07-22 15:17:54 +00:00
|
|
|
|
|
Use proper faces in apropos.el.
* lisp/apropos.el (apropos-symbol, apropos-keybinding, apropos-label)
(apropos-property, apropos-function-button)
(apropos-variable-button, apropos-misc-button): New faces.
(apropos-symbol-face, apropos-keybinding-face)
(apropos-label-face, apropos-property-face, apropos-match-face):
Variables removed.
(apropos-library-button, apropos-format-plist, apropos-print)
(apropos-print-doc, apropos-describe-plist): Callers changed.
Fixes: debbugs:8396
2012-04-23 15:38:48 +00:00
|
|
|
|
(defface apropos-property
|
|
|
|
|
'((t (:inherit font-lock-builtin-face)))
|
|
|
|
|
"Face for property name in apropos output, or nil for none."
|
1997-07-24 07:43:07 +00:00
|
|
|
|
:group 'apropos
|
2012-08-15 16:29:11 +00:00
|
|
|
|
:version "24.3")
|
1995-07-22 15:17:54 +00:00
|
|
|
|
|
Use proper faces in apropos.el.
* lisp/apropos.el (apropos-symbol, apropos-keybinding, apropos-label)
(apropos-property, apropos-function-button)
(apropos-variable-button, apropos-misc-button): New faces.
(apropos-symbol-face, apropos-keybinding-face)
(apropos-label-face, apropos-property-face, apropos-match-face):
Variables removed.
(apropos-library-button, apropos-format-plist, apropos-print)
(apropos-print-doc, apropos-describe-plist): Callers changed.
Fixes: debbugs:8396
2012-04-23 15:38:48 +00:00
|
|
|
|
(defface apropos-function-button
|
|
|
|
|
'((t (:inherit (font-lock-function-name-face button))))
|
|
|
|
|
"Button face indicating a function, macro, or command in Apropos."
|
1997-07-24 07:43:07 +00:00
|
|
|
|
:group 'apropos
|
2012-08-15 16:29:11 +00:00
|
|
|
|
:version "24.3")
|
1995-07-22 15:17:54 +00:00
|
|
|
|
|
Use proper faces in apropos.el.
* lisp/apropos.el (apropos-symbol, apropos-keybinding, apropos-label)
(apropos-property, apropos-function-button)
(apropos-variable-button, apropos-misc-button): New faces.
(apropos-symbol-face, apropos-keybinding-face)
(apropos-label-face, apropos-property-face, apropos-match-face):
Variables removed.
(apropos-library-button, apropos-format-plist, apropos-print)
(apropos-print-doc, apropos-describe-plist): Callers changed.
Fixes: debbugs:8396
2012-04-23 15:38:48 +00:00
|
|
|
|
(defface apropos-variable-button
|
|
|
|
|
'((t (:inherit (font-lock-variable-name-face button))))
|
|
|
|
|
"Button face indicating a variable in Apropos."
|
1997-07-24 07:43:07 +00:00
|
|
|
|
:group 'apropos
|
2012-08-15 16:29:11 +00:00
|
|
|
|
:version "24.3")
|
Use proper faces in apropos.el.
* lisp/apropos.el (apropos-symbol, apropos-keybinding, apropos-label)
(apropos-property, apropos-function-button)
(apropos-variable-button, apropos-misc-button): New faces.
(apropos-symbol-face, apropos-keybinding-face)
(apropos-label-face, apropos-property-face, apropos-match-face):
Variables removed.
(apropos-library-button, apropos-format-plist, apropos-print)
(apropos-print-doc, apropos-describe-plist): Callers changed.
Fixes: debbugs:8396
2012-04-23 15:38:48 +00:00
|
|
|
|
|
|
|
|
|
(defface apropos-misc-button
|
|
|
|
|
'((t (:inherit (font-lock-constant-face button))))
|
|
|
|
|
"Button face indicating a miscellaneous object type in Apropos."
|
|
|
|
|
:group 'apropos
|
2012-08-15 16:29:11 +00:00
|
|
|
|
:version "24.3")
|
1995-07-22 15:17:54 +00:00
|
|
|
|
|
2004-12-16 07:16:58 +00:00
|
|
|
|
(defcustom apropos-match-face 'match
|
2008-06-08 03:48:22 +00:00
|
|
|
|
"Face for matching text in Apropos documentation/value, or nil for none.
|
1999-09-17 19:43:09 +00:00
|
|
|
|
This applies when you look for matches in the documentation or variable value
|
2005-11-12 00:10:40 +00:00
|
|
|
|
for the pattern; the part that matches gets displayed in this font."
|
1997-07-24 07:43:07 +00:00
|
|
|
|
:group 'apropos
|
2012-08-15 16:29:11 +00:00
|
|
|
|
:version "24.3")
|
1995-07-07 18:53:58 +00:00
|
|
|
|
|
2003-07-14 21:49:02 +00:00
|
|
|
|
(defcustom apropos-sort-by-scores nil
|
2008-06-08 03:48:22 +00:00
|
|
|
|
"Non-nil means sort matches by scores; best match is shown first.
|
2005-11-12 00:10:40 +00:00
|
|
|
|
This applies to all `apropos' commands except `apropos-documentation'.
|
|
|
|
|
If value is `verbose', the computed score is shown for each match."
|
2003-07-12 21:57:50 +00:00
|
|
|
|
:group 'apropos
|
2005-11-12 00:10:40 +00:00
|
|
|
|
:type '(choice (const :tag "off" nil)
|
|
|
|
|
(const :tag "on" t)
|
|
|
|
|
(const :tag "show scores" verbose)))
|
|
|
|
|
|
|
|
|
|
(defcustom apropos-documentation-sort-by-scores t
|
2008-12-03 05:48:14 +00:00
|
|
|
|
"Non-nil means sort matches by scores; best match is shown first.
|
2005-11-12 00:10:40 +00:00
|
|
|
|
This applies to `apropos-documentation' only.
|
|
|
|
|
If value is `verbose', the computed score is shown for each match."
|
|
|
|
|
:group 'apropos
|
|
|
|
|
:type '(choice (const :tag "off" nil)
|
|
|
|
|
(const :tag "on" t)
|
|
|
|
|
(const :tag "show scores" verbose)))
|
1991-07-31 02:49:11 +00:00
|
|
|
|
|
1995-12-19 22:01:53 +00:00
|
|
|
|
(defvar apropos-mode-map
|
2011-02-01 21:22:21 +00:00
|
|
|
|
(let ((map (copy-keymap button-buffer-map)))
|
|
|
|
|
(set-keymap-parent map special-mode-map)
|
2001-10-07 11:35:09 +00:00
|
|
|
|
;; Use `apropos-follow' instead of just using the button
|
|
|
|
|
;; definition of RET, so that users can use it anywhere in an
|
|
|
|
|
;; apropos item, not just on top of a button.
|
1995-07-07 18:53:58 +00:00
|
|
|
|
(define-key map "\C-m" 'apropos-follow)
|
|
|
|
|
map)
|
1995-12-19 22:01:53 +00:00
|
|
|
|
"Keymap used in Apropos mode.")
|
1995-04-03 21:38:06 +00:00
|
|
|
|
|
2000-06-07 15:38:54 +00:00
|
|
|
|
(defvar apropos-mode-hook nil
|
2008-06-08 03:48:22 +00:00
|
|
|
|
"Hook run when mode is turned on.")
|
1995-07-07 18:53:58 +00:00
|
|
|
|
|
2005-11-10 03:18:51 +00:00
|
|
|
|
(defvar apropos-pattern nil
|
2005-11-12 00:10:40 +00:00
|
|
|
|
"Apropos pattern as entered by user.")
|
|
|
|
|
|
|
|
|
|
(defvar apropos-pattern-quoted nil
|
2006-10-13 19:32:50 +00:00
|
|
|
|
"Apropos pattern passed through `regexp-quote'.")
|
2005-11-12 00:10:40 +00:00
|
|
|
|
|
|
|
|
|
(defvar apropos-words ()
|
|
|
|
|
"Current list of apropos words extracted from `apropos-pattern'.")
|
1995-07-22 15:17:54 +00:00
|
|
|
|
|
2005-11-12 00:10:40 +00:00
|
|
|
|
(defvar apropos-all-words ()
|
|
|
|
|
"Current list of words and synonyms.")
|
2002-05-23 10:20:12 +00:00
|
|
|
|
|
2005-11-12 00:10:40 +00:00
|
|
|
|
(defvar apropos-regexp nil
|
|
|
|
|
"Regexp used in current apropos run.")
|
|
|
|
|
|
|
|
|
|
(defvar apropos-all-words-regexp nil
|
2002-05-23 10:20:12 +00:00
|
|
|
|
"Regexp matching apropos-all-words.")
|
|
|
|
|
|
1995-07-22 15:17:54 +00:00
|
|
|
|
(defvar apropos-files-scanned ()
|
1996-01-04 23:27:11 +00:00
|
|
|
|
"List of elc files already scanned in current run of `apropos-documentation'.")
|
1995-07-22 15:17:54 +00:00
|
|
|
|
|
|
|
|
|
(defvar apropos-accumulator ()
|
2011-04-24 00:15:26 +00:00
|
|
|
|
"Alist of symbols already found in current apropos run.
|
|
|
|
|
Each element has the form
|
|
|
|
|
|
|
|
|
|
(SYMBOL SCORE FUN-DOC VAR-DOC PLIST WIDGET-DOC FACE-DOC CUS-GROUP-DOC)
|
|
|
|
|
|
|
|
|
|
where SYMBOL is the symbol name, SCORE is its relevance score (a
|
|
|
|
|
number), FUN-DOC is the function docstring, VAR-DOC is the
|
|
|
|
|
variable docstring, PLIST is the list of the symbols names in the
|
|
|
|
|
property list, WIDGET-DOC is the widget docstring, FACE-DOC is
|
|
|
|
|
the face docstring, and CUS-GROUP-DOC is the custom group
|
|
|
|
|
docstring. Each docstring is either nil or a string.")
|
1995-07-07 18:53:58 +00:00
|
|
|
|
|
1995-07-22 15:17:54 +00:00
|
|
|
|
(defvar apropos-item ()
|
2000-06-20 09:58:07 +00:00
|
|
|
|
"Current item in or for `apropos-accumulator'.")
|
2001-10-07 11:35:09 +00:00
|
|
|
|
|
2002-05-23 10:20:12 +00:00
|
|
|
|
(defvar apropos-synonyms '(
|
|
|
|
|
("find" "open" "edit")
|
|
|
|
|
("kill" "cut")
|
2006-03-24 13:28:23 +00:00
|
|
|
|
("yank" "paste")
|
|
|
|
|
("region" "selection"))
|
2002-05-23 10:20:12 +00:00
|
|
|
|
"List of synonyms known by apropos.
|
2006-11-06 02:41:31 +00:00
|
|
|
|
Each element is a list of words where the first word is the standard Emacs
|
2002-05-23 10:20:12 +00:00
|
|
|
|
term, and the rest of the words are alternative terms.")
|
|
|
|
|
|
2001-10-07 11:35:09 +00:00
|
|
|
|
|
|
|
|
|
;;; Button types used by apropos
|
|
|
|
|
|
|
|
|
|
(define-button-type 'apropos-symbol
|
Use proper faces in apropos.el.
* lisp/apropos.el (apropos-symbol, apropos-keybinding, apropos-label)
(apropos-property, apropos-function-button)
(apropos-variable-button, apropos-misc-button): New faces.
(apropos-symbol-face, apropos-keybinding-face)
(apropos-label-face, apropos-property-face, apropos-match-face):
Variables removed.
(apropos-library-button, apropos-format-plist, apropos-print)
(apropos-print-doc, apropos-describe-plist): Callers changed.
Fixes: debbugs:8396
2012-04-23 15:38:48 +00:00
|
|
|
|
'face 'apropos-symbol
|
2001-10-08 06:58:32 +00:00
|
|
|
|
'help-echo "mouse-2, RET: Display more help on this symbol"
|
2004-12-17 15:17:22 +00:00
|
|
|
|
'follow-link t
|
2008-07-31 22:15:18 +00:00
|
|
|
|
'action #'apropos-symbol-button-display-help)
|
2001-10-07 11:35:09 +00:00
|
|
|
|
|
|
|
|
|
(defun apropos-symbol-button-display-help (button)
|
|
|
|
|
"Display further help for the `apropos-symbol' button BUTTON."
|
|
|
|
|
(button-activate
|
|
|
|
|
(or (apropos-next-label-button (button-start button))
|
|
|
|
|
(error "There is nothing to follow for `%s'" (button-label button)))))
|
|
|
|
|
|
2001-10-08 06:58:32 +00:00
|
|
|
|
(define-button-type 'apropos-function
|
|
|
|
|
'apropos-label "Function"
|
2008-06-10 02:44:48 +00:00
|
|
|
|
'apropos-short-label "f"
|
Use proper faces in apropos.el.
* lisp/apropos.el (apropos-symbol, apropos-keybinding, apropos-label)
(apropos-property, apropos-function-button)
(apropos-variable-button, apropos-misc-button): New faces.
(apropos-symbol-face, apropos-keybinding-face)
(apropos-label-face, apropos-property-face, apropos-match-face):
Variables removed.
(apropos-library-button, apropos-format-plist, apropos-print)
(apropos-print-doc, apropos-describe-plist): Callers changed.
Fixes: debbugs:8396
2012-04-23 15:38:48 +00:00
|
|
|
|
'face 'apropos-function-button
|
2004-12-17 15:17:22 +00:00
|
|
|
|
'help-echo "mouse-2, RET: Display more help on this function"
|
|
|
|
|
'follow-link t
|
2001-10-08 06:58:32 +00:00
|
|
|
|
'action (lambda (button)
|
2004-12-17 15:17:22 +00:00
|
|
|
|
(describe-function (button-get button 'apropos-symbol))))
|
|
|
|
|
|
2001-10-08 06:58:32 +00:00
|
|
|
|
(define-button-type 'apropos-macro
|
|
|
|
|
'apropos-label "Macro"
|
2008-06-10 02:44:48 +00:00
|
|
|
|
'apropos-short-label "m"
|
Use proper faces in apropos.el.
* lisp/apropos.el (apropos-symbol, apropos-keybinding, apropos-label)
(apropos-property, apropos-function-button)
(apropos-variable-button, apropos-misc-button): New faces.
(apropos-symbol-face, apropos-keybinding-face)
(apropos-label-face, apropos-property-face, apropos-match-face):
Variables removed.
(apropos-library-button, apropos-format-plist, apropos-print)
(apropos-print-doc, apropos-describe-plist): Callers changed.
Fixes: debbugs:8396
2012-04-23 15:38:48 +00:00
|
|
|
|
'face 'apropos-function-button
|
2004-12-17 15:17:22 +00:00
|
|
|
|
'help-echo "mouse-2, RET: Display more help on this macro"
|
|
|
|
|
'follow-link t
|
2001-10-08 06:58:32 +00:00
|
|
|
|
'action (lambda (button)
|
2004-12-17 15:17:22 +00:00
|
|
|
|
(describe-function (button-get button 'apropos-symbol))))
|
|
|
|
|
|
2001-10-08 06:58:32 +00:00
|
|
|
|
(define-button-type 'apropos-command
|
|
|
|
|
'apropos-label "Command"
|
2008-06-10 02:44:48 +00:00
|
|
|
|
'apropos-short-label "c"
|
Use proper faces in apropos.el.
* lisp/apropos.el (apropos-symbol, apropos-keybinding, apropos-label)
(apropos-property, apropos-function-button)
(apropos-variable-button, apropos-misc-button): New faces.
(apropos-symbol-face, apropos-keybinding-face)
(apropos-label-face, apropos-property-face, apropos-match-face):
Variables removed.
(apropos-library-button, apropos-format-plist, apropos-print)
(apropos-print-doc, apropos-describe-plist): Callers changed.
Fixes: debbugs:8396
2012-04-23 15:38:48 +00:00
|
|
|
|
'face 'apropos-function-button
|
2004-12-17 15:17:22 +00:00
|
|
|
|
'help-echo "mouse-2, RET: Display more help on this command"
|
|
|
|
|
'follow-link t
|
2001-10-08 06:58:32 +00:00
|
|
|
|
'action (lambda (button)
|
2004-12-17 15:17:22 +00:00
|
|
|
|
(describe-function (button-get button 'apropos-symbol))))
|
2002-01-05 19:02:27 +00:00
|
|
|
|
|
2001-10-08 06:58:32 +00:00
|
|
|
|
;; We used to use `customize-variable-other-window' instead for a
|
|
|
|
|
;; customizable variable, but that is slow. It is better to show an
|
|
|
|
|
;; ordinary help buffer and let the user click on the customization
|
|
|
|
|
;; button in that buffer, if he wants to.
|
|
|
|
|
;; Likewise for `customize-face-other-window'.
|
|
|
|
|
(define-button-type 'apropos-variable
|
|
|
|
|
'apropos-label "Variable"
|
2008-06-10 02:44:48 +00:00
|
|
|
|
'apropos-short-label "v"
|
Use proper faces in apropos.el.
* lisp/apropos.el (apropos-symbol, apropos-keybinding, apropos-label)
(apropos-property, apropos-function-button)
(apropos-variable-button, apropos-misc-button): New faces.
(apropos-symbol-face, apropos-keybinding-face)
(apropos-label-face, apropos-property-face, apropos-match-face):
Variables removed.
(apropos-library-button, apropos-format-plist, apropos-print)
(apropos-print-doc, apropos-describe-plist): Callers changed.
Fixes: debbugs:8396
2012-04-23 15:38:48 +00:00
|
|
|
|
'face 'apropos-variable-button
|
2001-10-08 06:58:32 +00:00
|
|
|
|
'help-echo "mouse-2, RET: Display more help on this variable"
|
2004-12-17 15:17:22 +00:00
|
|
|
|
'follow-link t
|
2001-10-08 06:58:32 +00:00
|
|
|
|
'action (lambda (button)
|
|
|
|
|
(describe-variable (button-get button 'apropos-symbol))))
|
|
|
|
|
|
|
|
|
|
(define-button-type 'apropos-face
|
|
|
|
|
'apropos-label "Face"
|
2008-06-10 02:44:48 +00:00
|
|
|
|
'apropos-short-label "F"
|
2011-04-24 00:15:26 +00:00
|
|
|
|
'face '(font-lock-variable-name-face button)
|
2001-10-08 06:58:32 +00:00
|
|
|
|
'help-echo "mouse-2, RET: Display more help on this face"
|
2004-12-17 15:17:22 +00:00
|
|
|
|
'follow-link t
|
2001-10-08 06:58:32 +00:00
|
|
|
|
'action (lambda (button)
|
|
|
|
|
(describe-face (button-get button 'apropos-symbol))))
|
|
|
|
|
|
|
|
|
|
(define-button-type 'apropos-group
|
|
|
|
|
'apropos-label "Group"
|
2008-06-10 02:44:48 +00:00
|
|
|
|
'apropos-short-label "g"
|
Use proper faces in apropos.el.
* lisp/apropos.el (apropos-symbol, apropos-keybinding, apropos-label)
(apropos-property, apropos-function-button)
(apropos-variable-button, apropos-misc-button): New faces.
(apropos-symbol-face, apropos-keybinding-face)
(apropos-label-face, apropos-property-face, apropos-match-face):
Variables removed.
(apropos-library-button, apropos-format-plist, apropos-print)
(apropos-print-doc, apropos-describe-plist): Callers changed.
Fixes: debbugs:8396
2012-04-23 15:38:48 +00:00
|
|
|
|
'face 'apropos-misc-button
|
2001-10-08 06:58:32 +00:00
|
|
|
|
'help-echo "mouse-2, RET: Display more help on this group"
|
2004-12-17 15:17:22 +00:00
|
|
|
|
'follow-link t
|
2001-10-08 06:58:32 +00:00
|
|
|
|
'action (lambda (button)
|
2002-10-20 21:03:54 +00:00
|
|
|
|
(customize-group-other-window
|
2001-10-08 06:58:32 +00:00
|
|
|
|
(button-get button 'apropos-symbol))))
|
|
|
|
|
|
|
|
|
|
(define-button-type 'apropos-widget
|
|
|
|
|
'apropos-label "Widget"
|
2008-06-10 02:44:48 +00:00
|
|
|
|
'apropos-short-label "w"
|
Use proper faces in apropos.el.
* lisp/apropos.el (apropos-symbol, apropos-keybinding, apropos-label)
(apropos-property, apropos-function-button)
(apropos-variable-button, apropos-misc-button): New faces.
(apropos-symbol-face, apropos-keybinding-face)
(apropos-label-face, apropos-property-face, apropos-match-face):
Variables removed.
(apropos-library-button, apropos-format-plist, apropos-print)
(apropos-print-doc, apropos-describe-plist): Callers changed.
Fixes: debbugs:8396
2012-04-23 15:38:48 +00:00
|
|
|
|
'face 'apropos-misc-button
|
2001-10-08 06:58:32 +00:00
|
|
|
|
'help-echo "mouse-2, RET: Display more help on this widget"
|
2004-12-17 15:17:22 +00:00
|
|
|
|
'follow-link t
|
2001-10-08 06:58:32 +00:00
|
|
|
|
'action (lambda (button)
|
|
|
|
|
(widget-browse-other-window (button-get button 'apropos-symbol))))
|
|
|
|
|
|
|
|
|
|
(define-button-type 'apropos-plist
|
2011-04-24 00:15:26 +00:00
|
|
|
|
'apropos-label "Properties"
|
2008-06-10 02:44:48 +00:00
|
|
|
|
'apropos-short-label "p"
|
Use proper faces in apropos.el.
* lisp/apropos.el (apropos-symbol, apropos-keybinding, apropos-label)
(apropos-property, apropos-function-button)
(apropos-variable-button, apropos-misc-button): New faces.
(apropos-symbol-face, apropos-keybinding-face)
(apropos-label-face, apropos-property-face, apropos-match-face):
Variables removed.
(apropos-library-button, apropos-format-plist, apropos-print)
(apropos-print-doc, apropos-describe-plist): Callers changed.
Fixes: debbugs:8396
2012-04-23 15:38:48 +00:00
|
|
|
|
'face 'apropos-misc-button
|
2001-10-08 06:58:32 +00:00
|
|
|
|
'help-echo "mouse-2, RET: Display more help on this plist"
|
2004-12-17 15:17:22 +00:00
|
|
|
|
'follow-link t
|
2001-10-08 06:58:32 +00:00
|
|
|
|
'action (lambda (button)
|
|
|
|
|
(apropos-describe-plist (button-get button 'apropos-symbol))))
|
2001-10-07 11:35:09 +00:00
|
|
|
|
|
2008-06-08 04:32:43 +00:00
|
|
|
|
(define-button-type 'apropos-library
|
|
|
|
|
'help-echo "mouse-2, RET: Display more help on this library"
|
|
|
|
|
'follow-link t
|
|
|
|
|
'action (lambda (button)
|
|
|
|
|
(apropos-library (button-get button 'apropos-symbol))))
|
|
|
|
|
|
2001-10-07 11:35:09 +00:00
|
|
|
|
(defun apropos-next-label-button (pos)
|
2001-11-16 18:30:25 +00:00
|
|
|
|
"Return the next apropos label button after POS, or nil if there's none.
|
2001-10-07 11:35:09 +00:00
|
|
|
|
Will also return nil if more than one `apropos-symbol' button is encountered
|
|
|
|
|
before finding a label."
|
2001-10-08 06:13:07 +00:00
|
|
|
|
(let* ((button (next-button pos t))
|
2001-10-07 11:35:09 +00:00
|
|
|
|
(already-hit-symbol nil)
|
2001-10-08 16:37:44 +00:00
|
|
|
|
(label (and button (button-get button 'apropos-label)))
|
|
|
|
|
(type (and button (button-get button 'type))))
|
2001-10-07 11:35:09 +00:00
|
|
|
|
(while (and button
|
2001-10-08 16:37:44 +00:00
|
|
|
|
(not label)
|
|
|
|
|
(or (not (eq type 'apropos-symbol))
|
2001-10-07 11:35:09 +00:00
|
|
|
|
(not already-hit-symbol)))
|
2001-10-08 16:37:44 +00:00
|
|
|
|
(when (eq type 'apropos-symbol)
|
2001-10-07 11:35:09 +00:00
|
|
|
|
(setq already-hit-symbol t))
|
|
|
|
|
(setq button (next-button (button-start button)))
|
|
|
|
|
(when button
|
2001-10-08 16:37:44 +00:00
|
|
|
|
(setq label (button-get button 'apropos-label))
|
|
|
|
|
(setq type (button-get button 'type))))
|
|
|
|
|
(and label button)))
|
2001-10-07 11:35:09 +00:00
|
|
|
|
|
1995-07-22 15:17:54 +00:00
|
|
|
|
|
2002-05-23 10:20:12 +00:00
|
|
|
|
(defun apropos-words-to-regexp (words wild)
|
|
|
|
|
"Make regexp matching any two of the words in WORDS."
|
|
|
|
|
(concat "\\("
|
|
|
|
|
(mapconcat 'identity words "\\|")
|
2003-08-02 20:36:51 +00:00
|
|
|
|
"\\)"
|
2003-02-04 11:26:42 +00:00
|
|
|
|
(if (cdr words)
|
2003-08-02 20:36:51 +00:00
|
|
|
|
(concat wild
|
|
|
|
|
"\\("
|
2002-05-23 10:20:12 +00:00
|
|
|
|
(mapconcat 'identity words "\\|")
|
|
|
|
|
"\\)")
|
|
|
|
|
"")))
|
|
|
|
|
|
2005-11-12 00:10:40 +00:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun apropos-read-pattern (subject)
|
|
|
|
|
"Read an apropos pattern, either a word list or a regexp.
|
|
|
|
|
Returns the user pattern, either a list of words which are matched
|
|
|
|
|
literally, or a string which is used as a regexp to search for.
|
|
|
|
|
|
|
|
|
|
SUBJECT is a string that is included in the prompt to identify what
|
|
|
|
|
kind of objects to search."
|
|
|
|
|
(let ((pattern
|
2012-04-23 12:37:55 +00:00
|
|
|
|
(read-string (concat "Search for " subject " (word list or regexp): "))))
|
2005-11-12 00:10:40 +00:00
|
|
|
|
(if (string-equal (regexp-quote pattern) pattern)
|
|
|
|
|
;; Split into words
|
2012-04-23 12:44:54 +00:00
|
|
|
|
(split-string pattern "[ \t]+" t)
|
2005-11-12 00:10:40 +00:00
|
|
|
|
pattern)))
|
|
|
|
|
|
|
|
|
|
(defun apropos-parse-pattern (pattern)
|
|
|
|
|
"Rewrite a list of words to a regexp matching all permutations.
|
2005-11-29 23:52:59 +00:00
|
|
|
|
If PATTERN is a string, that means it is already a regexp.
|
|
|
|
|
This updates variables `apropos-pattern', `apropos-pattern-quoted',
|
|
|
|
|
`apropos-regexp', `apropos-words', and `apropos-all-words-regexp'."
|
2005-11-12 00:10:40 +00:00
|
|
|
|
(setq apropos-words nil
|
|
|
|
|
apropos-all-words nil)
|
|
|
|
|
(if (consp pattern)
|
2002-05-23 10:20:12 +00:00
|
|
|
|
;; We don't actually make a regexp matching all permutations.
|
|
|
|
|
;; Instead, for e.g. "a b c", we make a regexp matching
|
|
|
|
|
;; any combination of two or more words like this:
|
|
|
|
|
;; (a|b|c).*(a|b|c) which may give some false matches,
|
|
|
|
|
;; but as long as it also gives the right ones, that's ok.
|
2005-11-12 00:10:40 +00:00
|
|
|
|
(let ((words pattern))
|
|
|
|
|
(setq apropos-pattern (mapconcat 'identity pattern " ")
|
|
|
|
|
apropos-pattern-quoted (regexp-quote apropos-pattern))
|
2002-05-23 10:20:12 +00:00
|
|
|
|
(dolist (word words)
|
|
|
|
|
(let ((syn apropos-synonyms) (s word) (a word))
|
|
|
|
|
(while syn
|
|
|
|
|
(if (member word (car syn))
|
|
|
|
|
(progn
|
|
|
|
|
(setq a (mapconcat 'identity (car syn) "\\|"))
|
|
|
|
|
(if (member word (cdr (car syn)))
|
|
|
|
|
(setq s a))
|
|
|
|
|
(setq syn nil))
|
|
|
|
|
(setq syn (cdr syn))))
|
|
|
|
|
(setq apropos-words (cons s apropos-words)
|
|
|
|
|
apropos-all-words (cons a apropos-all-words))))
|
2005-11-29 23:52:59 +00:00
|
|
|
|
(setq apropos-all-words-regexp
|
|
|
|
|
(apropos-words-to-regexp apropos-all-words ".+"))
|
|
|
|
|
(setq apropos-regexp
|
|
|
|
|
(apropos-words-to-regexp apropos-words ".*?")))
|
2005-11-12 00:10:40 +00:00
|
|
|
|
(setq apropos-pattern-quoted (regexp-quote pattern)
|
|
|
|
|
apropos-all-words-regexp pattern
|
2005-11-29 23:52:59 +00:00
|
|
|
|
apropos-pattern pattern
|
|
|
|
|
apropos-regexp pattern)))
|
2005-11-12 00:10:40 +00:00
|
|
|
|
|
2002-05-23 10:20:12 +00:00
|
|
|
|
|
|
|
|
|
(defun apropos-calc-scores (str words)
|
|
|
|
|
"Return apropos scores for string STR matching WORDS.
|
|
|
|
|
Value is a list of offsets of the words into the string."
|
2005-11-12 00:10:40 +00:00
|
|
|
|
(let (scores i)
|
2002-05-23 10:20:12 +00:00
|
|
|
|
(if words
|
|
|
|
|
(dolist (word words scores)
|
|
|
|
|
(if (setq i (string-match word str))
|
|
|
|
|
(setq scores (cons i scores))))
|
|
|
|
|
;; Return list of start and end position of regexp
|
2005-11-16 22:11:47 +00:00
|
|
|
|
(and (string-match apropos-pattern str)
|
2005-11-12 00:10:40 +00:00
|
|
|
|
(list (match-beginning 0) (match-end 0))))))
|
2002-05-23 10:20:12 +00:00
|
|
|
|
|
|
|
|
|
(defun apropos-score-str (str)
|
|
|
|
|
"Return apropos score for string STR."
|
|
|
|
|
(if str
|
2005-11-12 00:10:40 +00:00
|
|
|
|
(let* ((l (length str))
|
|
|
|
|
(score (- (/ l 10))))
|
2002-05-23 10:20:12 +00:00
|
|
|
|
(dolist (s (apropos-calc-scores str apropos-all-words) score)
|
2002-05-23 10:24:14 +00:00
|
|
|
|
(setq score (+ score 1000 (/ (* (- l s) 1000) l)))))
|
2002-05-23 10:20:12 +00:00
|
|
|
|
0))
|
|
|
|
|
|
|
|
|
|
(defun apropos-score-doc (doc)
|
|
|
|
|
"Return apropos score for documentation string DOC."
|
2005-02-11 16:09:50 +00:00
|
|
|
|
(let ((l (length doc)))
|
|
|
|
|
(if (> l 0)
|
2011-04-19 13:44:55 +00:00
|
|
|
|
(let ((score 0))
|
|
|
|
|
(when (string-match apropos-pattern-quoted doc)
|
2005-11-12 00:10:40 +00:00
|
|
|
|
(setq score 10000))
|
2005-02-11 16:09:50 +00:00
|
|
|
|
(dolist (s (apropos-calc-scores doc apropos-all-words) score)
|
|
|
|
|
(setq score (+ score 50 (/ (* (- l s) 50) l)))))
|
|
|
|
|
0)))
|
2003-02-04 11:26:42 +00:00
|
|
|
|
|
2002-05-23 10:20:12 +00:00
|
|
|
|
(defun apropos-score-symbol (symbol &optional weight)
|
|
|
|
|
"Return apropos score for SYMBOL."
|
|
|
|
|
(setq symbol (symbol-name symbol))
|
|
|
|
|
(let ((score 0)
|
2005-11-12 00:10:40 +00:00
|
|
|
|
(l (length symbol)))
|
2002-05-23 10:20:12 +00:00
|
|
|
|
(dolist (s (apropos-calc-scores symbol apropos-words) (* score (or weight 3)))
|
|
|
|
|
(setq score (+ score (- 60 l) (/ (* (- l s) 60) l))))))
|
|
|
|
|
|
2002-05-23 20:21:30 +00:00
|
|
|
|
(defun apropos-true-hit (str words)
|
|
|
|
|
"Return t if STR is a genuine hit.
|
|
|
|
|
This may fail if only one of the keywords is matched more than once.
|
|
|
|
|
This requires that at least 2 keywords (unless only one was given)."
|
|
|
|
|
(or (not str)
|
|
|
|
|
(not words)
|
|
|
|
|
(not (cdr words))
|
|
|
|
|
(> (length (apropos-calc-scores str words)) 1)))
|
|
|
|
|
|
|
|
|
|
(defun apropos-false-hit-symbol (symbol)
|
|
|
|
|
"Return t if SYMBOL is not really matched by the current keywords."
|
|
|
|
|
(not (apropos-true-hit (symbol-name symbol) apropos-words)))
|
|
|
|
|
|
|
|
|
|
(defun apropos-false-hit-str (str)
|
|
|
|
|
"Return t if STR is not really matched by the current keywords."
|
|
|
|
|
(not (apropos-true-hit str apropos-words)))
|
|
|
|
|
|
|
|
|
|
(defun apropos-true-hit-doc (doc)
|
|
|
|
|
"Return t if DOC is really matched by the current keywords."
|
|
|
|
|
(apropos-true-hit doc apropos-all-words))
|
|
|
|
|
|
2011-02-01 21:22:21 +00:00
|
|
|
|
(define-derived-mode apropos-mode special-mode "Apropos"
|
1995-12-19 22:01:53 +00:00
|
|
|
|
"Major mode for following hyperlinks in output of apropos commands.
|
|
|
|
|
|
2000-10-04 23:30:51 +00:00
|
|
|
|
\\{apropos-mode-map}")
|
1995-12-19 22:01:53 +00:00
|
|
|
|
|
2008-06-10 02:44:48 +00:00
|
|
|
|
(defvar apropos-multi-type t
|
|
|
|
|
"If non-nil, this apropos query concerns multiple types.
|
|
|
|
|
This is used to decide whether to print the result's type or not.")
|
|
|
|
|
|
1997-11-24 04:55:48 +00:00
|
|
|
|
;;;###autoload
|
2005-11-12 00:10:40 +00:00
|
|
|
|
(defun apropos-variable (pattern &optional do-all)
|
|
|
|
|
"Show user variables that match PATTERN.
|
|
|
|
|
PATTERN can be a word, a list of words (separated by spaces),
|
|
|
|
|
or a regexp (using some regexp special characters). If it is a word,
|
|
|
|
|
search for matches for that word as a substring. If it is a list of words,
|
|
|
|
|
search for matches for any two (or more) of those words.
|
|
|
|
|
|
|
|
|
|
With \\[universal-argument] prefix, or if `apropos-do-all' is non-nil, also show
|
1998-05-24 23:11:14 +00:00
|
|
|
|
normal variables."
|
2005-11-12 00:10:40 +00:00
|
|
|
|
(interactive (list (apropos-read-pattern
|
|
|
|
|
(if (or current-prefix-arg apropos-do-all)
|
|
|
|
|
"variable" "user option"))
|
1998-05-24 23:11:14 +00:00
|
|
|
|
current-prefix-arg))
|
2005-11-12 00:10:40 +00:00
|
|
|
|
(apropos-command pattern nil
|
1998-06-01 21:46:44 +00:00
|
|
|
|
(if (or do-all apropos-do-all)
|
1998-05-24 23:11:14 +00:00
|
|
|
|
#'(lambda (symbol)
|
|
|
|
|
(and (boundp symbol)
|
|
|
|
|
(get symbol 'variable-documentation)))
|
2012-04-09 12:36:01 +00:00
|
|
|
|
'custom-variable-p)))
|
1995-12-19 22:01:53 +00:00
|
|
|
|
|
1995-07-22 15:17:54 +00:00
|
|
|
|
;; For auld lang syne:
|
|
|
|
|
;;;###autoload
|
2002-08-24 14:26:06 +00:00
|
|
|
|
(defalias 'command-apropos 'apropos-command)
|
1991-07-31 02:49:11 +00:00
|
|
|
|
;;;###autoload
|
2005-11-12 00:10:40 +00:00
|
|
|
|
(defun apropos-command (pattern &optional do-all var-predicate)
|
|
|
|
|
"Show commands (interactively callable functions) that match PATTERN.
|
|
|
|
|
PATTERN can be a word, a list of words (separated by spaces),
|
2005-11-10 03:18:51 +00:00
|
|
|
|
or a regexp (using some regexp special characters). If it is a word,
|
|
|
|
|
search for matches for that word as a substring. If it is a list of words,
|
|
|
|
|
search for matches for any two (or more) of those words.
|
|
|
|
|
|
2005-11-12 00:10:40 +00:00
|
|
|
|
With \\[universal-argument] prefix, or if `apropos-do-all' is non-nil, also show
|
1998-05-24 23:19:37 +00:00
|
|
|
|
noninteractive functions.
|
1998-05-24 23:11:14 +00:00
|
|
|
|
|
1998-05-24 23:19:37 +00:00
|
|
|
|
If VAR-PREDICATE is non-nil, show only variables, and only those that
|
2005-11-12 00:10:40 +00:00
|
|
|
|
satisfy the predicate VAR-PREDICATE.
|
|
|
|
|
|
|
|
|
|
When called from a Lisp program, a string PATTERN is used as a regexp,
|
|
|
|
|
while a list of strings is used as a word list."
|
|
|
|
|
(interactive (list (apropos-read-pattern
|
|
|
|
|
(if (or current-prefix-arg apropos-do-all)
|
|
|
|
|
"command or function" "command"))
|
1995-07-22 15:17:54 +00:00
|
|
|
|
current-prefix-arg))
|
2005-11-29 23:52:59 +00:00
|
|
|
|
(apropos-parse-pattern pattern)
|
2007-12-06 03:59:38 +00:00
|
|
|
|
(let ((message
|
1995-12-19 22:01:53 +00:00
|
|
|
|
(let ((standard-output (get-buffer-create "*Apropos*")))
|
2009-08-21 07:24:26 +00:00
|
|
|
|
(help-print-return-message 'identity))))
|
1995-07-22 15:17:54 +00:00
|
|
|
|
(or do-all (setq do-all apropos-do-all))
|
|
|
|
|
(setq apropos-accumulator
|
2005-11-12 00:10:40 +00:00
|
|
|
|
(apropos-internal apropos-regexp
|
1998-06-01 21:46:44 +00:00
|
|
|
|
(or var-predicate
|
2008-03-26 03:31:42 +00:00
|
|
|
|
;; We used to use `functionp' here, but this
|
|
|
|
|
;; rules out macros. `fboundp' rules in
|
|
|
|
|
;; keymaps, but it seems harmless.
|
|
|
|
|
(if do-all 'fboundp 'commandp))))
|
1997-12-21 01:46:14 +00:00
|
|
|
|
(let ((tem apropos-accumulator))
|
|
|
|
|
(while tem
|
2002-05-23 20:21:30 +00:00
|
|
|
|
(if (or (get (car tem) 'apropos-inhibit)
|
|
|
|
|
(apropos-false-hit-symbol (car tem)))
|
1997-12-21 01:46:14 +00:00
|
|
|
|
(setq apropos-accumulator (delq (car tem) apropos-accumulator)))
|
|
|
|
|
(setq tem (cdr tem))))
|
1998-06-20 22:27:06 +00:00
|
|
|
|
(let ((p apropos-accumulator)
|
2002-05-23 10:20:12 +00:00
|
|
|
|
doc symbol score)
|
1998-06-20 22:27:06 +00:00
|
|
|
|
(while p
|
|
|
|
|
(setcar p (list
|
|
|
|
|
(setq symbol (car p))
|
2002-05-23 10:20:12 +00:00
|
|
|
|
(setq score (apropos-score-symbol symbol))
|
1998-06-20 22:27:06 +00:00
|
|
|
|
(unless var-predicate
|
2008-03-26 03:31:42 +00:00
|
|
|
|
(if (fboundp symbol)
|
2008-08-30 20:14:11 +00:00
|
|
|
|
(if (setq doc (condition-case nil
|
|
|
|
|
(documentation symbol t)
|
|
|
|
|
(error 'error)))
|
|
|
|
|
;; Eg alias to undefined function.
|
|
|
|
|
(if (eq doc 'error)
|
|
|
|
|
"(documentation error)"
|
2003-02-04 11:26:42 +00:00
|
|
|
|
(setq score (+ score (apropos-score-doc doc)))
|
2002-05-23 10:20:12 +00:00
|
|
|
|
(substring doc 0 (string-match "\n" doc)))
|
1998-06-20 22:27:06 +00:00
|
|
|
|
"(not documented)")))
|
|
|
|
|
(and var-predicate
|
|
|
|
|
(funcall var-predicate symbol)
|
|
|
|
|
(if (setq doc (documentation-property
|
|
|
|
|
symbol 'variable-documentation t))
|
2002-05-23 10:20:12 +00:00
|
|
|
|
(progn
|
|
|
|
|
(setq score (+ score (apropos-score-doc doc)))
|
|
|
|
|
(substring doc 0
|
|
|
|
|
(string-match "\n" doc)))))))
|
|
|
|
|
(setcar (cdr (car p)) score)
|
1998-06-20 22:27:06 +00:00
|
|
|
|
(setq p (cdr p))))
|
2008-06-10 02:44:48 +00:00
|
|
|
|
(and (let ((apropos-multi-type do-all))
|
|
|
|
|
(apropos-print t nil nil t))
|
1998-06-20 22:27:06 +00:00
|
|
|
|
message
|
2005-09-18 12:25:02 +00:00
|
|
|
|
(message "%s" message))))
|
1995-07-07 18:53:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;###autoload
|
2003-01-13 08:07:18 +00:00
|
|
|
|
(defun apropos-documentation-property (symbol property raw)
|
|
|
|
|
"Like (documentation-property SYMBOL PROPERTY RAW) but handle errors."
|
|
|
|
|
(condition-case ()
|
|
|
|
|
(let ((doc (documentation-property symbol property raw)))
|
|
|
|
|
(if doc (substring doc 0 (string-match "\n" doc))
|
|
|
|
|
"(not documented)"))
|
|
|
|
|
(error "(error retrieving documentation)")))
|
|
|
|
|
|
2003-01-14 20:47:21 +00:00
|
|
|
|
|
|
|
|
|
;;;###autoload
|
2005-11-12 00:10:40 +00:00
|
|
|
|
(defun apropos (pattern &optional do-all)
|
2005-12-26 21:21:04 +00:00
|
|
|
|
"Show all meaningful Lisp symbols whose names match PATTERN.
|
|
|
|
|
Symbols are shown if they are defined as functions, variables, or
|
|
|
|
|
faces, or if they have nonempty property lists.
|
|
|
|
|
|
2005-11-12 00:10:40 +00:00
|
|
|
|
PATTERN can be a word, a list of words (separated by spaces),
|
2005-11-10 03:18:51 +00:00
|
|
|
|
or a regexp (using some regexp special characters). If it is a word,
|
|
|
|
|
search for matches for that word as a substring. If it is a list of words,
|
|
|
|
|
search for matches for any two (or more) of those words.
|
|
|
|
|
|
2005-12-26 21:22:55 +00:00
|
|
|
|
With \\[universal-argument] prefix, or if `apropos-do-all' is non-nil,
|
|
|
|
|
consider all symbols (if they match PATTERN).
|
|
|
|
|
|
|
|
|
|
Returns list of symbols and documentation found."
|
2005-11-12 00:10:40 +00:00
|
|
|
|
(interactive (list (apropos-read-pattern "symbol")
|
|
|
|
|
current-prefix-arg))
|
2005-11-29 23:52:59 +00:00
|
|
|
|
(apropos-parse-pattern pattern)
|
2004-03-26 15:27:56 +00:00
|
|
|
|
(apropos-symbols-internal
|
2005-11-12 00:10:40 +00:00
|
|
|
|
(apropos-internal apropos-regexp
|
2005-12-26 21:22:55 +00:00
|
|
|
|
(and (not do-all)
|
|
|
|
|
(not apropos-do-all)
|
|
|
|
|
(lambda (symbol)
|
|
|
|
|
(or (fboundp symbol)
|
|
|
|
|
(boundp symbol)
|
|
|
|
|
(facep symbol)
|
|
|
|
|
(symbol-plist symbol)))))
|
2004-03-26 15:27:56 +00:00
|
|
|
|
(or do-all apropos-do-all)))
|
|
|
|
|
|
2008-06-08 04:32:43 +00:00
|
|
|
|
(defun apropos-library-button (sym)
|
|
|
|
|
(if (null sym)
|
|
|
|
|
"<nothing>"
|
|
|
|
|
(let ((name (copy-sequence (symbol-name sym))))
|
|
|
|
|
(make-text-button name nil
|
|
|
|
|
'type 'apropos-library
|
Use proper faces in apropos.el.
* lisp/apropos.el (apropos-symbol, apropos-keybinding, apropos-label)
(apropos-property, apropos-function-button)
(apropos-variable-button, apropos-misc-button): New faces.
(apropos-symbol-face, apropos-keybinding-face)
(apropos-label-face, apropos-property-face, apropos-match-face):
Variables removed.
(apropos-library-button, apropos-format-plist, apropos-print)
(apropos-print-doc, apropos-describe-plist): Callers changed.
Fixes: debbugs:8396
2012-04-23 15:38:48 +00:00
|
|
|
|
'face 'apropos-symbol
|
2008-06-08 04:32:43 +00:00
|
|
|
|
'apropos-symbol name)
|
|
|
|
|
name)))
|
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun apropos-library (file)
|
|
|
|
|
"List the variables and functions defined by library FILE.
|
|
|
|
|
FILE should be one of the libraries currently loaded and should
|
2011-11-12 02:13:23 +00:00
|
|
|
|
thus be found in `load-history'. If `apropos-do-all' is non-nil,
|
|
|
|
|
the output includes key-bindings of commands."
|
2008-06-08 04:32:43 +00:00
|
|
|
|
(interactive
|
2009-02-20 06:03:45 +00:00
|
|
|
|
(let* ((libs (delq nil (mapcar 'car load-history)))
|
|
|
|
|
(libs
|
|
|
|
|
(nconc (delq nil
|
|
|
|
|
(mapcar
|
|
|
|
|
(lambda (l)
|
|
|
|
|
(setq l (file-name-nondirectory l))
|
|
|
|
|
(while
|
|
|
|
|
(not (equal (setq l (file-name-sans-extension l))
|
|
|
|
|
l)))
|
|
|
|
|
l)
|
|
|
|
|
libs))
|
|
|
|
|
libs)))
|
2008-06-08 04:32:43 +00:00
|
|
|
|
(list (completing-read "Describe library: " libs nil t))))
|
|
|
|
|
(let ((symbols nil)
|
|
|
|
|
;; (autoloads nil)
|
|
|
|
|
(provides nil)
|
|
|
|
|
(requires nil)
|
|
|
|
|
(lh-entry (assoc file load-history)))
|
|
|
|
|
(unless lh-entry
|
|
|
|
|
;; `file' may be the "shortname".
|
|
|
|
|
(let ((lh load-history)
|
|
|
|
|
(re (concat "\\(?:\\`\\|[\\/]\\)" (regexp-quote file)
|
|
|
|
|
"\\(\\.\\|\\'\\)")))
|
|
|
|
|
(while (and lh (null lh-entry))
|
2009-02-20 06:06:18 +00:00
|
|
|
|
(if (and (caar lh) (string-match re (caar lh)))
|
2008-06-08 04:32:43 +00:00
|
|
|
|
(setq lh-entry (car lh))
|
|
|
|
|
(setq lh (cdr lh)))))
|
|
|
|
|
(unless lh-entry (error "Unknown library `%s'" file)))
|
|
|
|
|
(dolist (x (cdr lh-entry))
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
|
(pcase (car-safe x)
|
2008-06-08 04:32:43 +00:00
|
|
|
|
;; (autoload (push (cdr x) autoloads))
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
|
(`require (push (cdr x) requires))
|
|
|
|
|
(`provide (push (cdr x) provides))
|
|
|
|
|
(_ (push (or (cdr-safe x) x) symbols))))
|
2008-06-08 04:32:43 +00:00
|
|
|
|
(let ((apropos-pattern "")) ;Dummy binding for apropos-symbols-internal.
|
|
|
|
|
(apropos-symbols-internal
|
|
|
|
|
symbols apropos-do-all
|
|
|
|
|
(concat
|
|
|
|
|
(format "Library `%s' provides: %s\nand requires: %s"
|
|
|
|
|
file
|
|
|
|
|
(mapconcat 'apropos-library-button
|
|
|
|
|
(or provides '(nil)) " and ")
|
|
|
|
|
(mapconcat 'apropos-library-button
|
|
|
|
|
(or requires '(nil)) " and ")))))))
|
|
|
|
|
|
2004-03-26 15:27:56 +00:00
|
|
|
|
(defun apropos-symbols-internal (symbols keys &optional text)
|
|
|
|
|
;; Filter out entries that are marked as apropos-inhibit.
|
|
|
|
|
(let ((all nil))
|
|
|
|
|
(dolist (symbol symbols)
|
|
|
|
|
(unless (get symbol 'apropos-inhibit)
|
|
|
|
|
(push symbol all)))
|
|
|
|
|
(setq symbols all))
|
|
|
|
|
(let ((apropos-accumulator
|
|
|
|
|
(mapcar
|
|
|
|
|
(lambda (symbol)
|
|
|
|
|
(let (doc properties)
|
|
|
|
|
(list
|
|
|
|
|
symbol
|
|
|
|
|
(apropos-score-symbol symbol)
|
|
|
|
|
(when (fboundp symbol)
|
|
|
|
|
(if (setq doc (condition-case nil
|
|
|
|
|
(documentation symbol t)
|
|
|
|
|
(void-function
|
|
|
|
|
"(alias for undefined function)")
|
|
|
|
|
(error
|
|
|
|
|
"(can't retrieve function documentation)")))
|
|
|
|
|
(substring doc 0 (string-match "\n" doc))
|
|
|
|
|
"(not documented)"))
|
|
|
|
|
(when (boundp symbol)
|
|
|
|
|
(apropos-documentation-property
|
2011-04-24 00:15:26 +00:00
|
|
|
|
symbol 'variable-documentation t))
|
|
|
|
|
(when (setq properties (symbol-plist symbol))
|
|
|
|
|
(setq doc (list (car properties)))
|
|
|
|
|
(while (setq properties (cdr (cdr properties)))
|
|
|
|
|
(setq doc (cons (car properties) doc)))
|
|
|
|
|
(mapconcat #'symbol-name (nreverse doc) " "))
|
|
|
|
|
(when (get symbol 'widget-type)
|
|
|
|
|
(apropos-documentation-property
|
|
|
|
|
symbol 'widget-documentation t))
|
2004-03-26 15:27:56 +00:00
|
|
|
|
(when (facep symbol)
|
2009-08-31 01:33:11 +00:00
|
|
|
|
(let ((alias (get symbol 'face-alias)))
|
|
|
|
|
(if alias
|
|
|
|
|
(if (facep alias)
|
|
|
|
|
(format "%slias for the face `%s'."
|
|
|
|
|
(if (get symbol 'obsolete-face)
|
|
|
|
|
"Obsolete a"
|
|
|
|
|
"A")
|
|
|
|
|
alias)
|
|
|
|
|
;; Never happens in practice because fails
|
|
|
|
|
;; (facep symbol) test.
|
|
|
|
|
"(alias for undefined face)")
|
|
|
|
|
(apropos-documentation-property
|
|
|
|
|
symbol 'face-documentation t))))
|
2004-03-26 15:27:56 +00:00
|
|
|
|
(when (get symbol 'custom-group)
|
2011-04-24 00:15:26 +00:00
|
|
|
|
(apropos-documentation-property
|
|
|
|
|
symbol 'group-documentation t)))))
|
2004-03-26 15:27:56 +00:00
|
|
|
|
symbols)))
|
|
|
|
|
(apropos-print keys nil text)))
|
1995-07-07 18:53:58 +00:00
|
|
|
|
|
|
|
|
|
|
1991-07-31 02:49:11 +00:00
|
|
|
|
;;;###autoload
|
2005-11-12 00:10:40 +00:00
|
|
|
|
(defun apropos-value (pattern &optional do-all)
|
2005-12-26 21:21:04 +00:00
|
|
|
|
"Show all symbols whose value's printed representation matches PATTERN.
|
2005-11-12 00:10:40 +00:00
|
|
|
|
PATTERN can be a word, a list of words (separated by spaces),
|
2005-11-10 03:18:51 +00:00
|
|
|
|
or a regexp (using some regexp special characters). If it is a word,
|
|
|
|
|
search for matches for that word as a substring. If it is a list of words,
|
|
|
|
|
search for matches for any two (or more) of those words.
|
|
|
|
|
|
2005-11-12 00:10:40 +00:00
|
|
|
|
With \\[universal-argument] prefix, or if `apropos-do-all' is non-nil, also looks
|
2011-11-12 02:13:23 +00:00
|
|
|
|
at function definitions (arguments, documentation and body) and at the
|
|
|
|
|
names and values of properties.
|
|
|
|
|
|
1995-07-22 15:17:54 +00:00
|
|
|
|
Returns list of symbols and values found."
|
2005-11-12 00:10:40 +00:00
|
|
|
|
(interactive (list (apropos-read-pattern "value")
|
|
|
|
|
current-prefix-arg))
|
2005-11-29 23:52:59 +00:00
|
|
|
|
(apropos-parse-pattern pattern)
|
1995-07-22 15:17:54 +00:00
|
|
|
|
(or do-all (setq do-all apropos-do-all))
|
|
|
|
|
(setq apropos-accumulator ())
|
|
|
|
|
(let (f v p)
|
1995-07-07 18:53:58 +00:00
|
|
|
|
(mapatoms
|
|
|
|
|
(lambda (symbol)
|
|
|
|
|
(setq f nil v nil p nil)
|
2005-11-12 00:10:40 +00:00
|
|
|
|
(or (memq symbol '(apropos-regexp
|
|
|
|
|
apropos-pattern apropos-all-words-regexp
|
2002-05-23 10:20:12 +00:00
|
|
|
|
apropos-words apropos-all-words
|
|
|
|
|
do-all apropos-accumulator
|
|
|
|
|
symbol f v p))
|
1995-07-22 15:17:54 +00:00
|
|
|
|
(setq v (apropos-value-internal 'boundp symbol 'symbol-value)))
|
1995-07-07 18:53:58 +00:00
|
|
|
|
(if do-all
|
1995-07-22 15:17:54 +00:00
|
|
|
|
(setq f (apropos-value-internal 'fboundp symbol 'symbol-function)
|
|
|
|
|
p (apropos-format-plist symbol "\n " t)))
|
2002-05-23 20:21:30 +00:00
|
|
|
|
(if (apropos-false-hit-str v)
|
|
|
|
|
(setq v nil))
|
|
|
|
|
(if (apropos-false-hit-str f)
|
|
|
|
|
(setq f nil))
|
|
|
|
|
(if (apropos-false-hit-str p)
|
|
|
|
|
(setq p nil))
|
1995-07-07 18:53:58 +00:00
|
|
|
|
(if (or f v p)
|
2003-02-04 11:26:42 +00:00
|
|
|
|
(setq apropos-accumulator (cons (list symbol
|
2002-05-23 10:20:12 +00:00
|
|
|
|
(+ (apropos-score-str f)
|
|
|
|
|
(apropos-score-str v)
|
|
|
|
|
(apropos-score-str p))
|
|
|
|
|
f v p)
|
1995-07-22 15:17:54 +00:00
|
|
|
|
apropos-accumulator))))))
|
2008-06-10 02:44:48 +00:00
|
|
|
|
(let ((apropos-multi-type do-all))
|
|
|
|
|
(apropos-print nil "\n----------------\n")))
|
1995-07-07 18:53:58 +00:00
|
|
|
|
|
|
|
|
|
|
1995-07-22 15:17:54 +00:00
|
|
|
|
;;;###autoload
|
2005-11-12 00:10:40 +00:00
|
|
|
|
(defun apropos-documentation (pattern &optional do-all)
|
2005-12-26 21:21:04 +00:00
|
|
|
|
"Show symbols whose documentation contains matches for PATTERN.
|
2005-11-12 00:10:40 +00:00
|
|
|
|
PATTERN can be a word, a list of words (separated by spaces),
|
2005-11-10 03:18:51 +00:00
|
|
|
|
or a regexp (using some regexp special characters). If it is a word,
|
|
|
|
|
search for matches for that word as a substring. If it is a list of words,
|
|
|
|
|
search for matches for any two (or more) of those words.
|
|
|
|
|
|
2011-11-12 02:13:23 +00:00
|
|
|
|
Note that by default this command only searches in the file specified by
|
|
|
|
|
`internal-doc-file-name'; i.e., the etc/DOC file. With \\[universal-argument] prefix,
|
|
|
|
|
or if `apropos-do-all' is non-nil, it searches all currently defined
|
|
|
|
|
documentation strings.
|
|
|
|
|
|
1995-07-22 15:17:54 +00:00
|
|
|
|
Returns list of symbols and documentation found."
|
2011-11-12 02:13:23 +00:00
|
|
|
|
;; The doc used to say that DO-ALL includes key-bindings info in the
|
|
|
|
|
;; output, but I cannot see that that is true.
|
2005-11-12 00:10:40 +00:00
|
|
|
|
(interactive (list (apropos-read-pattern "documentation")
|
|
|
|
|
current-prefix-arg))
|
2005-11-29 23:52:59 +00:00
|
|
|
|
(apropos-parse-pattern pattern)
|
1995-07-22 15:17:54 +00:00
|
|
|
|
(or do-all (setq do-all apropos-do-all))
|
|
|
|
|
(setq apropos-accumulator () apropos-files-scanned ())
|
|
|
|
|
(let ((standard-input (get-buffer-create " apropos-temp"))
|
2005-11-12 00:10:40 +00:00
|
|
|
|
(apropos-sort-by-scores apropos-documentation-sort-by-scores)
|
2002-05-23 10:20:12 +00:00
|
|
|
|
f v sf sv)
|
1995-07-22 15:17:54 +00:00
|
|
|
|
(unwind-protect
|
* x-dnd.el (x-dnd-maybe-call-test-function):
* window.el (split-window-vertically):
* whitespace.el (whitespace-help-on):
* vc-rcs.el (vc-rcs-consult-headers):
* userlock.el (ask-user-about-lock-help)
(ask-user-about-supersession-help):
* type-break.el (type-break-force-mode-line-update):
* time-stamp.el (time-stamp-conv-warn):
* terminal.el (te-set-output-log, te-more-break, te-filter)
(te-sentinel,terminal-emulator):
* term.el (make-term, term-exec, term-sentinel, term-read-input-ring)
(term-write-input-ring, term-check-source, term-start-output-log):
(term-display-buffer-line, term-dynamic-list-completions):
(term-ansi-make-term, serial-term):
* subr.el (selective-display):
* strokes.el (strokes-xpm-to-compressed-string, strokes-decode-buffer)
(strokes-encode-buffer, strokes-xpm-for-compressed-string):
* speedbar.el (speedbar-buffers-tail-notes, speedbar-buffers-item-info)
(speedbar-reconfigure-keymaps, speedbar-add-localized-speedbar-support)
(speedbar-remove-localized-speedbar-support)
(speedbar-set-mode-line-format, speedbar-create-tag-hierarchy)
(speedbar-update-special-contents, speedbar-buffer-buttons-engine)
(speedbar-buffers-line-directory):
* simple.el (shell-command-on-region, append-to-buffer)
(prepend-to-buffer):
* shadowfile.el (shadow-save-todo-file):
* scroll-bar.el (scroll-bar-set-window-start, scroll-bar-drag-1)
(scroll-bar-maybe-set-window-start):
* sb-image.el (speedbar-image-dump):
* saveplace.el (save-place-alist-to-file, save-places-to-alist)
(load-save-place-alist-from-file):
* ps-samp.el (ps-print-message-from-summary):
* ps-print.el (ps-flush-output, ps-insert-file, ps-get-boundingbox)
(ps-background-image, ps-begin-job, ps-do-despool):
* ps-bdf.el (bdf-find-file, bdf-read-font-info):
* printing.el (pr-interface, pr-ps-file-print, pr-find-buffer-visiting)
(pr-ps-message-from-summary, pr-lpr-message-from-summary):
(pr-call-process, pr-file-list, pr-interface-save):
* novice.el (disabled-command-function)
(enable-command, disable-command):
* mouse.el (mouse-buffer-menu-alist):
* mouse-copy.el (mouse-kill-preserving-secondary):
* macros.el (kbd-macro-query):
* ledit.el (ledit-go-to-lisp, ledit-go-to-liszt):
* informat.el (batch-info-validate):
* ido.el (ido-copy-current-word, ido-initiate-auto-merge):
* hippie-exp.el (try-expand-dabbrev-visible):
* help-mode.el (help-make-xrefs):
* help-fns.el (describe-variable):
* generic-x.el (bat-generic-mode-run-as-comint):
* finder.el (finder-mouse-select):
* find-dired.el (find-dired-sentinel):
* filesets.el (filesets-file-close):
* files.el (list-directory):
* faces.el (list-faces-display, describe-face):
* facemenu.el (list-colors-display):
* ezimage.el (ezimage-image-association-dump, ezimage-image-dump):
* epg.el (epg--process-filter, epg-cancel):
* epa.el (epa--marked-keys, epa--select-keys, epa-display-info)
(epa--read-signature-type):
* emerge.el (emerge-copy-as-kill-A, emerge-copy-as-kill-B)
(emerge-file-names):
* ehelp.el (electric-helpify):
* ediff.el (ediff-regions-wordwise, ediff-regions-linewise):
* ediff-vers.el (rcs-ediff-view-revision):
* ediff-util.el (ediff-setup):
* ediff-mult.el (ediff-append-custom-diff):
* ediff-diff.el (ediff-exec-process, ediff-process-sentinel)
(ediff-wordify):
* echistory.el (Electric-command-history-redo-expression):
* dos-w32.el (find-file-not-found-set-buffer-file-coding-system):
* disp-table.el (describe-display-table):
* dired.el (dired-find-buffer-nocreate):
* dired-aux.el (dired-rename-subdir, dired-dwim-target-directory):
* dabbrev.el (dabbrev--same-major-mode-p):
* chistory.el (list-command-history):
* apropos.el (apropos-documentation):
* allout.el (allout-obtain-passphrase):
(allout-copy-exposed-to-buffer):
(allout-verify-passphrase): Use with-current-buffer.
2009-11-13 22:19:45 +00:00
|
|
|
|
(with-current-buffer standard-input
|
1995-07-22 15:17:54 +00:00
|
|
|
|
(apropos-documentation-check-doc-file)
|
|
|
|
|
(if do-all
|
|
|
|
|
(mapatoms
|
|
|
|
|
(lambda (symbol)
|
|
|
|
|
(setq f (apropos-safe-documentation symbol)
|
1995-12-19 22:01:53 +00:00
|
|
|
|
v (get symbol 'variable-documentation))
|
|
|
|
|
(if (integerp v) (setq v))
|
|
|
|
|
(setq f (apropos-documentation-internal f)
|
|
|
|
|
v (apropos-documentation-internal v))
|
2002-05-23 10:20:12 +00:00
|
|
|
|
(setq sf (apropos-score-doc f)
|
|
|
|
|
sv (apropos-score-doc v))
|
1995-07-22 15:17:54 +00:00
|
|
|
|
(if (or f v)
|
|
|
|
|
(if (setq apropos-item
|
|
|
|
|
(cdr (assq symbol apropos-accumulator)))
|
|
|
|
|
(progn
|
|
|
|
|
(if f
|
2002-05-23 10:20:12 +00:00
|
|
|
|
(progn
|
|
|
|
|
(setcar (nthcdr 1 apropos-item) f)
|
|
|
|
|
(setcar apropos-item (+ (car apropos-item) sf))))
|
1995-07-22 15:17:54 +00:00
|
|
|
|
(if v
|
2002-05-23 10:20:12 +00:00
|
|
|
|
(progn
|
|
|
|
|
(setcar (nthcdr 2 apropos-item) v)
|
|
|
|
|
(setcar apropos-item (+ (car apropos-item) sv)))))
|
1995-07-22 15:17:54 +00:00
|
|
|
|
(setq apropos-accumulator
|
2003-02-04 11:26:42 +00:00
|
|
|
|
(cons (list symbol
|
2002-05-23 10:20:12 +00:00
|
|
|
|
(+ (apropos-score-symbol symbol 2) sf sv)
|
|
|
|
|
f v)
|
1995-07-22 15:17:54 +00:00
|
|
|
|
apropos-accumulator)))))))
|
2005-11-12 00:10:40 +00:00
|
|
|
|
(apropos-print nil "\n----------------\n" nil t))
|
1995-07-22 15:17:54 +00:00
|
|
|
|
(kill-buffer standard-input))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun apropos-value-internal (predicate symbol function)
|
|
|
|
|
(if (funcall predicate symbol)
|
|
|
|
|
(progn
|
|
|
|
|
(setq symbol (prin1-to-string (funcall function symbol)))
|
2005-11-12 00:10:40 +00:00
|
|
|
|
(if (string-match apropos-regexp symbol)
|
1995-07-22 15:17:54 +00:00
|
|
|
|
(progn
|
|
|
|
|
(if apropos-match-face
|
|
|
|
|
(put-text-property (match-beginning 0) (match-end 0)
|
|
|
|
|
'face apropos-match-face
|
|
|
|
|
symbol))
|
|
|
|
|
symbol)))))
|
|
|
|
|
|
|
|
|
|
(defun apropos-documentation-internal (doc)
|
|
|
|
|
(if (consp doc)
|
|
|
|
|
(apropos-documentation-check-elc-file (car doc))
|
2005-11-12 00:10:40 +00:00
|
|
|
|
(if (and doc
|
|
|
|
|
(string-match apropos-all-words-regexp doc)
|
|
|
|
|
(apropos-true-hit-doc doc))
|
|
|
|
|
(when apropos-match-face
|
|
|
|
|
(setq doc (substitute-command-keys (copy-sequence doc)))
|
|
|
|
|
(if (or (string-match apropos-pattern-quoted doc)
|
|
|
|
|
(string-match apropos-all-words-regexp doc))
|
|
|
|
|
(put-text-property (match-beginning 0)
|
|
|
|
|
(match-end 0)
|
|
|
|
|
'face apropos-match-face doc))
|
|
|
|
|
doc))))
|
1995-07-22 15:17:54 +00:00
|
|
|
|
|
|
|
|
|
(defun apropos-format-plist (pl sep &optional compare)
|
1995-07-07 18:53:58 +00:00
|
|
|
|
(setq pl (symbol-plist pl))
|
|
|
|
|
(let (p p-out)
|
|
|
|
|
(while pl
|
|
|
|
|
(setq p (format "%s %S" (car pl) (nth 1 pl)))
|
2005-11-12 00:10:40 +00:00
|
|
|
|
(if (or (not compare) (string-match apropos-regexp p))
|
Use proper faces in apropos.el.
* lisp/apropos.el (apropos-symbol, apropos-keybinding, apropos-label)
(apropos-property, apropos-function-button)
(apropos-variable-button, apropos-misc-button): New faces.
(apropos-symbol-face, apropos-keybinding-face)
(apropos-label-face, apropos-property-face, apropos-match-face):
Variables removed.
(apropos-library-button, apropos-format-plist, apropos-print)
(apropos-print-doc, apropos-describe-plist): Callers changed.
Fixes: debbugs:8396
2012-04-23 15:38:48 +00:00
|
|
|
|
(put-text-property 0 (length (symbol-name (car pl)))
|
|
|
|
|
'face 'apropos-property p)
|
1995-07-07 18:53:58 +00:00
|
|
|
|
(setq p nil))
|
1995-07-22 15:17:54 +00:00
|
|
|
|
(if p
|
|
|
|
|
(progn
|
|
|
|
|
(and compare apropos-match-face
|
|
|
|
|
(put-text-property (match-beginning 0) (match-end 0)
|
|
|
|
|
'face apropos-match-face
|
|
|
|
|
p))
|
|
|
|
|
(setq p-out (concat p-out (if p-out sep) p))))
|
1995-07-07 18:53:58 +00:00
|
|
|
|
(setq pl (nthcdr 2 pl)))
|
|
|
|
|
p-out))
|
|
|
|
|
|
1991-07-31 02:49:11 +00:00
|
|
|
|
|
2005-11-12 00:10:40 +00:00
|
|
|
|
;; Finds all documentation related to APROPOS-REGEXP in internal-doc-file-name.
|
1995-07-07 18:53:58 +00:00
|
|
|
|
|
1995-07-22 15:17:54 +00:00
|
|
|
|
(defun apropos-documentation-check-doc-file ()
|
2009-09-15 02:37:28 +00:00
|
|
|
|
(let (type symbol (sepa 2) sepb doc)
|
1995-12-19 22:01:53 +00:00
|
|
|
|
(insert ?\^_)
|
|
|
|
|
(backward-char)
|
1995-07-22 15:17:54 +00:00
|
|
|
|
(insert-file-contents (concat doc-directory internal-doc-file-name))
|
1995-12-19 22:01:53 +00:00
|
|
|
|
(forward-char)
|
|
|
|
|
(while (save-excursion
|
|
|
|
|
(setq sepb (search-forward "\^_"))
|
|
|
|
|
(not (eobp)))
|
|
|
|
|
(beginning-of-line 2)
|
|
|
|
|
(if (save-restriction
|
|
|
|
|
(narrow-to-region (point) (1- sepb))
|
2005-11-12 00:10:40 +00:00
|
|
|
|
(re-search-forward apropos-all-words-regexp nil t))
|
1995-12-19 22:01:53 +00:00
|
|
|
|
(progn
|
|
|
|
|
(goto-char (1+ sepa))
|
2002-05-23 20:21:30 +00:00
|
|
|
|
(setq type (if (eq ?F (preceding-char))
|
|
|
|
|
2 ; function documentation
|
|
|
|
|
3) ; variable documentation
|
|
|
|
|
symbol (read)
|
|
|
|
|
doc (buffer-substring (1+ (point)) (1- sepb)))
|
2009-09-11 03:39:04 +00:00
|
|
|
|
(when (and (apropos-true-hit-doc doc)
|
|
|
|
|
;; The DOC file lists all built-in funcs and vars.
|
|
|
|
|
;; If any are not currently bound, they can
|
|
|
|
|
;; only be platform-specific stuff (eg NS) not
|
|
|
|
|
;; in use on the current platform.
|
|
|
|
|
;; So we exclude them.
|
|
|
|
|
(cond ((= 3 type) (boundp symbol))
|
|
|
|
|
((= 2 type) (fboundp symbol))))
|
2002-05-23 20:21:30 +00:00
|
|
|
|
(or (and (setq apropos-item (assq symbol apropos-accumulator))
|
|
|
|
|
(setcar (cdr apropos-item)
|
2005-11-12 00:10:40 +00:00
|
|
|
|
(apropos-score-doc doc)))
|
2003-02-04 11:26:42 +00:00
|
|
|
|
(setq apropos-item (list symbol
|
2002-05-23 20:21:30 +00:00
|
|
|
|
(+ (apropos-score-symbol symbol 2)
|
|
|
|
|
(apropos-score-doc doc))
|
|
|
|
|
nil nil)
|
|
|
|
|
apropos-accumulator (cons apropos-item
|
|
|
|
|
apropos-accumulator)))
|
2005-11-12 00:10:40 +00:00
|
|
|
|
(when apropos-match-face
|
|
|
|
|
(setq doc (substitute-command-keys doc))
|
|
|
|
|
(if (or (string-match apropos-pattern-quoted doc)
|
|
|
|
|
(string-match apropos-all-words-regexp doc))
|
|
|
|
|
(put-text-property (match-beginning 0)
|
|
|
|
|
(match-end 0)
|
|
|
|
|
'face apropos-match-face doc)))
|
2002-05-23 20:21:30 +00:00
|
|
|
|
(setcar (nthcdr type apropos-item) doc))))
|
1995-12-19 22:01:53 +00:00
|
|
|
|
(setq sepa (goto-char sepb)))))
|
1995-07-22 15:17:54 +00:00
|
|
|
|
|
|
|
|
|
(defun apropos-documentation-check-elc-file (file)
|
|
|
|
|
(if (member file apropos-files-scanned)
|
|
|
|
|
nil
|
1995-12-19 22:01:53 +00:00
|
|
|
|
(let (symbol doc beg end this-is-a-variable)
|
1995-07-22 15:17:54 +00:00
|
|
|
|
(setq apropos-files-scanned (cons file apropos-files-scanned))
|
|
|
|
|
(erase-buffer)
|
|
|
|
|
(insert-file-contents file)
|
|
|
|
|
(while (search-forward "\n#@" nil t)
|
|
|
|
|
;; Read the comment length, and advance over it.
|
|
|
|
|
(setq end (read)
|
1995-12-19 22:01:53 +00:00
|
|
|
|
beg (1+ (point))
|
|
|
|
|
end (+ (point) end -1))
|
|
|
|
|
(forward-char)
|
|
|
|
|
(if (save-restriction
|
|
|
|
|
;; match ^ and $ relative to doc string
|
|
|
|
|
(narrow-to-region beg end)
|
2005-11-12 00:10:40 +00:00
|
|
|
|
(re-search-forward apropos-all-words-regexp nil t))
|
1995-07-22 15:17:54 +00:00
|
|
|
|
(progn
|
1995-12-19 22:01:53 +00:00
|
|
|
|
(goto-char (+ end 2))
|
|
|
|
|
(setq doc (buffer-substring beg end)
|
|
|
|
|
end (- (match-end 0) beg)
|
2002-05-23 20:21:30 +00:00
|
|
|
|
beg (- (match-beginning 0) beg))
|
|
|
|
|
(when (apropos-true-hit-doc doc)
|
|
|
|
|
(setq this-is-a-variable (looking-at "(def\\(var\\|const\\) ")
|
|
|
|
|
symbol (progn
|
|
|
|
|
(skip-chars-forward "(a-z")
|
|
|
|
|
(forward-char)
|
|
|
|
|
(read))
|
|
|
|
|
symbol (if (consp symbol)
|
|
|
|
|
(nth 1 symbol)
|
|
|
|
|
symbol))
|
|
|
|
|
(if (if this-is-a-variable
|
|
|
|
|
(get symbol 'variable-documentation)
|
|
|
|
|
(and (fboundp symbol) (apropos-safe-documentation symbol)))
|
|
|
|
|
(progn
|
|
|
|
|
(or (and (setq apropos-item (assq symbol apropos-accumulator))
|
|
|
|
|
(setcar (cdr apropos-item)
|
|
|
|
|
(+ (cadr apropos-item) (apropos-score-doc doc))))
|
|
|
|
|
(setq apropos-item (list symbol
|
|
|
|
|
(+ (apropos-score-symbol symbol 2)
|
|
|
|
|
(apropos-score-doc doc))
|
|
|
|
|
nil nil)
|
|
|
|
|
apropos-accumulator (cons apropos-item
|
|
|
|
|
apropos-accumulator)))
|
2005-11-12 00:10:40 +00:00
|
|
|
|
(when apropos-match-face
|
|
|
|
|
(setq doc (substitute-command-keys doc))
|
|
|
|
|
(if (or (string-match apropos-pattern-quoted doc)
|
|
|
|
|
(string-match apropos-all-words-regexp doc))
|
|
|
|
|
(put-text-property (match-beginning 0)
|
|
|
|
|
(match-end 0)
|
|
|
|
|
'face apropos-match-face doc)))
|
2002-05-23 20:21:30 +00:00
|
|
|
|
(setcar (nthcdr (if this-is-a-variable 3 2)
|
|
|
|
|
apropos-item)
|
|
|
|
|
doc))))))))))
|
1995-07-22 15:17:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun apropos-safe-documentation (function)
|
2000-06-20 09:58:07 +00:00
|
|
|
|
"Like `documentation', except it avoids calling `get_doc_string'.
|
1991-07-31 02:49:11 +00:00
|
|
|
|
Will return nil instead."
|
1995-07-07 18:53:58 +00:00
|
|
|
|
(while (and function (symbolp function))
|
1991-07-31 02:49:11 +00:00
|
|
|
|
(setq function (if (fboundp function)
|
1995-07-07 18:53:58 +00:00
|
|
|
|
(symbol-function function))))
|
1993-06-08 01:32:42 +00:00
|
|
|
|
(if (eq (car-safe function) 'macro)
|
|
|
|
|
(setq function (cdr function)))
|
1995-07-07 18:53:58 +00:00
|
|
|
|
(setq function (if (byte-code-function-p function)
|
1995-07-22 15:17:54 +00:00
|
|
|
|
(if (> (length function) 4)
|
|
|
|
|
(aref function 4))
|
2012-07-26 01:27:33 +00:00
|
|
|
|
(if (autoloadp function)
|
1995-07-22 15:17:54 +00:00
|
|
|
|
(nth 2 function)
|
|
|
|
|
(if (eq (car-safe function) 'lambda)
|
|
|
|
|
(if (stringp (nth 2 function))
|
|
|
|
|
(nth 2 function)
|
|
|
|
|
(if (stringp (nth 3 function))
|
|
|
|
|
(nth 3 function)))))))
|
|
|
|
|
(if (integerp function)
|
|
|
|
|
nil
|
|
|
|
|
function))
|
|
|
|
|
|
2008-06-10 02:44:48 +00:00
|
|
|
|
(defcustom apropos-compact-layout nil
|
|
|
|
|
"If non-nil, use a single line per binding."
|
|
|
|
|
:type 'boolean)
|
1995-07-22 15:17:54 +00:00
|
|
|
|
|
2005-11-12 00:10:40 +00:00
|
|
|
|
(defun apropos-print (do-keys spacing &optional text nosubst)
|
1998-06-20 22:27:06 +00:00
|
|
|
|
"Output result of apropos searching into buffer `*Apropos*'.
|
|
|
|
|
The value of `apropos-accumulator' is the list of items to output.
|
2003-02-04 11:26:42 +00:00
|
|
|
|
Each element should have the format
|
2002-05-23 10:20:12 +00:00
|
|
|
|
(SYMBOL SCORE FN-DOC VAR-DOC [PLIST-DOC WIDGET-DOC FACE-DOC GROUP-DOC]).
|
1998-06-20 22:27:06 +00:00
|
|
|
|
The return value is the list that was in `apropos-accumulator', sorted
|
|
|
|
|
alphabetically by symbol name; but this function also sets
|
2001-12-22 01:36:48 +00:00
|
|
|
|
`apropos-accumulator' to nil before returning.
|
|
|
|
|
|
2004-03-26 15:27:56 +00:00
|
|
|
|
If SPACING is non-nil, it should be a string; separate items with that string.
|
|
|
|
|
If non-nil TEXT is a string that will be printed as a heading."
|
1995-07-22 15:17:54 +00:00
|
|
|
|
(if (null apropos-accumulator)
|
2005-11-12 00:10:40 +00:00
|
|
|
|
(message "No apropos matches for `%s'" apropos-pattern)
|
1995-07-22 15:17:54 +00:00
|
|
|
|
(setq apropos-accumulator
|
2003-07-12 21:57:50 +00:00
|
|
|
|
(sort apropos-accumulator
|
|
|
|
|
(lambda (a b)
|
|
|
|
|
;; Don't sort by score if user can't see the score.
|
|
|
|
|
;; It would be confusing. -- rms.
|
2003-07-14 21:49:02 +00:00
|
|
|
|
(if apropos-sort-by-scores
|
2003-07-12 21:57:50 +00:00
|
|
|
|
(or (> (cadr a) (cadr b))
|
|
|
|
|
(and (= (cadr a) (cadr b))
|
|
|
|
|
(string-lessp (car a) (car b))))
|
|
|
|
|
(string-lessp (car a) (car b))))))
|
1995-11-10 17:08:38 +00:00
|
|
|
|
(with-output-to-temp-buffer "*Apropos*"
|
1995-07-22 15:17:54 +00:00
|
|
|
|
(let ((p apropos-accumulator)
|
1995-07-07 18:53:58 +00:00
|
|
|
|
(old-buffer (current-buffer))
|
2011-02-18 22:52:58 +00:00
|
|
|
|
(inhibit-read-only t)
|
2001-10-07 11:35:09 +00:00
|
|
|
|
symbol item)
|
1995-12-19 22:01:53 +00:00
|
|
|
|
(set-buffer standard-output)
|
2011-02-18 22:52:58 +00:00
|
|
|
|
(apropos-mode)
|
2011-04-24 00:15:26 +00:00
|
|
|
|
(insert (substitute-command-keys "Type \\[apropos-follow] on ")
|
|
|
|
|
(if apropos-multi-type "a type label" "an entry")
|
|
|
|
|
" to view its full documentation.\n\n")
|
2004-03-26 15:27:56 +00:00
|
|
|
|
(if text (insert text "\n\n"))
|
2008-06-08 03:48:22 +00:00
|
|
|
|
(dolist (apropos-item p)
|
2001-12-22 01:36:48 +00:00
|
|
|
|
(when (and spacing (not (bobp)))
|
|
|
|
|
(princ spacing))
|
2008-06-08 03:48:22 +00:00
|
|
|
|
(setq symbol (car apropos-item))
|
2005-11-12 00:10:40 +00:00
|
|
|
|
;; Insert dummy score element for backwards compatibility with 21.x
|
|
|
|
|
;; apropos-item format.
|
|
|
|
|
(if (not (numberp (cadr apropos-item)))
|
|
|
|
|
(setq apropos-item
|
|
|
|
|
(cons (car apropos-item)
|
|
|
|
|
(cons nil (cdr apropos-item)))))
|
2001-10-07 11:35:09 +00:00
|
|
|
|
(insert-text-button (symbol-name symbol)
|
|
|
|
|
'type 'apropos-symbol
|
2008-07-31 22:15:18 +00:00
|
|
|
|
'skip apropos-multi-type
|
Use proper faces in apropos.el.
* lisp/apropos.el (apropos-symbol, apropos-keybinding, apropos-label)
(apropos-property, apropos-function-button)
(apropos-variable-button, apropos-misc-button): New faces.
(apropos-symbol-face, apropos-keybinding-face)
(apropos-label-face, apropos-property-face, apropos-match-face):
Variables removed.
(apropos-library-button, apropos-format-plist, apropos-print)
(apropos-print-doc, apropos-describe-plist): Callers changed.
Fixes: debbugs:8396
2012-04-23 15:38:48 +00:00
|
|
|
|
'face 'apropos-symbol)
|
2005-11-12 00:10:40 +00:00
|
|
|
|
(if (and (eq apropos-sort-by-scores 'verbose)
|
|
|
|
|
(cadr apropos-item))
|
2002-05-23 10:20:12 +00:00
|
|
|
|
(insert " (" (number-to-string (cadr apropos-item)) ") "))
|
1996-01-27 22:45:19 +00:00
|
|
|
|
;; Calculate key-bindings if we want them.
|
2008-06-10 02:44:48 +00:00
|
|
|
|
(unless apropos-compact-layout
|
|
|
|
|
(and do-keys
|
|
|
|
|
(commandp symbol)
|
|
|
|
|
(not (eq symbol 'self-insert-command))
|
|
|
|
|
(indent-to 30 1)
|
|
|
|
|
(if (let ((keys
|
|
|
|
|
(with-current-buffer old-buffer
|
|
|
|
|
(where-is-internal symbol)))
|
|
|
|
|
filtered)
|
|
|
|
|
;; Copy over the list of key sequences,
|
|
|
|
|
;; omitting any that contain a buffer or a frame.
|
|
|
|
|
;; FIXME: Why omit keys that contain buffers and
|
|
|
|
|
;; frames? This looks like a bad workaround rather
|
2011-11-14 23:59:56 +00:00
|
|
|
|
;; than a proper fix. Does anybody know what problem
|
2008-06-10 02:44:48 +00:00
|
|
|
|
;; this is trying to address? --Stef
|
|
|
|
|
(dolist (key keys)
|
|
|
|
|
(let ((i 0)
|
|
|
|
|
loser)
|
|
|
|
|
(while (< i (length key))
|
|
|
|
|
(if (or (framep (aref key i))
|
|
|
|
|
(bufferp (aref key i)))
|
|
|
|
|
(setq loser t))
|
|
|
|
|
(setq i (1+ i)))
|
|
|
|
|
(or loser
|
|
|
|
|
(push key filtered))))
|
|
|
|
|
(setq item filtered))
|
|
|
|
|
;; Convert the remaining keys to a string and insert.
|
|
|
|
|
(insert
|
|
|
|
|
(mapconcat
|
|
|
|
|
(lambda (key)
|
|
|
|
|
(setq key (condition-case ()
|
|
|
|
|
(key-description key)
|
|
|
|
|
(error)))
|
Use proper faces in apropos.el.
* lisp/apropos.el (apropos-symbol, apropos-keybinding, apropos-label)
(apropos-property, apropos-function-button)
(apropos-variable-button, apropos-misc-button): New faces.
(apropos-symbol-face, apropos-keybinding-face)
(apropos-label-face, apropos-property-face, apropos-match-face):
Variables removed.
(apropos-library-button, apropos-format-plist, apropos-print)
(apropos-print-doc, apropos-describe-plist): Callers changed.
Fixes: debbugs:8396
2012-04-23 15:38:48 +00:00
|
|
|
|
(put-text-property 0 (length key)
|
|
|
|
|
'face 'apropos-keybinding
|
|
|
|
|
key)
|
2008-06-10 02:44:48 +00:00
|
|
|
|
key)
|
|
|
|
|
item ", "))
|
|
|
|
|
(insert "M-x ... RET")
|
Use proper faces in apropos.el.
* lisp/apropos.el (apropos-symbol, apropos-keybinding, apropos-label)
(apropos-property, apropos-function-button)
(apropos-variable-button, apropos-misc-button): New faces.
(apropos-symbol-face, apropos-keybinding-face)
(apropos-label-face, apropos-property-face, apropos-match-face):
Variables removed.
(apropos-library-button, apropos-format-plist, apropos-print)
(apropos-print-doc, apropos-describe-plist): Callers changed.
Fixes: debbugs:8396
2012-04-23 15:38:48 +00:00
|
|
|
|
(put-text-property (- (point) 11) (- (point) 8)
|
|
|
|
|
'face 'apropos-keybinding)
|
|
|
|
|
(put-text-property (- (point) 3) (point)
|
|
|
|
|
'face 'apropos-keybinding)))
|
2008-06-10 02:44:48 +00:00
|
|
|
|
(terpri))
|
2002-05-23 10:20:12 +00:00
|
|
|
|
(apropos-print-doc 2
|
1995-12-19 22:01:53 +00:00
|
|
|
|
(if (commandp symbol)
|
2001-10-08 06:58:32 +00:00
|
|
|
|
'apropos-command
|
1995-12-19 22:01:53 +00:00
|
|
|
|
(if (apropos-macrop symbol)
|
2001-10-08 06:58:32 +00:00
|
|
|
|
'apropos-macro
|
|
|
|
|
'apropos-function))
|
2005-11-12 00:10:40 +00:00
|
|
|
|
(not nosubst))
|
|
|
|
|
(apropos-print-doc 3 'apropos-variable (not nosubst))
|
2002-05-23 10:20:12 +00:00
|
|
|
|
(apropos-print-doc 7 'apropos-group t)
|
|
|
|
|
(apropos-print-doc 6 'apropos-face t)
|
|
|
|
|
(apropos-print-doc 5 'apropos-widget t)
|
|
|
|
|
(apropos-print-doc 4 'apropos-plist nil))
|
2008-06-10 02:44:48 +00:00
|
|
|
|
(set (make-local-variable 'truncate-partial-width-windows) t)
|
2011-02-18 22:52:58 +00:00
|
|
|
|
(set (make-local-variable 'truncate-lines) t))))
|
1995-07-22 15:17:54 +00:00
|
|
|
|
(prog1 apropos-accumulator
|
|
|
|
|
(setq apropos-accumulator ()))) ; permit gc
|
|
|
|
|
|
|
|
|
|
(defun apropos-macrop (symbol)
|
2004-10-27 17:46:33 +00:00
|
|
|
|
"Return t if SYMBOL is a Lisp macro."
|
1995-07-22 15:17:54 +00:00
|
|
|
|
(and (fboundp symbol)
|
|
|
|
|
(consp (setq symbol
|
|
|
|
|
(symbol-function symbol)))
|
|
|
|
|
(or (eq (car symbol) 'macro)
|
2012-07-26 01:27:33 +00:00
|
|
|
|
(if (autoloadp symbol)
|
1995-07-22 15:17:54 +00:00
|
|
|
|
(memq (nth 4 symbol)
|
|
|
|
|
'(macro t))))))
|
1995-07-07 18:53:58 +00:00
|
|
|
|
|
1995-07-22 15:17:54 +00:00
|
|
|
|
|
2001-10-08 06:58:32 +00:00
|
|
|
|
(defun apropos-print-doc (i type do-keys)
|
2011-04-24 00:15:26 +00:00
|
|
|
|
(let ((doc (nth i apropos-item)))
|
|
|
|
|
(when (stringp doc)
|
|
|
|
|
(if apropos-compact-layout
|
|
|
|
|
(insert (propertize "\t" 'display '(space :align-to 32)) " ")
|
|
|
|
|
(insert " "))
|
|
|
|
|
(if apropos-multi-type
|
|
|
|
|
(let ((button-face (button-type-get type 'face)))
|
|
|
|
|
(unless (consp button-face)
|
|
|
|
|
(setq button-face (list button-face)))
|
|
|
|
|
(insert-text-button
|
|
|
|
|
(if apropos-compact-layout
|
|
|
|
|
(format "<%s>" (button-type-get type 'apropos-short-label))
|
|
|
|
|
(button-type-get type 'apropos-label))
|
|
|
|
|
'type type
|
|
|
|
|
'apropos-symbol (car apropos-item))
|
|
|
|
|
(insert (if apropos-compact-layout " " ": ")))
|
|
|
|
|
|
|
|
|
|
;; If the query is only for a single type, there's no point
|
|
|
|
|
;; writing it over and over again. Insert a blank button, and
|
|
|
|
|
;; put the 'apropos-label property there (needed by
|
|
|
|
|
;; apropos-symbol-button-display-help).
|
|
|
|
|
(insert-text-button
|
2008-07-31 22:15:18 +00:00
|
|
|
|
" " 'type type 'skip t
|
2011-04-24 00:15:26 +00:00
|
|
|
|
'face 'default 'apropos-symbol (car apropos-item)))
|
|
|
|
|
|
|
|
|
|
(let ((opoint (point))
|
|
|
|
|
(ocol (current-column)))
|
|
|
|
|
(cond ((equal doc "")
|
|
|
|
|
(setq doc "(not documented)"))
|
|
|
|
|
(do-keys
|
|
|
|
|
(setq doc (substitute-command-keys doc))))
|
|
|
|
|
(insert doc)
|
|
|
|
|
(if (equal doc "(not documented)")
|
|
|
|
|
(put-text-property opoint (point) 'font-lock-face 'shadow))
|
|
|
|
|
;; The labeling buttons might make the line too long, so fill it if
|
|
|
|
|
;; necessary.
|
2011-05-06 19:59:17 +00:00
|
|
|
|
(let ((fill-column (+ 5 (if (integerp emacs-lisp-docstring-fill-column)
|
|
|
|
|
emacs-lisp-docstring-fill-column
|
|
|
|
|
fill-column)))
|
2011-04-24 00:15:26 +00:00
|
|
|
|
(fill-prefix (make-string ocol ?\s)))
|
|
|
|
|
(fill-region opoint (point) nil t)))
|
|
|
|
|
(or (bolp) (terpri)))))
|
1995-07-07 18:53:58 +00:00
|
|
|
|
|
2001-10-07 11:35:09 +00:00
|
|
|
|
(defun apropos-follow ()
|
|
|
|
|
"Invokes any button at point, otherwise invokes the nearest label button."
|
1995-07-07 18:53:58 +00:00
|
|
|
|
(interactive)
|
2001-10-07 11:35:09 +00:00
|
|
|
|
(button-activate
|
|
|
|
|
(or (apropos-next-label-button (line-beginning-position))
|
|
|
|
|
(error "There is nothing to follow here"))))
|
1995-07-07 18:53:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun apropos-describe-plist (symbol)
|
|
|
|
|
"Display a pretty listing of SYMBOL's plist."
|
2009-10-02 03:48:36 +00:00
|
|
|
|
(help-setup-xref (list 'apropos-describe-plist symbol)
|
|
|
|
|
(called-interactively-p 'interactive))
|
2007-11-10 09:55:10 +00:00
|
|
|
|
(with-help-window (help-buffer)
|
1995-07-07 18:53:58 +00:00
|
|
|
|
(set-buffer standard-output)
|
|
|
|
|
(princ "Symbol ")
|
|
|
|
|
(prin1 symbol)
|
|
|
|
|
(princ "'s plist is\n (")
|
Use proper faces in apropos.el.
* lisp/apropos.el (apropos-symbol, apropos-keybinding, apropos-label)
(apropos-property, apropos-function-button)
(apropos-variable-button, apropos-misc-button): New faces.
(apropos-symbol-face, apropos-keybinding-face)
(apropos-label-face, apropos-property-face, apropos-match-face):
Variables removed.
(apropos-library-button, apropos-format-plist, apropos-print)
(apropos-print-doc, apropos-describe-plist): Callers changed.
Fixes: debbugs:8396
2012-04-23 15:38:48 +00:00
|
|
|
|
(put-text-property (+ (point-min) 7) (- (point) 14)
|
|
|
|
|
'face 'apropos-symbol)
|
1995-07-07 18:53:58 +00:00
|
|
|
|
(insert (apropos-format-plist symbol "\n "))
|
2007-11-10 09:55:10 +00:00
|
|
|
|
(princ ")")))
|
1991-07-31 02:49:11 +00:00
|
|
|
|
|
2001-10-07 11:35:09 +00:00
|
|
|
|
|
1997-06-22 18:57:55 +00:00
|
|
|
|
(provide 'apropos)
|
|
|
|
|
|
1992-05-30 23:54:21 +00:00
|
|
|
|
;;; apropos.el ends here
|