Mercurial > emacs
annotate lisp/emacs-lisp/eldoc.el @ 53085:397404038558
Regenerated with "rm loaddefs.el; make autoloads".
This fixes default value of `button-map' where
push-button was bound to "" instead to "\r".
author | Markus Rost <rost@math.uni-bielefeld.de> |
---|---|
date | Mon, 17 Nov 2003 19:02:52 +0000 |
parents | d776a9884cef |
children | f0eb34e60705 e8824c4f5f7e |
rev | line source |
---|---|
13530 | 1 ;;; eldoc.el --- show function arglist or variable docstring in echo area |
2 | |
49018 | 3 ;; Copyright (C) 1996, 97, 98, 99, 2000, 2003 Free Software Foundation, Inc. |
13530 | 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 | 7 ;; Keywords: extensions |
8 ;; Created: 1995-10-06 | |
9 | |
52445
d776a9884cef
(eldoc-print-current-symbol-info-function):
Dave Love <fx@gnu.org>
parents:
52401
diff
changeset
|
10 ;; $Id: eldoc.el,v 1.26 2003/09/01 15:45:22 miles Exp $ |
13530 | 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 | 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 | 15 ;; it under the terms of the GNU General Public License as published by |
16 ;; the Free Software Foundation; either version 2, or (at your option) | |
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 | 20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
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 | 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 | 28 |
29 ;;; Commentary: | |
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 | 39 |
40 ;; One useful way to enable this minor mode is to put the following in your | |
41 ;; .emacs: | |
42 ;; | |
43 ;; (add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode) | |
44 ;; (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
|
45 ;; (add-hook 'ielm-mode-hook 'turn-on-eldoc-mode) |
13530 | 46 |
52445
d776a9884cef
(eldoc-print-current-symbol-info-function):
Dave Love <fx@gnu.org>
parents:
52401
diff
changeset
|
47 ;; Major modes for other languages may use Eldoc by defining an |
d776a9884cef
(eldoc-print-current-symbol-info-function):
Dave Love <fx@gnu.org>
parents:
52401
diff
changeset
|
48 ;; appropriate function as the buffer-local value of |
d776a9884cef
(eldoc-print-current-symbol-info-function):
Dave Love <fx@gnu.org>
parents:
52401
diff
changeset
|
49 ;; `eldoc-print-current-symbol-info-function'. |
d776a9884cef
(eldoc-print-current-symbol-info-function):
Dave Love <fx@gnu.org>
parents:
52401
diff
changeset
|
50 |
13530 | 51 ;;; Code: |
52 | |
48470
5a25c61f2c8b
(eldoc-print-current-symbol-info):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42623
diff
changeset
|
53 (require 'help-fns) ;For fundoc-usage handling functions. |
5a25c61f2c8b
(eldoc-print-current-symbol-info):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42623
diff
changeset
|
54 |
17445
f2db4e8bb6ed
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17253
diff
changeset
|
55 (defgroup eldoc nil |
f2db4e8bb6ed
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17253
diff
changeset
|
56 "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
|
57 :group 'lisp |
17445
f2db4e8bb6ed
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17253
diff
changeset
|
58 :group 'extensions) |
f2db4e8bb6ed
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17253
diff
changeset
|
59 |
f2db4e8bb6ed
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17253
diff
changeset
|
60 (defcustom eldoc-idle-delay 0.50 |
13530 | 61 "*Number of seconds of idle time to wait before printing. |
62 If user input arrives before this interval of time has elapsed after the | |
63 last input, no documentation will be printed. | |
64 | |
17445
f2db4e8bb6ed
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17253
diff
changeset
|
65 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
|
66 :type 'number |
f2db4e8bb6ed
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17253
diff
changeset
|
67 :group 'eldoc) |
13530 | 68 |
30389
38f19553e93d
(eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents:
23586
diff
changeset
|
69 ;;;###autoload |
17445
f2db4e8bb6ed
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17253
diff
changeset
|
70 (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
|
71 "*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
|
72 :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
|
73 :group 'eldoc) |
16969
436fd36233d1
Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents:
16385
diff
changeset
|
74 |
17445
f2db4e8bb6ed
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17253
diff
changeset
|
75 (defcustom eldoc-argument-case 'upcase |
13530 | 76 "Case to display argument names of functions, as a symbol. |
77 This has two preferred values: `upcase' or `downcase'. | |
78 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
|
79 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
|
80 :type '(radio (function-item upcase) |
38f19553e93d
(eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents:
23586
diff
changeset
|
81 (function-item downcase) |
38f19553e93d
(eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents:
23586
diff
changeset
|
82 function) |
17445
f2db4e8bb6ed
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17253
diff
changeset
|
83 :group 'eldoc) |
13530 | 84 |
30389
38f19553e93d
(eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents:
23586
diff
changeset
|
85 (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
|
86 "*Allow long eldoc messages to resize echo area display. |
50853
3a65ede5c70c
(eldoc-echo-area-use-multiline-p): Don't quote nil and t in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
49697
diff
changeset
|
87 If value is t, never attempt to truncate messages; complete symbol name |
30389
38f19553e93d
(eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents:
23586
diff
changeset
|
88 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
|
89 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
|
90 |
50853
3a65ede5c70c
(eldoc-echo-area-use-multiline-p): Don't quote nil and t in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
49697
diff
changeset
|
91 If value is any non-nil value other than t, symbol name may be truncated |
30389
38f19553e93d
(eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents:
23586
diff
changeset
|
92 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
|
93 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
|
94 former case. |
38f19553e93d
(eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents:
23586
diff
changeset
|
95 |
38f19553e93d
(eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents:
23586
diff
changeset
|
96 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
|
97 display in the echo area. Function or variable symbol name may be |
49697
eb34aebd1084
(eldoc-echo-area-multiline-supported-p, eldoc-use-idle-timer-p): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49018
diff
changeset
|
98 truncated to make more of the arglist or documentation string visible." |
30389
38f19553e93d
(eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents:
23586
diff
changeset
|
99 :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
|
100 (const :tag "Never" nil) |
38f19553e93d
(eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents:
23586
diff
changeset
|
101 (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
|
102 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
|
103 :group 'eldoc) |
38f19553e93d
(eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents:
23586
diff
changeset
|
104 |
38f19553e93d
(eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents:
23586
diff
changeset
|
105 ;;; No user options below here. |
38f19553e93d
(eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents:
23586
diff
changeset
|
106 |
17920
161cc8316f98
(eldoc-message-commands): Move docstring into comments, since this isn't
Noah Friedman <friedman@splode.com>
parents:
17445
diff
changeset
|
107 ;; 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
|
108 ;; 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
|
109 ;; 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
|
110 ;; 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
|
111 ;; 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
|
112 ;; 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
|
113 ;; 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
|
114 (defvar eldoc-message-commands nil) |
13530 | 115 |
16996
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
116 ;; 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
|
117 ;; 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
|
118 ;; 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
|
119 ;; 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
|
120 ;; 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
|
121 ;; 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
|
122 (defvar eldoc-message-commands-table-size 31) |
13530 | 123 |
23283
2442a5dce1a8
(eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents:
18699
diff
changeset
|
124 ;; 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
|
125 ;; 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
|
126 ;; 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
|
127 ;; 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
|
128 ;; 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
|
129 (defvar eldoc-last-data (make-vector 3 nil)) |
16996
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
130 (defvar eldoc-last-message nil) |
13530 | 131 |
49697
eb34aebd1084
(eldoc-echo-area-multiline-supported-p, eldoc-use-idle-timer-p): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49018
diff
changeset
|
132 ;; eldoc's timer object. |
16969
436fd36233d1
Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents:
16385
diff
changeset
|
133 (defvar eldoc-timer nil) |
436fd36233d1
Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents:
16385
diff
changeset
|
134 |
436fd36233d1
Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents:
16385
diff
changeset
|
135 ;; 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
|
136 ;; 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
|
137 (defvar eldoc-current-idle-delay eldoc-idle-delay) |
13530 | 138 |
139 | |
140 ;;;###autoload | |
41167
ae8862effdf5
(eldoc-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
34127
diff
changeset
|
141 (define-minor-mode eldoc-mode |
ae8862effdf5
(eldoc-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
34127
diff
changeset
|
142 "Toggle ElDoc mode on or off. |
ae8862effdf5
(eldoc-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
34127
diff
changeset
|
143 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
|
144 |
41167
ae8862effdf5
(eldoc-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
34127
diff
changeset
|
145 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
|
146 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
|
147 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
|
148 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
|
149 from the documentation string if possible. |
ae8862effdf5
(eldoc-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
34127
diff
changeset
|
150 |
ae8862effdf5
(eldoc-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
34127
diff
changeset
|
151 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
|
152 instead. |
ae8862effdf5
(eldoc-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
34127
diff
changeset
|
153 |
ae8862effdf5
(eldoc-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
34127
diff
changeset
|
154 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
|
155 nil eldoc-minor-mode-string nil |
16996
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
156 (setq eldoc-last-message nil) |
49697
eb34aebd1084
(eldoc-echo-area-multiline-supported-p, eldoc-use-idle-timer-p): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49018
diff
changeset
|
157 (if eldoc-mode |
eb34aebd1084
(eldoc-echo-area-multiline-supported-p, eldoc-use-idle-timer-p): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49018
diff
changeset
|
158 (progn |
eb34aebd1084
(eldoc-echo-area-multiline-supported-p, eldoc-use-idle-timer-p): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49018
diff
changeset
|
159 (add-hook 'post-command-hook 'eldoc-schedule-timer nil t) |
eb34aebd1084
(eldoc-echo-area-multiline-supported-p, eldoc-use-idle-timer-p): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49018
diff
changeset
|
160 (add-hook 'pre-command-hook 'eldoc-pre-command-refresh-echo-area t)) |
eb34aebd1084
(eldoc-echo-area-multiline-supported-p, eldoc-use-idle-timer-p): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49018
diff
changeset
|
161 (remove-hook 'post-command-hook 'eldoc-schedule-timer) |
eb34aebd1084
(eldoc-echo-area-multiline-supported-p, eldoc-use-idle-timer-p): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49018
diff
changeset
|
162 (remove-hook 'pre-command-hook 'eldoc-pre-command-refresh-echo-area))) |
13530 | 163 |
164 ;;;###autoload | |
165 (defun turn-on-eldoc-mode () | |
166 "Unequivocally turn on eldoc-mode (see variable documentation)." | |
167 (interactive) | |
168 (eldoc-mode 1)) | |
169 | |
23283
2442a5dce1a8
(eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents:
18699
diff
changeset
|
170 |
16969
436fd36233d1
Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents:
16385
diff
changeset
|
171 ;; 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
|
172 (defun eldoc-schedule-timer () |
436fd36233d1
Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents:
16385
diff
changeset
|
173 (or (and eldoc-timer |
436fd36233d1
Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents:
16385
diff
changeset
|
174 (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
|
175 (setq eldoc-timer |
436fd36233d1
Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents:
16385
diff
changeset
|
176 (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
|
177 '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
|
178 |
436fd36233d1
Update copyright notice to reflect assignment to FSF and incorporation
Noah Friedman <friedman@splode.com>
parents:
16385
diff
changeset
|
179 ;; 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
|
180 (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
|
181 (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
|
182 (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
|
183 |
23283
2442a5dce1a8
(eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents:
18699
diff
changeset
|
184 (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
|
185 (let ((omessage eldoc-last-message)) |
50853
3a65ede5c70c
(eldoc-echo-area-use-multiline-p): Don't quote nil and t in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
49697
diff
changeset
|
186 (setq eldoc-last-message |
49697
eb34aebd1084
(eldoc-echo-area-multiline-supported-p, eldoc-use-idle-timer-p): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49018
diff
changeset
|
187 (cond ((eq (car args) eldoc-last-message) eldoc-last-message) |
eb34aebd1084
(eldoc-echo-area-multiline-supported-p, eldoc-use-idle-timer-p): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49018
diff
changeset
|
188 ((null (car args)) nil) |
eb34aebd1084
(eldoc-echo-area-multiline-supported-p, eldoc-use-idle-timer-p): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49018
diff
changeset
|
189 ;; If only one arg, no formatting to do, so put it in |
eb34aebd1084
(eldoc-echo-area-multiline-supported-p, eldoc-use-idle-timer-p): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49018
diff
changeset
|
190 ;; eldoc-last-message so eq test above might succeed on |
eb34aebd1084
(eldoc-echo-area-multiline-supported-p, eldoc-use-idle-timer-p): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49018
diff
changeset
|
191 ;; subsequent calls. |
eb34aebd1084
(eldoc-echo-area-multiline-supported-p, eldoc-use-idle-timer-p): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49018
diff
changeset
|
192 ((null (cdr args)) (car args)) |
eb34aebd1084
(eldoc-echo-area-multiline-supported-p, eldoc-use-idle-timer-p): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49018
diff
changeset
|
193 (t (apply 'format args)))) |
23283
2442a5dce1a8
(eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents:
18699
diff
changeset
|
194 ;; 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
|
195 ;; 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
|
196 ;; they are Legion. |
49697
eb34aebd1084
(eldoc-echo-area-multiline-supported-p, eldoc-use-idle-timer-p): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49018
diff
changeset
|
197 ;; Emacs way of preventing log messages. |
eb34aebd1084
(eldoc-echo-area-multiline-supported-p, eldoc-use-idle-timer-p): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49018
diff
changeset
|
198 (let ((message-log-max nil)) |
eb34aebd1084
(eldoc-echo-area-multiline-supported-p, eldoc-use-idle-timer-p): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49018
diff
changeset
|
199 (cond (eldoc-last-message (message "%s" eldoc-last-message)) |
eb34aebd1084
(eldoc-echo-area-multiline-supported-p, eldoc-use-idle-timer-p): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49018
diff
changeset
|
200 (omessage (message nil))))) |
23283
2442a5dce1a8
(eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents:
18699
diff
changeset
|
201 eldoc-last-message) |
2442a5dce1a8
(eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents:
18699
diff
changeset
|
202 |
16996
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
203 ;; 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
|
204 ;; 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
|
205 ;; 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
|
206 ;; begins. This function reprints the last eldoc message immediately |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
207 ;; 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
|
208 ;; 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
|
209 (defun eldoc-pre-command-refresh-echo-area () |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
210 (and eldoc-last-message |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
211 (if (eldoc-display-message-no-interference-p) |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
212 (eldoc-message eldoc-last-message) |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
213 (setq eldoc-last-message nil)))) |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
214 |
16975
188c4da9bf5d
(eldoc-display-message-p): New function.
Noah Friedman <friedman@splode.com>
parents:
16969
diff
changeset
|
215 ;; 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
|
216 (defun eldoc-display-message-p () |
16996
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
217 (and (eldoc-display-message-no-interference-p) |
49697
eb34aebd1084
(eldoc-echo-area-multiline-supported-p, eldoc-use-idle-timer-p): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49018
diff
changeset
|
218 ;; If this-command is non-nil while running via an idle |
eb34aebd1084
(eldoc-echo-area-multiline-supported-p, eldoc-use-idle-timer-p): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49018
diff
changeset
|
219 ;; timer, we're still in the middle of executing a command, |
eb34aebd1084
(eldoc-echo-area-multiline-supported-p, eldoc-use-idle-timer-p): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49018
diff
changeset
|
220 ;; e.g. a query-replace where it would be annoying to |
eb34aebd1084
(eldoc-echo-area-multiline-supported-p, eldoc-use-idle-timer-p): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49018
diff
changeset
|
221 ;; overwrite the echo area. |
eb34aebd1084
(eldoc-echo-area-multiline-supported-p, eldoc-use-idle-timer-p): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49018
diff
changeset
|
222 (and (not this-command) |
eb34aebd1084
(eldoc-echo-area-multiline-supported-p, eldoc-use-idle-timer-p): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49018
diff
changeset
|
223 (symbolp last-command) |
eb34aebd1084
(eldoc-echo-area-multiline-supported-p, eldoc-use-idle-timer-p): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49018
diff
changeset
|
224 (intern-soft (symbol-name last-command) |
eb34aebd1084
(eldoc-echo-area-multiline-supported-p, eldoc-use-idle-timer-p): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49018
diff
changeset
|
225 eldoc-message-commands)))) |
13530 | 226 |
30389
38f19553e93d
(eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents:
23586
diff
changeset
|
227 ;; 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
|
228 ;; 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
|
229 (defun eldoc-display-message-no-interference-p () |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
230 (and eldoc-mode |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
231 (not executing-kbd-macro) |
30389
38f19553e93d
(eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents:
23586
diff
changeset
|
232 (not (and (boundp 'edebug-active) edebug-active)) |
16996
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
233 ;; 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
|
234 ;; interference with what's going on there. |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
235 (not cursor-in-echo-area) |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
236 (not (eq (selected-window) (minibuffer-window))))) |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
237 |
23283
2442a5dce1a8
(eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents:
18699
diff
changeset
|
238 |
52445
d776a9884cef
(eldoc-print-current-symbol-info-function):
Dave Love <fx@gnu.org>
parents:
52401
diff
changeset
|
239 (defvar eldoc-print-current-symbol-info-function nil |
d776a9884cef
(eldoc-print-current-symbol-info-function):
Dave Love <fx@gnu.org>
parents:
52401
diff
changeset
|
240 "If non-nil, function to call to return doc string. |
d776a9884cef
(eldoc-print-current-symbol-info-function):
Dave Love <fx@gnu.org>
parents:
52401
diff
changeset
|
241 The function of no args should return a one-line string for displaying |
d776a9884cef
(eldoc-print-current-symbol-info-function):
Dave Love <fx@gnu.org>
parents:
52401
diff
changeset
|
242 doc about a function etc. appropriate to the context around point. |
d776a9884cef
(eldoc-print-current-symbol-info-function):
Dave Love <fx@gnu.org>
parents:
52401
diff
changeset
|
243 It should return nil if there's no doc appropriate for the context. |
d776a9884cef
(eldoc-print-current-symbol-info-function):
Dave Love <fx@gnu.org>
parents:
52401
diff
changeset
|
244 Typically doc is returned if point is on a function-like name or in its |
d776a9884cef
(eldoc-print-current-symbol-info-function):
Dave Love <fx@gnu.org>
parents:
52401
diff
changeset
|
245 arg list. |
d776a9884cef
(eldoc-print-current-symbol-info-function):
Dave Love <fx@gnu.org>
parents:
52401
diff
changeset
|
246 |
d776a9884cef
(eldoc-print-current-symbol-info-function):
Dave Love <fx@gnu.org>
parents:
52401
diff
changeset
|
247 This variable is expected to be made buffer-local by modes (other than |
d776a9884cef
(eldoc-print-current-symbol-info-function):
Dave Love <fx@gnu.org>
parents:
52401
diff
changeset
|
248 Emacs Lisp mode) that support Eldoc.") |
d776a9884cef
(eldoc-print-current-symbol-info-function):
Dave Love <fx@gnu.org>
parents:
52401
diff
changeset
|
249 |
23283
2442a5dce1a8
(eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents:
18699
diff
changeset
|
250 (defun eldoc-print-current-symbol-info () |
48470
5a25c61f2c8b
(eldoc-print-current-symbol-info):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42623
diff
changeset
|
251 (condition-case err |
5a25c61f2c8b
(eldoc-print-current-symbol-info):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42623
diff
changeset
|
252 (and (eldoc-display-message-p) |
52445
d776a9884cef
(eldoc-print-current-symbol-info-function):
Dave Love <fx@gnu.org>
parents:
52401
diff
changeset
|
253 (if eldoc-print-current-symbol-info-function |
d776a9884cef
(eldoc-print-current-symbol-info-function):
Dave Love <fx@gnu.org>
parents:
52401
diff
changeset
|
254 (eldoc-message (funcall eldoc-print-current-symbol-info-function)) |
d776a9884cef
(eldoc-print-current-symbol-info-function):
Dave Love <fx@gnu.org>
parents:
52401
diff
changeset
|
255 (let* ((current-symbol (eldoc-current-symbol)) |
d776a9884cef
(eldoc-print-current-symbol-info-function):
Dave Love <fx@gnu.org>
parents:
52401
diff
changeset
|
256 (current-fnsym (eldoc-fnsym-in-current-sexp)) |
d776a9884cef
(eldoc-print-current-symbol-info-function):
Dave Love <fx@gnu.org>
parents:
52401
diff
changeset
|
257 (doc (cond |
d776a9884cef
(eldoc-print-current-symbol-info-function):
Dave Love <fx@gnu.org>
parents:
52401
diff
changeset
|
258 ((eq current-symbol current-fnsym) |
d776a9884cef
(eldoc-print-current-symbol-info-function):
Dave Love <fx@gnu.org>
parents:
52401
diff
changeset
|
259 (or (eldoc-get-fnsym-args-string current-fnsym) |
d776a9884cef
(eldoc-print-current-symbol-info-function):
Dave Love <fx@gnu.org>
parents:
52401
diff
changeset
|
260 (eldoc-get-var-docstring current-symbol))) |
d776a9884cef
(eldoc-print-current-symbol-info-function):
Dave Love <fx@gnu.org>
parents:
52401
diff
changeset
|
261 (t |
d776a9884cef
(eldoc-print-current-symbol-info-function):
Dave Love <fx@gnu.org>
parents:
52401
diff
changeset
|
262 (or (eldoc-get-var-docstring current-symbol) |
d776a9884cef
(eldoc-print-current-symbol-info-function):
Dave Love <fx@gnu.org>
parents:
52401
diff
changeset
|
263 (eldoc-get-fnsym-args-string current-fnsym)))))) |
d776a9884cef
(eldoc-print-current-symbol-info-function):
Dave Love <fx@gnu.org>
parents:
52401
diff
changeset
|
264 (eldoc-message doc)))) |
48470
5a25c61f2c8b
(eldoc-print-current-symbol-info):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42623
diff
changeset
|
265 ;; This is run from post-command-hook or some idle timer thing, |
5a25c61f2c8b
(eldoc-print-current-symbol-info):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42623
diff
changeset
|
266 ;; so we need to be careful that errors aren't ignored. |
5a25c61f2c8b
(eldoc-print-current-symbol-info):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42623
diff
changeset
|
267 (error (message "eldoc error: %s" err)))) |
23283
2442a5dce1a8
(eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents:
18699
diff
changeset
|
268 |
2442a5dce1a8
(eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents:
18699
diff
changeset
|
269 ;; 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
|
270 ;; 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
|
271 ;; docstring or elsewhere. |
2442a5dce1a8
(eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents:
18699
diff
changeset
|
272 (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
|
273 (let ((args nil) |
2442a5dce1a8
(eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents:
18699
diff
changeset
|
274 (doc nil)) |
49697
eb34aebd1084
(eldoc-echo-area-multiline-supported-p, eldoc-use-idle-timer-p): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49018
diff
changeset
|
275 (cond ((not (and sym (symbolp sym) (fboundp sym)))) |
23283
2442a5dce1a8
(eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents:
18699
diff
changeset
|
276 ((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
|
277 (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
|
278 (setq doc (aref eldoc-last-data 1))) |
48470
5a25c61f2c8b
(eldoc-print-current-symbol-info):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42623
diff
changeset
|
279 ((setq doc (help-split-fundoc (documentation sym t) sym)) |
5a25c61f2c8b
(eldoc-print-current-symbol-info):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42623
diff
changeset
|
280 (setq args (car doc)) |
5a25c61f2c8b
(eldoc-print-current-symbol-info):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42623
diff
changeset
|
281 (string-match "\\`[^ )]* ?" args) |
5a25c61f2c8b
(eldoc-print-current-symbol-info):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42623
diff
changeset
|
282 (setq args (concat "(" (substring args (match-end 0))))) |
13530 | 283 (t |
23283
2442a5dce1a8
(eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents:
18699
diff
changeset
|
284 (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
|
285 (cond (args |
2442a5dce1a8
(eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents:
18699
diff
changeset
|
286 (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
|
287 (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
|
288 doc)) |
2442a5dce1a8
(eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents:
18699
diff
changeset
|
289 |
2442a5dce1a8
(eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents:
18699
diff
changeset
|
290 ;; 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
|
291 ;; the variable. |
2442a5dce1a8
(eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents:
18699
diff
changeset
|
292 (defun eldoc-get-var-docstring (sym) |
49017
09ff6e632947
(eldoc-get-var-docstring): Only return a
John Paul Wallington <jpw@pobox.com>
parents:
48470
diff
changeset
|
293 (when sym |
09ff6e632947
(eldoc-get-var-docstring): Only return a
John Paul Wallington <jpw@pobox.com>
parents:
48470
diff
changeset
|
294 (cond ((and (eq sym (aref eldoc-last-data 0)) |
09ff6e632947
(eldoc-get-var-docstring): Only return a
John Paul Wallington <jpw@pobox.com>
parents:
48470
diff
changeset
|
295 (eq 'variable (aref eldoc-last-data 2))) |
09ff6e632947
(eldoc-get-var-docstring): Only return a
John Paul Wallington <jpw@pobox.com>
parents:
48470
diff
changeset
|
296 (aref eldoc-last-data 1)) |
09ff6e632947
(eldoc-get-var-docstring): Only return a
John Paul Wallington <jpw@pobox.com>
parents:
48470
diff
changeset
|
297 (t |
09ff6e632947
(eldoc-get-var-docstring): Only return a
John Paul Wallington <jpw@pobox.com>
parents:
48470
diff
changeset
|
298 (let ((doc (documentation-property sym 'variable-documentation t))) |
09ff6e632947
(eldoc-get-var-docstring): Only return a
John Paul Wallington <jpw@pobox.com>
parents:
48470
diff
changeset
|
299 (cond (doc |
09ff6e632947
(eldoc-get-var-docstring): Only return a
John Paul Wallington <jpw@pobox.com>
parents:
48470
diff
changeset
|
300 (setq doc (eldoc-docstring-format-sym-doc |
09ff6e632947
(eldoc-get-var-docstring): Only return a
John Paul Wallington <jpw@pobox.com>
parents:
48470
diff
changeset
|
301 sym (eldoc-docstring-first-line doc))) |
09ff6e632947
(eldoc-get-var-docstring): Only return a
John Paul Wallington <jpw@pobox.com>
parents:
48470
diff
changeset
|
302 (eldoc-last-data-store sym doc 'variable))) |
09ff6e632947
(eldoc-get-var-docstring): Only return a
John Paul Wallington <jpw@pobox.com>
parents:
48470
diff
changeset
|
303 doc))))) |
23283
2442a5dce1a8
(eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents:
18699
diff
changeset
|
304 |
2442a5dce1a8
(eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents:
18699
diff
changeset
|
305 (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
|
306 (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
|
307 (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
|
308 (aset eldoc-last-data 2 type)) |
13530 | 309 |
23283
2442a5dce1a8
(eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents:
18699
diff
changeset
|
310 ;; 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
|
311 ;; 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
|
312 (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
|
313 (and (stringp doc) |
2442a5dce1a8
(eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents:
18699
diff
changeset
|
314 (substitute-command-keys |
2442a5dce1a8
(eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents:
18699
diff
changeset
|
315 (save-match-data |
2442a5dce1a8
(eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents:
18699
diff
changeset
|
316 (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
|
317 (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
|
318 (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
|
319 ((zerop start) doc) |
2442a5dce1a8
(eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents:
18699
diff
changeset
|
320 (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
|
321 |
2442a5dce1a8
(eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents:
18699
diff
changeset
|
322 ;; 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
|
323 ;; 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
|
324 ;; description. |
2442a5dce1a8
(eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents:
18699
diff
changeset
|
325 (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
|
326 (save-match-data |
2442a5dce1a8
(eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents:
18699
diff
changeset
|
327 (let* ((name (symbol-name sym)) |
49697
eb34aebd1084
(eldoc-echo-area-multiline-supported-p, eldoc-use-idle-timer-p): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49018
diff
changeset
|
328 (ea-multi eldoc-echo-area-use-multiline-p) |
30389
38f19553e93d
(eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents:
23586
diff
changeset
|
329 ;; 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
|
330 ;; 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
|
331 ;; 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
|
332 (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
|
333 (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
|
334 (cond ((or (<= strip 0) |
38f19553e93d
(eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents:
23586
diff
changeset
|
335 (eq ea-multi t) |
38f19553e93d
(eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents:
23586
diff
changeset
|
336 (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
|
337 (format "%s: %s" sym doc)) |
38f19553e93d
(eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents:
23586
diff
changeset
|
338 ((> (length doc) ea-width) |
38f19553e93d
(eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents:
23586
diff
changeset
|
339 (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
|
340 ((>= strip (length name)) |
38f19553e93d
(eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents:
23586
diff
changeset
|
341 (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
|
342 (t |
30389
38f19553e93d
(eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents:
23586
diff
changeset
|
343 ;; 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
|
344 ;; 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
|
345 ;; 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
|
346 (setq name (substring name strip)) |
38f19553e93d
(eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents:
23586
diff
changeset
|
347 (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
|
348 |
2442a5dce1a8
(eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents:
18699
diff
changeset
|
349 |
13530 | 350 (defun eldoc-fnsym-in-current-sexp () |
16996
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
351 (let ((p (point))) |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
352 (eldoc-beginning-of-sexp) |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
353 (prog1 |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
354 ;; 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
|
355 (if (= (or (char-after (1- (point))) 0) ?\") |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
356 nil |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
357 (eldoc-current-symbol)) |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
358 (goto-char p)))) |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
359 |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
360 (defun eldoc-beginning-of-sexp () |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
361 (let ((parse-sexp-ignore-comments t)) |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
362 (condition-case err |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
363 (while (progn |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
364 (forward-sexp -1) |
48470
5a25c61f2c8b
(eldoc-print-current-symbol-info):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42623
diff
changeset
|
365 (or (= (char-before) ?\") |
16996
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
366 (> (point) (point-min))))) |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
367 (error nil)))) |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
368 |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
369 ;; returns nil unless current word is an interned symbol. |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
370 (defun eldoc-current-symbol () |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
371 (let ((c (char-after (point)))) |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
372 (and c |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
373 (memq (char-syntax c) '(?w ?_)) |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
374 (intern-soft (current-word))))) |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
375 |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
376 ;; Do indirect function resolution if possible. |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
377 (defun eldoc-symbol-function (fsym) |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
378 (let ((defn (and (fboundp fsym) |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
379 (symbol-function fsym)))) |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
380 (and (symbolp defn) |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
381 (condition-case err |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
382 (setq defn (indirect-function fsym)) |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
383 (error (setq defn nil)))) |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
384 defn)) |
13530 | 385 |
30389
38f19553e93d
(eldoc-minor-mode-string): Add autoload cookie; otherwise autoloaded
Noah Friedman <friedman@splode.com>
parents:
23586
diff
changeset
|
386 (defun eldoc-function-argstring (fn) |
48470
5a25c61f2c8b
(eldoc-print-current-symbol-info):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42623
diff
changeset
|
387 (eldoc-function-argstring-format (help-function-arglist fn))) |
13530 | 388 |
389 (defun eldoc-function-argstring-format (arglist) | |
390 (cond ((not (listp arglist)) | |
391 (setq arglist nil)) | |
392 ((symbolp (car arglist)) | |
393 (setq arglist | |
394 (mapcar (function (lambda (s) | |
395 (if (memq s '(&optional &rest)) | |
396 (symbol-name s) | |
397 (funcall eldoc-argument-case | |
398 (symbol-name s))))) | |
399 arglist))) | |
400 ((stringp (car arglist)) | |
401 (setq arglist | |
402 (mapcar (function (lambda (s) | |
403 (if (member s '("&optional" "&rest")) | |
404 s | |
405 (funcall eldoc-argument-case s)))) | |
406 arglist)))) | |
407 (concat "(" (mapconcat 'identity arglist " ") ")")) | |
408 | |
409 | |
16996
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
410 ;; 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
|
411 ;; 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
|
412 ;; 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
|
413 ;; overwrite them unless it is more restrained. |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
414 ;; These functions do display-command table management. |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
415 |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
416 (defun eldoc-add-command (&rest cmds) |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
417 (or eldoc-message-commands |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
418 (setq eldoc-message-commands |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
419 (make-vector eldoc-message-commands-table-size 0))) |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
420 |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
421 (let (name sym) |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
422 (while cmds |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
423 (setq name (car cmds)) |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
424 (setq cmds (cdr cmds)) |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
425 |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
426 (cond ((symbolp name) |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
427 (setq sym name) |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
428 (setq name (symbol-name sym))) |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
429 ((stringp name) |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
430 (setq sym (intern-soft name)))) |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
431 |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
432 (and (symbolp sym) |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
433 (fboundp sym) |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
434 (set (intern name eldoc-message-commands) t))))) |
13530 | 435 |
16996
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
436 (defun eldoc-add-command-completions (&rest names) |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
437 (while names |
49697
eb34aebd1084
(eldoc-echo-area-multiline-supported-p, eldoc-use-idle-timer-p): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49018
diff
changeset
|
438 (apply 'eldoc-add-command |
eb34aebd1084
(eldoc-echo-area-multiline-supported-p, eldoc-use-idle-timer-p): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49018
diff
changeset
|
439 (all-completions (car names) obarray 'fboundp)) |
eb34aebd1084
(eldoc-echo-area-multiline-supported-p, eldoc-use-idle-timer-p): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49018
diff
changeset
|
440 (setq names (cdr names)))) |
16996
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
441 |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
442 (defun eldoc-remove-command (&rest cmds) |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
443 (let (name) |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
444 (while cmds |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
445 (setq name (car cmds)) |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
446 (setq cmds (cdr cmds)) |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
447 |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
448 (and (symbolp name) |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
449 (setq name (symbol-name name))) |
13530 | 450 |
49697
eb34aebd1084
(eldoc-echo-area-multiline-supported-p, eldoc-use-idle-timer-p): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49018
diff
changeset
|
451 (unintern name eldoc-message-commands)))) |
16996
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
452 |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
453 (defun eldoc-remove-command-completions (&rest names) |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
454 (while names |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
455 (apply 'eldoc-remove-command |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
456 (all-completions (car names) eldoc-message-commands)) |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
457 (setq names (cdr names)))) |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
458 |
23283
2442a5dce1a8
(eldoc-message): Check for 1-arg case, and store string in
Noah Friedman <friedman@splode.com>
parents:
18699
diff
changeset
|
459 |
16996
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
460 ;; Prime the command list. |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
461 (eldoc-add-command-completions |
2d67501c45b9
(eldoc-message-commands): Doc fixes.
Noah Friedman <friedman@splode.com>
parents:
16975
diff
changeset
|
462 "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
|
463 "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
|
464 "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
|
465 "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
|
466 "up-list" "down-list") |
13530 | 467 |
468 (provide 'eldoc) | |
469 | |
52401 | 470 ;;; arch-tag: c9a58f9d-2055-46c1-9b82-7248b71a8375 |
13530 | 471 ;;; eldoc.el ends here |