annotate lisp/emacs-lisp/eldoc.el @ 44384:3626a12fe452

* pcvs.el (cvs-mode-previous-line, cvs-mode-next-line): Move to spot indicated by text property `cvs-goal-column', if present. * pcvs-info.el (cvs-fileinfo-pp): Use text property `cvs-goal-column' to indicate position of file name (if present).
author Kai Großjohann <kgrossjo@eu.uu.net>
date Wed, 03 Apr 2002 16:56:36 +0000
parents 365f0cb0170e
children 5a25c61f2c8b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13530
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
1 ;;; eldoc.el --- show function arglist or variable docstring in echo area
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
2
30389
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
3 ;; Copyright (C) 1996, 97, 98, 99, 2000 Free Software Foundation, Inc.
13530
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
4
23283
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
5 ;; Author: Noah Friedman <friedman@splode.com>
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
6 ;; Maintainer: friedman@splode.com
13530
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
7 ;; Keywords: extensions
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
8 ;; Created: 1995-10-06
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
9
42623
365f0cb0170e (eldoc-minor-mode-string): Fix custom type.
Richard M. Stallman <rms@gnu.org>
parents: 41167
diff changeset
10 ;; $Id: eldoc.el,v 1.19 2001/11/16 23:58:48 monnier Exp $
13530
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
11
16969
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
12 ;; This file is part of GNU Emacs.
13530
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
13
16969
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
14 ;; GNU Emacs is free software; you can redistribute it and/or modify
13530
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
15 ;; it under the terms of the GNU General Public License as published by
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
16 ;; the Free Software Foundation; either version 2, or (at your option)
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
17 ;; any later version.
16969
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
18
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
19 ;; GNU Emacs is distributed in the hope that it will be useful,
13530
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
22 ;; GNU General Public License for more details.
16969
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
23
13530
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
24 ;; You should have received a copy of the GNU General Public License
16969
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
25 ;; along with GNU Emacs; see the file COPYING. If not, write to the
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
26 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
27 ;; Boston, MA 02111-1307, USA.
13530
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
28
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
29 ;;; Commentary:
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
30
16969
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
31 ;; This program was inspired by the behavior of the "mouse documentation
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
32 ;; window" on many Lisp Machine systems; as you type a function's symbol
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
33 ;; name as part of a sexp, it will print the argument list for that
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
34 ;; function. Behavior is not identical; for example, you need not actually
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
35 ;; type the function name, you need only move point around in a sexp that
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
36 ;; calls it. Also, if point is over a documented variable, it will print
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
37 ;; the one-line documentation for that variable instead, to remind you of
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
38 ;; that variable's meaning.
13530
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
39
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
40 ;; One useful way to enable this minor mode is to put the following in your
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
41 ;; .emacs:
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
42 ;;
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
43 ;; (autoload 'turn-on-eldoc-mode "eldoc" nil t)
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
44 ;; (add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode)
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
45 ;; (add-hook 'lisp-interaction-mode-hook 'turn-on-eldoc-mode)
16975
188c4da9bf5d (eldoc-display-message-p): New function.
Noah Friedman <friedman@splode.com>
parents: 16969
diff changeset
46 ;; (add-hook 'ielm-mode-hook 'turn-on-eldoc-mode)
13530
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
47
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
48 ;;; Code:
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
49
16969
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
50 ;; Use idle timers if available in the version of emacs running.
30389
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
51 ;; Please don't change this to use `require'; this package works
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
52 ;; as-is in XEmacs 19.14 and later and I am striving to maintain
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
53 ;; compatibility between emacs variants.
16969
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
54 (or (featurep 'timer)
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
55 (load "timer" t))
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
56
17445
f2db4e8bb6ed Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17253
diff changeset
57 (defgroup eldoc nil
f2db4e8bb6ed Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17253
diff changeset
58 "Show function arglist or variable docstring in echo area."
30389
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
59 :group 'lisp
17445
f2db4e8bb6ed Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17253
diff changeset
60 :group 'extensions)
f2db4e8bb6ed Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17253
diff changeset
61
f2db4e8bb6ed Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17253
diff changeset
62 (defcustom eldoc-idle-delay 0.50
13530
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
63 "*Number of seconds of idle time to wait before printing.
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
64 If user input arrives before this interval of time has elapsed after the
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
65 last input, no documentation will be printed.
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
66
17445
f2db4e8bb6ed Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17253
diff changeset
67 If this variable is set to 0, no idle time is required."
f2db4e8bb6ed Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17253
diff changeset
68 :type 'number
f2db4e8bb6ed Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17253
diff changeset
69 :group 'eldoc)
13530
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
70
30389
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
71 ;;;###autoload
17445
f2db4e8bb6ed Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17253
diff changeset
72 (defcustom eldoc-minor-mode-string " ElDoc"
42623
365f0cb0170e (eldoc-minor-mode-string): Fix custom type.
Richard M. Stallman <rms@gnu.org>
parents: 41167
diff changeset
73 "*String to display in mode line when Eldoc Mode is enabled; nil for none."
365f0cb0170e (eldoc-minor-mode-string): Fix custom type.
Richard M. Stallman <rms@gnu.org>
parents: 41167
diff changeset
74 :type '(choice string (const :tag "None" nil))
17445
f2db4e8bb6ed Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17253
diff changeset
75 :group 'eldoc)
16969
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
76
17445
f2db4e8bb6ed Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17253
diff changeset
77 (defcustom eldoc-argument-case 'upcase
13530
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
78 "Case to display argument names of functions, as a symbol.
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
79 This has two preferred values: `upcase' or `downcase'.
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
80 Actually, any name of a function which takes a string as an argument and
17445
f2db4e8bb6ed Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17253
diff changeset
81 returns another string is acceptable."
30389
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
82 :type '(radio (function-item upcase)
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
83 (function-item downcase)
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
84 function)
17445
f2db4e8bb6ed Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17253
diff changeset
85 :group 'eldoc)
13530
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
86
30389
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
87 (defcustom eldoc-echo-area-use-multiline-p 'truncate-sym-name-if-fit
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
88 "*Allow long eldoc messages to resize echo area display.
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
89 If value is `t', never attempt to truncate messages; complete symbol name
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
90 and function arglist or 1-line variable documentation will be displayed
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
91 even if echo area must be resized to fit.
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
92
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
93 If value is any non-nil value other than `t', symbol name may be truncated
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
94 if it will enable the function arglist or documentation string to fit on a
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
95 single line without resizing window. Otherwise, behavior is just like
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
96 former case.
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
97
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
98 If value is nil, messages are always truncated to fit in a single line of
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
99 display in the echo area. Function or variable symbol name may be
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
100 truncated to make more of the arglist or documentation string visible.
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
101
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
102 Non-nil values for this variable have no effect unless
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
103 `eldoc-echo-area-multiline-supported-p' is non-nil."
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
104 :type '(radio (const :tag "Always" t)
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
105 (const :tag "Never" nil)
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
106 (const :tag "Yes, but truncate symbol names if it will\
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
107 enable argument list to fit on one line" truncate-sym-name-if-fit))
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
108 :group 'eldoc)
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
109
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
110 ;;; No user options below here.
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
111
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
112 ;; Non-nil if this version of emacs supports dynamically resizable echo areas.
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
113 (defvar eldoc-echo-area-multiline-supported-p
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
114 (and (string-lessp "21" emacs-version)
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
115 (save-match-data
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
116 (numberp (string-match "^GNU Emacs" (emacs-version))))))
16996
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
117
17920
161cc8316f98 (eldoc-message-commands): Move docstring into comments, since this isn't
Noah Friedman <friedman@splode.com>
parents: 17445
diff changeset
118 ;; Commands after which it is appropriate to print in the echo area.
161cc8316f98 (eldoc-message-commands): Move docstring into comments, since this isn't
Noah Friedman <friedman@splode.com>
parents: 17445
diff changeset
119 ;; Eldoc does not try to print function arglists, etc. after just any command,
161cc8316f98 (eldoc-message-commands): Move docstring into comments, since this isn't
Noah Friedman <friedman@splode.com>
parents: 17445
diff changeset
120 ;; because some commands print their own messages in the echo area and these
161cc8316f98 (eldoc-message-commands): Move docstring into comments, since this isn't
Noah Friedman <friedman@splode.com>
parents: 17445
diff changeset
121 ;; functions would instantly overwrite them. But self-insert-command as well
161cc8316f98 (eldoc-message-commands): Move docstring into comments, since this isn't
Noah Friedman <friedman@splode.com>
parents: 17445
diff changeset
122 ;; as most motion commands are good candidates.
161cc8316f98 (eldoc-message-commands): Move docstring into comments, since this isn't
Noah Friedman <friedman@splode.com>
parents: 17445
diff changeset
123 ;; This variable contains an obarray of symbols; do not manipulate it
161cc8316f98 (eldoc-message-commands): Move docstring into comments, since this isn't
Noah Friedman <friedman@splode.com>
parents: 17445
diff changeset
124 ;; directly. Instead, use `eldoc-add-command' and `eldoc-remove-command'.
161cc8316f98 (eldoc-message-commands): Move docstring into comments, since this isn't
Noah Friedman <friedman@splode.com>
parents: 17445
diff changeset
125 (defvar eldoc-message-commands nil)
13530
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
126
16996
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
127 ;; This is used by eldoc-add-command to initialize eldoc-message-commands
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
128 ;; as an obarray.
17920
161cc8316f98 (eldoc-message-commands): Move docstring into comments, since this isn't
Noah Friedman <friedman@splode.com>
parents: 17445
diff changeset
129 ;; It should probably never be necessary to do so, but if you
161cc8316f98 (eldoc-message-commands): Move docstring into comments, since this isn't
Noah Friedman <friedman@splode.com>
parents: 17445
diff changeset
130 ;; choose to increase the number of buckets, you must do so before loading
161cc8316f98 (eldoc-message-commands): Move docstring into comments, since this isn't
Noah Friedman <friedman@splode.com>
parents: 17445
diff changeset
131 ;; this file since the obarray is initialized at load time.
161cc8316f98 (eldoc-message-commands): Move docstring into comments, since this isn't
Noah Friedman <friedman@splode.com>
parents: 17445
diff changeset
132 ;; Remember to keep it a prime number to improve hash performance.
161cc8316f98 (eldoc-message-commands): Move docstring into comments, since this isn't
Noah Friedman <friedman@splode.com>
parents: 17445
diff changeset
133 (defvar eldoc-message-commands-table-size 31)
13530
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
134
23283
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
135 ;; Bookkeeping; elements are as follows:
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
136 ;; 0 - contains the last symbol read from the buffer.
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
137 ;; 1 - contains the string last displayed in the echo area for that
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
138 ;; symbol, so it can be printed again if necessary without reconsing.
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
139 ;; 2 - 'function if function args, 'variable if variable documentation.
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
140 (defvar eldoc-last-data (make-vector 3 nil))
16996
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
141 (defvar eldoc-last-message nil)
13530
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
142
16969
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
143 ;; Idle timers are supported in Emacs 19.31 and later.
17920
161cc8316f98 (eldoc-message-commands): Move docstring into comments, since this isn't
Noah Friedman <friedman@splode.com>
parents: 17445
diff changeset
144 (defvar eldoc-use-idle-timer-p (fboundp 'run-with-idle-timer))
13591
b2fb0109006d (eldoc-minor-mode-string): New variable.
Noah Friedman <friedman@splode.com>
parents: 13532
diff changeset
145
16969
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
146 ;; eldoc's timer object, if using idle timers
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
147 (defvar eldoc-timer nil)
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
148
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
149 ;; idle time delay currently in use by timer.
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
150 ;; This is used to determine if eldoc-idle-delay is changed by the user.
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
151 (defvar eldoc-current-idle-delay eldoc-idle-delay)
13530
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
152
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
153
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
154 ;;;###autoload
41167
ae8862effdf5 (eldoc-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34127
diff changeset
155 (define-minor-mode eldoc-mode
ae8862effdf5 (eldoc-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34127
diff changeset
156 "Toggle ElDoc mode on or off.
ae8862effdf5 (eldoc-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34127
diff changeset
157 Show the defined parameters for the elisp function near point.
16969
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
158
41167
ae8862effdf5 (eldoc-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34127
diff changeset
159 For the emacs lisp function at the beginning of the sexp which point is
ae8862effdf5 (eldoc-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34127
diff changeset
160 within, show the defined parameters for the function in the echo area.
ae8862effdf5 (eldoc-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34127
diff changeset
161 This information is extracted directly from the function or macro if it is
ae8862effdf5 (eldoc-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34127
diff changeset
162 in pure lisp. If the emacs function is a subr, the parameters are obtained
ae8862effdf5 (eldoc-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34127
diff changeset
163 from the documentation string if possible.
ae8862effdf5 (eldoc-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34127
diff changeset
164
ae8862effdf5 (eldoc-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34127
diff changeset
165 If point is over a documented variable, print that variable's docstring
ae8862effdf5 (eldoc-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34127
diff changeset
166 instead.
ae8862effdf5 (eldoc-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34127
diff changeset
167
ae8862effdf5 (eldoc-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34127
diff changeset
168 With prefix ARG, turn ElDoc mode on if and only if ARG is positive."
ae8862effdf5 (eldoc-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34127
diff changeset
169 nil eldoc-minor-mode-string nil
16996
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
170 (setq eldoc-last-message nil)
16969
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
171 (cond (eldoc-use-idle-timer-p
16996
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
172 (add-hook 'post-command-hook 'eldoc-schedule-timer)
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
173 (add-hook 'pre-command-hook 'eldoc-pre-command-refresh-echo-area))
16969
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
174 (t
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
175 ;; Use post-command-idle-hook if defined, otherwise use
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
176 ;; post-command-hook. The former is only proper to use in Emacs
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
177 ;; 19.30; that is the first version in which it appeared, but it
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
178 ;; was obsolesced by idle timers in Emacs 19.31.
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
179 (add-hook (if (boundp 'post-command-idle-hook)
30389
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
180 'post-command-idle-hook
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
181 'post-command-hook)
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
182 'eldoc-print-current-symbol-info t t)
16996
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
183 ;; quick and dirty hack for seeing if this is XEmacs
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
184 (and (fboundp 'display-message)
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
185 (add-hook 'pre-command-hook
41167
ae8862effdf5 (eldoc-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34127
diff changeset
186 'eldoc-pre-command-refresh-echo-area t t)))))
13530
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
187
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
188 ;;;###autoload
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
189 (defun turn-on-eldoc-mode ()
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
190 "Unequivocally turn on eldoc-mode (see variable documentation)."
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
191 (interactive)
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
192 (eldoc-mode 1))
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
193
23283
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
194
16969
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
195 ;; Idle timers are part of Emacs 19.31 and later.
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
196 (defun eldoc-schedule-timer ()
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
197 (or (and eldoc-timer
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
198 (memq eldoc-timer timer-idle-list))
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
199 (setq eldoc-timer
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
200 (run-with-idle-timer eldoc-idle-delay t
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
201 'eldoc-print-current-symbol-info)))
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
202
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
203 ;; If user has changed the idle delay, update the timer.
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
204 (cond ((not (= eldoc-idle-delay eldoc-current-idle-delay))
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
205 (setq eldoc-current-idle-delay eldoc-idle-delay)
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
206 (timer-set-idle-time eldoc-timer eldoc-idle-delay t))))
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
207
23283
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
208 (defun eldoc-message (&rest args)
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
209 (let ((omessage eldoc-last-message))
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
210 (cond ((eq (car args) eldoc-last-message))
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
211 ((or (null args)
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
212 (null (car args)))
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
213 (setq eldoc-last-message nil))
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
214 ;; If only one arg, no formatting to do so put it in
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
215 ;; eldoc-last-message so eq test above might succeed on
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
216 ;; subsequent calls.
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
217 ((null (cdr args))
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
218 (setq eldoc-last-message (car args)))
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
219 (t
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
220 (setq eldoc-last-message (apply 'format args))))
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
221 ;; In emacs 19.29 and later, and XEmacs 19.13 and later, all messages
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
222 ;; are recorded in a log. Do not put eldoc messages in that log since
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
223 ;; they are Legion.
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
224 (cond ((fboundp 'display-message)
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
225 ;; XEmacs 19.13 way of preventing log messages.
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
226 (cond (eldoc-last-message
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
227 (display-message 'no-log eldoc-last-message))
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
228 (omessage
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
229 (clear-message 'no-log))))
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
230 (t
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
231 ;; Emacs way of preventing log messages.
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
232 (let ((message-log-max nil))
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
233 (cond (eldoc-last-message
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
234 (message "%s" eldoc-last-message))
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
235 (omessage
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
236 (message nil)))))))
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
237 eldoc-last-message)
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
238
16996
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
239 ;; This function goes on pre-command-hook for XEmacs or when using idle
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
240 ;; timers in Emacs. Motion commands clear the echo area for some reason,
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
241 ;; which make eldoc messages flicker or disappear just before motion
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
242 ;; begins. This function reprints the last eldoc message immediately
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
243 ;; before the next command executes, which does away with the flicker.
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
244 ;; This doesn't seem to be required for Emacs 19.28 and earlier.
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
245 (defun eldoc-pre-command-refresh-echo-area ()
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
246 (and eldoc-last-message
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
247 (if (eldoc-display-message-no-interference-p)
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
248 (eldoc-message eldoc-last-message)
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
249 (setq eldoc-last-message nil))))
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
250
16975
188c4da9bf5d (eldoc-display-message-p): New function.
Noah Friedman <friedman@splode.com>
parents: 16969
diff changeset
251 ;; Decide whether now is a good time to display a message.
188c4da9bf5d (eldoc-display-message-p): New function.
Noah Friedman <friedman@splode.com>
parents: 16969
diff changeset
252 (defun eldoc-display-message-p ()
16996
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
253 (and (eldoc-display-message-no-interference-p)
16969
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
254 (cond (eldoc-use-idle-timer-p
16975
188c4da9bf5d (eldoc-display-message-p): New function.
Noah Friedman <friedman@splode.com>
parents: 16969
diff changeset
255 ;; If this-command is non-nil while running via an idle
188c4da9bf5d (eldoc-display-message-p): New function.
Noah Friedman <friedman@splode.com>
parents: 16969
diff changeset
256 ;; timer, we're still in the middle of executing a command,
188c4da9bf5d (eldoc-display-message-p): New function.
Noah Friedman <friedman@splode.com>
parents: 16969
diff changeset
257 ;; e.g. a query-replace where it would be annoying to
188c4da9bf5d (eldoc-display-message-p): New function.
Noah Friedman <friedman@splode.com>
parents: 16969
diff changeset
258 ;; overwrite the echo area.
188c4da9bf5d (eldoc-display-message-p): New function.
Noah Friedman <friedman@splode.com>
parents: 16969
diff changeset
259 (and (not this-command)
188c4da9bf5d (eldoc-display-message-p): New function.
Noah Friedman <friedman@splode.com>
parents: 16969
diff changeset
260 (symbolp last-command)
16969
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
261 (intern-soft (symbol-name last-command)
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
262 eldoc-message-commands)))
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
263 (t
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
264 ;; If we don't have idle timers, this function is
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
265 ;; running on post-command-hook directly; that means the
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
266 ;; user's last command is still on `this-command', and we
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
267 ;; must wait briefly for input to see whether to do display.
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
268 (and (symbolp this-command)
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
269 (intern-soft (symbol-name this-command)
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
270 eldoc-message-commands)
16975
188c4da9bf5d (eldoc-display-message-p): New function.
Noah Friedman <friedman@splode.com>
parents: 16969
diff changeset
271 (sit-for eldoc-idle-delay))))))
13530
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
272
30389
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
273 ;; Check various conditions about the current environment that might make
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
274 ;; it undesirable to print eldoc messages right this instant.
16996
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
275 (defun eldoc-display-message-no-interference-p ()
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
276 (and eldoc-mode
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
277 (not executing-kbd-macro)
30389
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
278 (not (and (boundp 'edebug-active) edebug-active))
16996
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
279 ;; Having this mode operate in an active minibuffer/echo area causes
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
280 ;; interference with what's going on there.
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
281 (not cursor-in-echo-area)
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
282 (not (eq (selected-window) (minibuffer-window)))))
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
283
23283
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
284
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
285 (defun eldoc-print-current-symbol-info ()
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
286 (and (eldoc-display-message-p)
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
287 (let* ((current-symbol (eldoc-current-symbol))
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
288 (current-fnsym (eldoc-fnsym-in-current-sexp))
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
289 (doc (cond ((eq current-symbol current-fnsym)
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
290 (or (eldoc-get-fnsym-args-string current-fnsym)
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
291 (eldoc-get-var-docstring current-symbol)))
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
292 (t
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
293 (or (eldoc-get-var-docstring current-symbol)
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
294 (eldoc-get-fnsym-args-string current-fnsym))))))
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
295 (eldoc-message doc))))
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
296
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
297 ;; Return a string containing the function parameter list, or 1-line
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
298 ;; docstring if function is a subr and no arglist is obtainable from the
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
299 ;; docstring or elsewhere.
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
300 (defun eldoc-get-fnsym-args-string (sym)
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
301 (let ((args nil)
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
302 (doc nil))
16996
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
303 (cond ((not (and sym
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
304 (symbolp sym)
13530
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
305 (fboundp sym))))
23283
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
306 ((and (eq sym (aref eldoc-last-data 0))
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
307 (eq 'function (aref eldoc-last-data 2)))
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
308 (setq doc (aref eldoc-last-data 1)))
13530
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
309 ((subrp (eldoc-symbol-function sym))
16969
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
310 (setq args (or (eldoc-function-argstring-from-docstring sym)
23283
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
311 (eldoc-docstring-first-line (documentation sym t)))))
13530
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
312 (t
23283
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
313 (setq args (eldoc-function-argstring sym))))
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
314 (cond (args
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
315 (setq doc (eldoc-docstring-format-sym-doc sym args))
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
316 (eldoc-last-data-store sym doc 'function)))
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
317 doc))
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
318
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
319 ;; Return a string containing a brief (one-line) documentation string for
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
320 ;; the variable.
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
321 (defun eldoc-get-var-docstring (sym)
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
322 (cond ((and (eq sym (aref eldoc-last-data 0))
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
323 (eq 'variable (aref eldoc-last-data 2)))
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
324 (aref eldoc-last-data 1))
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
325 (t
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
326 (let ((doc (documentation-property sym 'variable-documentation t)))
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
327 (cond (doc
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
328 (setq doc (eldoc-docstring-format-sym-doc
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
329 sym (eldoc-docstring-first-line doc)))
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
330 (eldoc-last-data-store sym doc 'variable)))
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
331 doc))))
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
332
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
333 (defun eldoc-last-data-store (symbol doc type)
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
334 (aset eldoc-last-data 0 symbol)
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
335 (aset eldoc-last-data 1 doc)
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
336 (aset eldoc-last-data 2 type))
13530
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
337
23283
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
338 ;; Note that any leading `*' in the docstring (which indicates the variable
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
339 ;; is a user option) is removed.
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
340 (defun eldoc-docstring-first-line (doc)
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
341 (and (stringp doc)
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
342 (substitute-command-keys
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
343 (save-match-data
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
344 (let ((start (if (string-match "^\\*" doc) (match-end 0) 0)))
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
345 (cond ((string-match "\n" doc)
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
346 (substring doc start (match-beginning 0)))
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
347 ((zerop start) doc)
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
348 (t (substring doc start))))))))
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
349
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
350 ;; If the entire line cannot fit in the echo area, the symbol name may be
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
351 ;; truncated or eliminated entirely from the output to make room for the
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
352 ;; description.
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
353 (defun eldoc-docstring-format-sym-doc (sym doc)
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
354 (save-match-data
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
355 (let* ((name (symbol-name sym))
30389
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
356 (ea-multi (and eldoc-echo-area-multiline-supported-p
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
357 eldoc-echo-area-use-multiline-p))
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
358 ;; Subtract 1 from window width since emacs will not write
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
359 ;; any chars to the last column, or in later versions, will
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
360 ;; cause a wraparound and resize of the echo area.
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
361 (ea-width (1- (window-width (minibuffer-window))))
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
362 (strip (- (+ (length name) (length ": ") (length doc)) ea-width)))
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
363 (cond ((or (<= strip 0)
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
364 (eq ea-multi t)
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
365 (and ea-multi (> (length doc) ea-width)))
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
366 (format "%s: %s" sym doc))
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
367 ((> (length doc) ea-width)
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
368 (substring (format "%s" doc) 0 ea-width))
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
369 ((>= strip (length name))
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
370 (format "%s" doc))
23283
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
371 (t
30389
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
372 ;; Show the end of the partial symbol name, rather
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
373 ;; than the beginning, since the former is more likely
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
374 ;; to be unique given package namespace conventions.
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
375 (setq name (substring name strip))
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
376 (format "%s: %s" name doc))))))
23283
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
377
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
378
13530
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
379 (defun eldoc-fnsym-in-current-sexp ()
16996
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
380 (let ((p (point)))
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
381 (eldoc-beginning-of-sexp)
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
382 (prog1
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
383 ;; Don't do anything if current word is inside a string.
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
384 (if (= (or (char-after (1- (point))) 0) ?\")
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
385 nil
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
386 (eldoc-current-symbol))
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
387 (goto-char p))))
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
388
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
389 (defun eldoc-beginning-of-sexp ()
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
390 (let ((parse-sexp-ignore-comments t))
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
391 (condition-case err
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
392 (while (progn
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
393 (forward-sexp -1)
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
394 (or (= (or (char-after (1- (point)))) ?\")
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
395 (> (point) (point-min)))))
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
396 (error nil))))
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
397
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
398 ;; returns nil unless current word is an interned symbol.
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
399 (defun eldoc-current-symbol ()
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
400 (let ((c (char-after (point))))
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
401 (and c
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
402 (memq (char-syntax c) '(?w ?_))
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
403 (intern-soft (current-word)))))
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
404
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
405 ;; Do indirect function resolution if possible.
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
406 (defun eldoc-symbol-function (fsym)
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
407 (let ((defn (and (fboundp fsym)
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
408 (symbol-function fsym))))
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
409 (and (symbolp defn)
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
410 (condition-case err
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
411 (setq defn (indirect-function fsym))
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
412 (error (setq defn nil))))
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
413 defn))
13530
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
414
30389
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
415 (defun eldoc-function-arglist (fn)
13532
37fdd3664658 (top level): Make sure to set global minor-mode-alist, not local one.
Noah Friedman <friedman@splode.com>
parents: 13530
diff changeset
416 (let* ((prelim-def (eldoc-symbol-function fn))
37fdd3664658 (top level): Make sure to set global minor-mode-alist, not local one.
Noah Friedman <friedman@splode.com>
parents: 13530
diff changeset
417 (def (if (eq (car-safe prelim-def) 'macro)
37fdd3664658 (top level): Make sure to set global minor-mode-alist, not local one.
Noah Friedman <friedman@splode.com>
parents: 13530
diff changeset
418 (cdr prelim-def)
37fdd3664658 (top level): Make sure to set global minor-mode-alist, not local one.
Noah Friedman <friedman@splode.com>
parents: 13530
diff changeset
419 prelim-def))
13530
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
420 (arglist (cond ((null def) nil)
13532
37fdd3664658 (top level): Make sure to set global minor-mode-alist, not local one.
Noah Friedman <friedman@splode.com>
parents: 13530
diff changeset
421 ((byte-code-function-p def)
30389
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
422 (cond ((fboundp 'compiled-function-arglist)
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
423 (funcall 'compiled-function-arglist def))
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
424 (t
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
425 (aref def 0))))
13530
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
426 ((eq (car-safe def) 'lambda)
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
427 (nth 1 def))
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
428 (t t))))
30389
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
429 arglist))
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
430
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
431 (defun eldoc-function-argstring (fn)
38f19553e93d (eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents: 23586
diff changeset
432 (eldoc-function-argstring-format (eldoc-function-arglist fn)))
13530
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
433
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
434 (defun eldoc-function-argstring-format (arglist)
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
435 (cond ((not (listp arglist))
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
436 (setq arglist nil))
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
437 ((symbolp (car arglist))
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
438 (setq arglist
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
439 (mapcar (function (lambda (s)
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
440 (if (memq s '(&optional &rest))
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
441 (symbol-name s)
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
442 (funcall eldoc-argument-case
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
443 (symbol-name s)))))
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
444 arglist)))
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
445 ((stringp (car arglist))
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
446 (setq arglist
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
447 (mapcar (function (lambda (s)
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
448 (if (member s '("&optional" "&rest"))
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
449 s
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
450 (funcall eldoc-argument-case s))))
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
451 arglist))))
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
452 (concat "(" (mapconcat 'identity arglist " ") ")"))
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
453
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
454
16969
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
455 ;; Alist of predicate/action pairs.
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
456 ;; Each member of the list is a sublist consisting of a predicate function
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
457 ;; used to determine if the arglist for a function can be found using a
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
458 ;; certain pattern, and a function which returns the actual arglist from
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
459 ;; that docstring.
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
460 ;;
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
461 ;; The order in this table is significant, since later predicates may be
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
462 ;; more general than earlier ones.
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
463 ;;
17920
161cc8316f98 (eldoc-message-commands): Move docstring into comments, since this isn't
Noah Friedman <friedman@splode.com>
parents: 17445
diff changeset
464 ;; Compiler note for Emacs/XEmacs versions which support dynamic loading:
161cc8316f98 (eldoc-message-commands): Move docstring into comments, since this isn't
Noah Friedman <friedman@splode.com>
parents: 17445
diff changeset
465 ;; these functions will be compiled to bytecode, but can't be lazy-loaded
161cc8316f98 (eldoc-message-commands): Move docstring into comments, since this isn't
Noah Friedman <friedman@splode.com>
parents: 17445
diff changeset
466 ;; even if you set byte-compile-dynamic; to do that would require making
161cc8316f98 (eldoc-message-commands): Move docstring into comments, since this isn't
Noah Friedman <friedman@splode.com>
parents: 17445
diff changeset
467 ;; them named top-level defuns, which is not particularly desirable either.
161cc8316f98 (eldoc-message-commands): Move docstring into comments, since this isn't
Noah Friedman <friedman@splode.com>
parents: 17445
diff changeset
468 (defvar eldoc-function-argstring-from-docstring-method-table
16969
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
469 (list
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
470 ;; Try first searching for args starting with symbol name.
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
471 ;; This is to avoid matching parenthetical remarks in e.g. sit-for.
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
472 (list (function (lambda (doc fn)
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
473 (string-match (format "^(%s[^\n)]*)$" fn) doc)))
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
474 (function (lambda (doc)
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
475 ;; end does not include trailing ")" sequence.
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
476 (let ((end (- (match-end 0) 1)))
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
477 (if (string-match " +" doc (match-beginning 0))
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
478 (substring doc (match-end 0) end)
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
479 "")))))
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
480
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
481 ;; Try again not requiring this symbol name in the docstring.
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
482 ;; This will be the case when looking up aliases.
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
483 (list (function (lambda (doc fn)
17920
161cc8316f98 (eldoc-message-commands): Move docstring into comments, since this isn't
Noah Friedman <friedman@splode.com>
parents: 17445
diff changeset
484 ;; save-restriction has a pathological docstring in
161cc8316f98 (eldoc-message-commands): Move docstring into comments, since this isn't
Noah Friedman <friedman@splode.com>
parents: 17445
diff changeset
485 ;; Emacs/XEmacs 19.
161cc8316f98 (eldoc-message-commands): Move docstring into comments, since this isn't
Noah Friedman <friedman@splode.com>
parents: 17445
diff changeset
486 (and (not (eq fn 'save-restriction))
161cc8316f98 (eldoc-message-commands): Move docstring into comments, since this isn't
Noah Friedman <friedman@splode.com>
parents: 17445
diff changeset
487 (string-match "^([^\n)]+)$" doc))))
16969
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
488 (function (lambda (doc)
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
489 ;; end does not include trailing ")" sequence.
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
490 (let ((end (- (match-end 0) 1)))
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
491 (and (string-match " +" doc (match-beginning 0))
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
492 (substring doc (match-end 0) end))))))
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
493
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
494 ;; Emacs subr docstring style:
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
495 ;; (fn arg1 arg2 ...): description...
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
496 (list (function (lambda (doc fn)
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
497 (string-match "^([^\n)]+):" doc)))
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
498 (function (lambda (doc)
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
499 ;; end does not include trailing "):" sequence.
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
500 (let ((end (- (match-end 0) 2)))
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
501 (and (string-match " +" doc (match-beginning 0))
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
502 (substring doc (match-end 0) end))))))
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
503
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
504 ;; XEmacs subr docstring style:
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
505 ;; "arguments: (arg1 arg2 ...)
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
506 (list (function (lambda (doc fn)
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
507 (string-match "^arguments: (\\([^\n)]+\\))" doc)))
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
508 (function (lambda (doc)
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
509 ;; also skip leading paren, but the first word is
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
510 ;; actually an argument, not the function name.
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
511 (substring doc (match-beginning 1) (match-end 1)))))
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
512
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
513 ;; This finds the argstring for `condition-case'. Any others?
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
514 (list (function (lambda (doc fn)
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
515 (string-match
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
516 (format "^Usage looks like \\((%s[^\n)]*)\\)\\.$" fn)
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
517 doc)))
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
518 (function (lambda (doc)
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
519 ;; end does not include trailing ")" sequence.
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
520 (let ((end (- (match-end 1) 1)))
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
521 (and (string-match " +" doc (match-beginning 1))
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
522 (substring doc (match-end 0) end))))))
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
523
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
524 ;; This finds the argstring for `setq-default'. Any others?
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
525 (list (function (lambda (doc fn)
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
526 (string-match (format "^[ \t]+\\((%s[^\n)]*)\\)$" fn)
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
527 doc)))
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
528 (function (lambda (doc)
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
529 ;; end does not include trailing ")" sequence.
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
530 (let ((end (- (match-end 1) 1)))
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
531 (and (string-match " +" doc (match-beginning 1))
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
532 (substring doc (match-end 0) end))))))
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
533
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
534 ;; This finds the argstring for `start-process'. Any others?
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
535 (list (function (lambda (doc fn)
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
536 (string-match "^Args are +\\([^\n]+\\)$" doc)))
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
537 (function (lambda (doc)
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
538 (substring doc (match-beginning 1) (match-end 1)))))
16996
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
539
17920
161cc8316f98 (eldoc-message-commands): Move docstring into comments, since this isn't
Noah Friedman <friedman@splode.com>
parents: 17445
diff changeset
540 ;; These common subrs don't have arglists in their docstrings. So cheat.
16996
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
541 (list (function (lambda (doc fn)
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
542 (memq fn '(and or list + -))))
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
543 (function (lambda (doc)
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
544 ;; The value nil is a placeholder; otherwise, the
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
545 ;; following string may be compiled as a docstring,
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
546 ;; and not a return value for the function.
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
547 ;; In interpreted lisp form they are
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
548 ;; indistinguishable; it only matters for compiled
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
549 ;; forms.
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
550 nil
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
551 "&rest args")))
16969
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
552 ))
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
553
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
554 (defun eldoc-function-argstring-from-docstring (fn)
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
555 (let ((docstring (documentation fn 'raw))
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
556 (table eldoc-function-argstring-from-docstring-method-table)
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
557 (doc nil)
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
558 (doclist nil))
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
559 (save-match-data
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
560 (while table
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
561 (cond ((funcall (car (car table)) docstring fn)
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
562 (setq doc (funcall (car (cdr (car table))) docstring))
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
563 (setq table nil))
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
564 (t
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
565 (setq table (cdr table)))))
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
566
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
567 (cond ((not (stringp doc))
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
568 nil)
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
569 ((string-match "&" doc)
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
570 (let ((p 0)
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
571 (l (length doc)))
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
572 (while (< p l)
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
573 (cond ((string-match "[ \t\n]+" doc p)
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
574 (setq doclist
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
575 (cons (substring doc p (match-beginning 0))
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
576 doclist))
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
577 (setq p (match-end 0)))
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
578 (t
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
579 (setq doclist (cons (substring doc p) doclist))
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
580 (setq p l))))
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
581 (eldoc-function-argstring-format (nreverse doclist))))
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
582 (t
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
583 (concat "(" (funcall eldoc-argument-case doc) ")"))))))
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
584
436fd36233d1 Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents: 16385
diff changeset
585
16996
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
586 ;; When point is in a sexp, the function args are not reprinted in the echo
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
587 ;; area after every possible interactive command because some of them print
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
588 ;; their own messages in the echo area; the eldoc functions would instantly
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
589 ;; overwrite them unless it is more restrained.
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
590 ;; These functions do display-command table management.
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
591
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
592 (defun eldoc-add-command (&rest cmds)
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
593 (or eldoc-message-commands
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
594 (setq eldoc-message-commands
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
595 (make-vector eldoc-message-commands-table-size 0)))
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
596
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
597 (let (name sym)
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
598 (while cmds
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
599 (setq name (car cmds))
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
600 (setq cmds (cdr cmds))
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
601
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
602 (cond ((symbolp name)
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
603 (setq sym name)
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
604 (setq name (symbol-name sym)))
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
605 ((stringp name)
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
606 (setq sym (intern-soft name))))
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
607
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
608 (and (symbolp sym)
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
609 (fboundp sym)
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
610 (set (intern name eldoc-message-commands) t)))))
13530
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
611
16996
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
612 (defun eldoc-add-command-completions (&rest names)
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
613 (while names
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
614 (apply 'eldoc-add-command
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
615 (all-completions (car names) obarray 'fboundp))
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
616 (setq names (cdr names))))
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
617
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
618 (defun eldoc-remove-command (&rest cmds)
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
619 (let (name)
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
620 (while cmds
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
621 (setq name (car cmds))
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
622 (setq cmds (cdr cmds))
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
623
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
624 (and (symbolp name)
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
625 (setq name (symbol-name name)))
13530
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
626
16996
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
627 (if (fboundp 'unintern)
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
628 (unintern name eldoc-message-commands)
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
629 (let ((s (intern-soft name eldoc-message-commands)))
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
630 (and s
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
631 (makunbound s)))))))
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
632
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
633 (defun eldoc-remove-command-completions (&rest names)
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
634 (while names
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
635 (apply 'eldoc-remove-command
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
636 (all-completions (car names) eldoc-message-commands))
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
637 (setq names (cdr names))))
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
638
23283
2442a5dce1a8 (eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents: 18699
diff changeset
639
16996
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
640 ;; Prime the command list.
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
641 (eldoc-add-command-completions
2d67501c45b9 (eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents: 16975
diff changeset
642 "backward-" "beginning-of-" "delete-other-windows" "delete-window"
17920
161cc8316f98 (eldoc-message-commands): Move docstring into comments, since this isn't
Noah Friedman <friedman@splode.com>
parents: 17445
diff changeset
643 "end-of-" "forward-" "indent-for-tab-command" "goto-" "mouse-set-point"
161cc8316f98 (eldoc-message-commands): Move docstring into comments, since this isn't
Noah Friedman <friedman@splode.com>
parents: 17445
diff changeset
644 "next-" "other-window" "previous-" "recenter" "scroll-"
18699
c6cf53a7da72 [top level]: Add `up-list' and `down-list' to eldoc-message-commands.
Noah Friedman <friedman@splode.com>
parents: 17920
diff changeset
645 "self-insert-command" "split-window-"
c6cf53a7da72 [top level]: Add `up-list' and `down-list' to eldoc-message-commands.
Noah Friedman <friedman@splode.com>
parents: 17920
diff changeset
646 "up-list" "down-list")
13530
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
647
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
648 (provide 'eldoc)
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
649
625e90e74d83 Initial revision
Noah Friedman <friedman@splode.com>
parents:
diff changeset
650 ;;; eldoc.el ends here