Mercurial > emacs
annotate lisp/ielm.el @ 108485:0eeae12a33a9
Synch with Gnus trunk.
(gnus-summary-kill-thread): Use gnus-summary-mark-article instead of
g-s-m-a-as-unread to set the expirable mark. (Bug#5284)
By Andreas Seltenreich <seltenreich (at) gmx.de>.
author | Katsumi Yamaoka <yamaoka@jpl.org> |
---|---|
date | Tue, 11 May 2010 06:05:19 +0000 |
parents | 1d1d5d9bd884 |
children | 376148b31b5e |
rev | line source |
---|---|
7267 | 1 ;;; ielm.el --- interaction mode for Emacs Lisp |
14169 | 2 |
74442 | 3 ;; Copyright (C) 1994, 2001, 2002, 2003, 2004, 2005, |
106815 | 4 ;; 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
7267 | 5 |
6 ;; Author: David Smith <maa036@lancaster.ac.uk> | |
17976 | 7 ;; Maintainer: FSF |
7267 | 8 ;; Created: 25 Feb 1994 |
9 ;; Keywords: lisp | |
10 | |
11 ;; This file is part of GNU Emacs. | |
12 | |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
13 ;; GNU Emacs is free software: you can redistribute it and/or modify |
7267 | 14 ;; it under the terms of the GNU General Public License as published by |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
15 ;; the Free Software Foundation, either version 3 of the License, or |
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
16 ;; (at your option) any later version. |
7267 | 17 |
18 ;; GNU Emacs is distributed in the hope that it will be useful, | |
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 ;; GNU General Public License for more details. | |
22 | |
23 ;; You should have received a copy of the GNU General Public License | |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
7267 | 25 |
26 ;;; Commentary: | |
27 | |
7275
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
28 ;; Provides a nice interface to evaluating Emacs Lisp expressions. |
7267 | 29 ;; Input is handled by the comint package, and output is passed |
30 ;; through the pretty-printer. | |
31 | |
32 ;; To start: M-x ielm. Type C-h m in the *ielm* buffer for more info. | |
33 | |
34 ;;; Code: | |
35 | |
36 (require 'comint) | |
37 (require 'pp) | |
38 | |
39 ;;; User variables | |
40 | |
17634
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17148
diff
changeset
|
41 (defgroup ielm nil |
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17148
diff
changeset
|
42 "Interaction mode for Emacs Lisp." |
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17148
diff
changeset
|
43 :group 'lisp) |
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17148
diff
changeset
|
44 |
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17148
diff
changeset
|
45 |
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17148
diff
changeset
|
46 (defcustom ielm-noisy t |
99594
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
47 "If non-nil, IELM will beep on error." |
17634
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17148
diff
changeset
|
48 :type 'boolean |
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17148
diff
changeset
|
49 :group 'ielm) |
7267 | 50 |
55121
06d6dda8a91c
(ielm-prompt-read-only): New user option.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55104
diff
changeset
|
51 (defcustom ielm-prompt-read-only t |
06d6dda8a91c
(ielm-prompt-read-only): New user option.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55104
diff
changeset
|
52 "If non-nil, the IELM prompt is read only. |
55296
24a3d142d101
(ielm-prompt-read-only): Update docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55224
diff
changeset
|
53 The read only region includes the newline before the prompt. |
55121
06d6dda8a91c
(ielm-prompt-read-only): New user option.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55104
diff
changeset
|
54 Setting this variable does not affect existing IELM runs. |
55224
649d109f3222
(ielm-prompt-read-only, ielm-prompt): Update docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55146
diff
changeset
|
55 This works by setting the buffer-local value of `comint-prompt-read-only'. |
55296
24a3d142d101
(ielm-prompt-read-only): Update docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55224
diff
changeset
|
56 Setting that value directly affects new prompts in the current buffer. |
24a3d142d101
(ielm-prompt-read-only): Update docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55224
diff
changeset
|
57 |
24a3d142d101
(ielm-prompt-read-only): Update docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55224
diff
changeset
|
58 If this option is enabled, then the safe way to temporarily |
99594
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
59 override the read-only-ness of IELM prompts is to call |
55296
24a3d142d101
(ielm-prompt-read-only): Update docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55224
diff
changeset
|
60 `comint-kill-whole-line' or `comint-kill-region' with no |
24a3d142d101
(ielm-prompt-read-only): Update docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55224
diff
changeset
|
61 narrowing in effect. This way you will be certain that none of |
24a3d142d101
(ielm-prompt-read-only): Update docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55224
diff
changeset
|
62 the remaining prompts will be accidentally messed up. You may |
24a3d142d101
(ielm-prompt-read-only): Update docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55224
diff
changeset
|
63 wish to put something like the following in your `.emacs' file: |
24a3d142d101
(ielm-prompt-read-only): Update docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55224
diff
changeset
|
64 |
24a3d142d101
(ielm-prompt-read-only): Update docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55224
diff
changeset
|
65 \(add-hook 'ielm-mode-hook |
24a3d142d101
(ielm-prompt-read-only): Update docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55224
diff
changeset
|
66 '(lambda () |
61370
116c10e516e5
(ielm-prompt-read-only): Doc fix.
Luc Teirlinck <teirllm@auburn.edu>
parents:
59996
diff
changeset
|
67 (define-key ielm-map \"\\C-w\" 'comint-kill-region) |
55296
24a3d142d101
(ielm-prompt-read-only): Update docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55224
diff
changeset
|
68 (define-key ielm-map [C-S-backspace] |
24a3d142d101
(ielm-prompt-read-only): Update docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55224
diff
changeset
|
69 'comint-kill-whole-line))) |
24a3d142d101
(ielm-prompt-read-only): Update docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55224
diff
changeset
|
70 |
24a3d142d101
(ielm-prompt-read-only): Update docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55224
diff
changeset
|
71 If you set `comint-prompt-read-only' to t, you might wish to use |
24a3d142d101
(ielm-prompt-read-only): Update docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55224
diff
changeset
|
72 `comint-mode-hook' and `comint-mode-map' instead of |
24a3d142d101
(ielm-prompt-read-only): Update docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55224
diff
changeset
|
73 `ielm-mode-hook' and `ielm-map'. That will affect all comint |
99594
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
74 buffers, including IELM buffers. If you sometimes use IELM on |
55296
24a3d142d101
(ielm-prompt-read-only): Update docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55224
diff
changeset
|
75 text-only terminals or with `emacs -nw', you might wish to use |
24a3d142d101
(ielm-prompt-read-only): Update docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55224
diff
changeset
|
76 another binding for `comint-kill-whole-line'." |
55121
06d6dda8a91c
(ielm-prompt-read-only): New user option.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55104
diff
changeset
|
77 :type 'boolean |
06d6dda8a91c
(ielm-prompt-read-only): New user option.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55104
diff
changeset
|
78 :group 'ielm |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
56790
diff
changeset
|
79 :version "22.1") |
55121
06d6dda8a91c
(ielm-prompt-read-only): New user option.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55104
diff
changeset
|
80 |
43524
ca53e91e0186
(ielm-prompt): Allow customization; make it read-only.
Juanma Barranquero <lekktu@gmail.com>
parents:
43519
diff
changeset
|
81 (defcustom ielm-prompt "ELISP> " |
55121
06d6dda8a91c
(ielm-prompt-read-only): New user option.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55104
diff
changeset
|
82 "Prompt used in IELM. |
55224
649d109f3222
(ielm-prompt-read-only, ielm-prompt): Update docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55146
diff
changeset
|
83 Setting this variable does not affect existing IELM runs. |
55144
ab3d5c605cad
(ielm-prompt-read-only, ielm-prompt): Expand docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55135
diff
changeset
|
84 |
ab3d5c605cad
(ielm-prompt-read-only, ielm-prompt): Expand docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55135
diff
changeset
|
85 Interrupting the IELM process with \\<ielm-map>\\[comint-interrupt-subjob], |
ab3d5c605cad
(ielm-prompt-read-only, ielm-prompt): Expand docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55135
diff
changeset
|
86 and then restarting it using \\[ielm], makes the then current |
55224
649d109f3222
(ielm-prompt-read-only, ielm-prompt): Update docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55146
diff
changeset
|
87 default value affect _new_ prompts. Unless the new prompt |
55144
ab3d5c605cad
(ielm-prompt-read-only, ielm-prompt): Expand docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55135
diff
changeset
|
88 differs only in text properties from the old one, IELM will no |
ab3d5c605cad
(ielm-prompt-read-only, ielm-prompt): Expand docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55135
diff
changeset
|
89 longer recognize the old prompts. However, executing \\[ielm] |
ab3d5c605cad
(ielm-prompt-read-only, ielm-prompt): Expand docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55135
diff
changeset
|
90 does not update the prompt of an *ielm* buffer with a running process. |
55146
1a8fe9f88f09
(ielm-prompt-read-only, ielm-prompt): Minor doc fix.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55144
diff
changeset
|
91 For IELM buffers that are not called `*ielm*', you can execute |
55144
ab3d5c605cad
(ielm-prompt-read-only, ielm-prompt): Expand docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55135
diff
changeset
|
92 \\[inferior-emacs-lisp-mode] in that IELM buffer to update the value, |
ab3d5c605cad
(ielm-prompt-read-only, ielm-prompt): Expand docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55135
diff
changeset
|
93 for new prompts. This works even if the buffer has a running process." |
43524
ca53e91e0186
(ielm-prompt): Allow customization; make it read-only.
Juanma Barranquero <lekktu@gmail.com>
parents:
43519
diff
changeset
|
94 :type 'string |
55121
06d6dda8a91c
(ielm-prompt-read-only): New user option.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55104
diff
changeset
|
95 :group 'ielm) |
7267 | 96 |
55224
649d109f3222
(ielm-prompt-read-only, ielm-prompt): Update docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55146
diff
changeset
|
97 (defvar ielm-prompt-internal "ELISP> " |
649d109f3222
(ielm-prompt-read-only, ielm-prompt): Update docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55146
diff
changeset
|
98 "Stored value of `ielm-prompt' in the current IELM buffer. |
649d109f3222
(ielm-prompt-read-only, ielm-prompt): Update docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55146
diff
changeset
|
99 This is an internal variable used by IELM. Its purpose is to |
649d109f3222
(ielm-prompt-read-only, ielm-prompt): Update docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55146
diff
changeset
|
100 prevent a running IELM process from being messed up when the user |
649d109f3222
(ielm-prompt-read-only, ielm-prompt): Update docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55146
diff
changeset
|
101 customizes `ielm-prompt'.") |
649d109f3222
(ielm-prompt-read-only, ielm-prompt): Update docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55146
diff
changeset
|
102 |
17634
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17148
diff
changeset
|
103 (defcustom ielm-dynamic-return t |
99594
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
104 "Controls whether \\<ielm-map>\\[ielm-return] has intelligent behavior in IELM. |
7275
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
105 If non-nil, \\[ielm-return] evaluates input for complete sexps, or inserts a newline |
17634
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17148
diff
changeset
|
106 and indents for incomplete sexps. If nil, always inserts newlines." |
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17148
diff
changeset
|
107 :type 'boolean |
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17148
diff
changeset
|
108 :group 'ielm) |
7275
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
109 |
17634
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17148
diff
changeset
|
110 (defcustom ielm-dynamic-multiline-inputs t |
99594
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
111 "Force multiline inputs to start from column zero? |
7275
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
112 If non-nil, after entering the first line of an incomplete sexp, a newline |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
113 will be inserted after the prompt, moving the input to the next line. |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
114 This gives more frame width for large indented sexps, and allows functions |
17634
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17148
diff
changeset
|
115 such as `edebug-defun' to work with such inputs." |
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17148
diff
changeset
|
116 :type 'boolean |
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17148
diff
changeset
|
117 :group 'ielm) |
7267 | 118 |
17634
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17148
diff
changeset
|
119 (defcustom ielm-mode-hook nil |
99594
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
120 "Hooks to be run when IELM (`inferior-emacs-lisp-mode') is started." |
52446 | 121 :options '(turn-on-eldoc-mode) |
17634
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17148
diff
changeset
|
122 :type 'hook |
247c2a11843d
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
17148
diff
changeset
|
123 :group 'ielm) |
99594
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
124 (defvaralias 'inferior-emacs-lisp-mode-hook 'ielm-mode-hook) |
7267 | 125 |
21834
8ba41a7b6464
(*, **, ***): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents:
21795
diff
changeset
|
126 (defvar * nil |
8ba41a7b6464
(*, **, ***): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents:
21795
diff
changeset
|
127 "Most recent value evaluated in IELM.") |
8ba41a7b6464
(*, **, ***): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents:
21795
diff
changeset
|
128 |
8ba41a7b6464
(*, **, ***): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents:
21795
diff
changeset
|
129 (defvar ** nil |
8ba41a7b6464
(*, **, ***): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents:
21795
diff
changeset
|
130 "Second-most-recent value evaluated in IELM.") |
8ba41a7b6464
(*, **, ***): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents:
21795
diff
changeset
|
131 |
8ba41a7b6464
(*, **, ***): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents:
21795
diff
changeset
|
132 (defvar *** nil |
8ba41a7b6464
(*, **, ***): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents:
21795
diff
changeset
|
133 "Third-most-recent value evaluated in IELM.") |
32367
7c181d033dae
use lisp-mode-shared-map instead of shared-lisp-mode-map
Sam Steingold <sds@gnu.org>
parents:
30644
diff
changeset
|
134 |
43519
a604392198d7
(ielm-match-data): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43509
diff
changeset
|
135 (defvar ielm-match-data nil |
a604392198d7
(ielm-match-data): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43509
diff
changeset
|
136 "Match data saved at the end of last command.") |
a604392198d7
(ielm-match-data): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43509
diff
changeset
|
137 |
47586
86b3a5572fda
(*1): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
47551
diff
changeset
|
138 (defvar *1 nil |
47529
9b53ca22ace7
(*1, *2, *3): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
46942
diff
changeset
|
139 "During IELM evaluation, most recent value evaluated in IELM. |
9b53ca22ace7
(*1, *2, *3): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
46942
diff
changeset
|
140 Normally identical to `*'. However, if the working buffer is an IELM |
9b53ca22ace7
(*1, *2, *3): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
46942
diff
changeset
|
141 buffer, distinct from the process buffer, then `*' gives the value in |
49588
37645a051842
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49161
diff
changeset
|
142 the working buffer, `*1' the value in the process buffer. |
47529
9b53ca22ace7
(*1, *2, *3): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
46942
diff
changeset
|
143 The intended value is only accessible during IELM evaluation.") |
9b53ca22ace7
(*1, *2, *3): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
46942
diff
changeset
|
144 |
9b53ca22ace7
(*1, *2, *3): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
46942
diff
changeset
|
145 (defvar *2 nil |
9b53ca22ace7
(*1, *2, *3): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
46942
diff
changeset
|
146 "During IELM evaluation, second-most-recent value evaluated in IELM. |
9b53ca22ace7
(*1, *2, *3): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
46942
diff
changeset
|
147 Normally identical to `**'. However, if the working buffer is an IELM |
9b53ca22ace7
(*1, *2, *3): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
46942
diff
changeset
|
148 buffer, distinct from the process buffer, then `**' gives the value in |
9b53ca22ace7
(*1, *2, *3): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
46942
diff
changeset
|
149 the working buffer, `*2' the value in the process buffer. |
9b53ca22ace7
(*1, *2, *3): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
46942
diff
changeset
|
150 The intended value is only accessible during IELM evaluation.") |
9b53ca22ace7
(*1, *2, *3): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
46942
diff
changeset
|
151 |
9b53ca22ace7
(*1, *2, *3): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
46942
diff
changeset
|
152 (defvar *3 nil |
9b53ca22ace7
(*1, *2, *3): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
46942
diff
changeset
|
153 "During IELM evaluation, third-most-recent value evaluated in IELM. |
9b53ca22ace7
(*1, *2, *3): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
46942
diff
changeset
|
154 Normally identical to `***'. However, if the working buffer is an IELM |
9b53ca22ace7
(*1, *2, *3): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
46942
diff
changeset
|
155 buffer, distinct from the process buffer, then `***' gives the value in |
9b53ca22ace7
(*1, *2, *3): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
46942
diff
changeset
|
156 the working buffer, `*3' the value in the process buffer. |
9b53ca22ace7
(*1, *2, *3): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
46942
diff
changeset
|
157 The intended value is only accessible during IELM evaluation.") |
9b53ca22ace7
(*1, *2, *3): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
46942
diff
changeset
|
158 |
7267 | 159 ;;; System variables |
160 | |
161 (defvar ielm-working-buffer nil | |
7275
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
162 "Buffer in which IELM sexps will be evaluated. |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
163 This variable is buffer-local.") |
7267 | 164 |
32367
7c181d033dae
use lisp-mode-shared-map instead of shared-lisp-mode-map
Sam Steingold <sds@gnu.org>
parents:
30644
diff
changeset
|
165 (defvar ielm-header |
18400
16de434b8026
(ielm-header): Delete version and RCS header.
Richard M. Stallman <rms@gnu.org>
parents:
18387
diff
changeset
|
166 "*** Welcome to IELM *** Type (describe-mode) for help.\n" |
7275
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
167 "Message to display when IELM is started.") |
7267 | 168 |
99594
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
169 (defvar ielm-map |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
170 (let ((map (make-sparse-keymap))) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
171 (define-key map "\t" 'comint-dynamic-complete) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
172 (define-key map "\C-m" 'ielm-return) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
173 (define-key map "\C-j" 'ielm-send-input) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
174 (define-key map "\e\C-x" 'eval-defun) ; for consistency with |
106482
806e9f7990d8
* minibuffer.el (completion-at-point-functions): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105798
diff
changeset
|
175 (define-key map "\e\t" 'completion-at-point) ; lisp-interaction-mode |
99594
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
176 ;; These bindings are from `lisp-mode-shared-map' -- can you inherit |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
177 ;; from more than one keymap?? |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
178 (define-key map "\e\C-q" 'indent-sexp) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
179 (define-key map "\177" 'backward-delete-char-untabify) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
180 ;; Some convenience bindings for setting the working buffer |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
181 (define-key map "\C-c\C-b" 'ielm-change-working-buffer) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
182 (define-key map "\C-c\C-f" 'ielm-display-working-buffer) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
183 (define-key map "\C-c\C-v" 'ielm-print-working-buffer) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
184 map) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
185 "Keymap for IELM mode.") |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
186 (defvaralias 'inferior-emacs-lisp-mode-map 'ielm-map) |
7267 | 187 |
12439
6141f81a80e5
(ielm-font-lock-keywords): New variable
Richard M. Stallman <rms@gnu.org>
parents:
10981
diff
changeset
|
188 (defvar ielm-font-lock-keywords |
55224
649d109f3222
(ielm-prompt-read-only, ielm-prompt): Update docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55146
diff
changeset
|
189 '(("\\(^\\*\\*\\*[^*]+\\*\\*\\*\\)\\(.*$\\)" |
20953
f3f9df46d008
Changed font-lock-reference-face to font-lock-constant-face.
Simon Marshall <simon@gnu.org>
parents:
18400
diff
changeset
|
190 (1 font-lock-comment-face) |
f3f9df46d008
Changed font-lock-reference-face to font-lock-constant-face.
Simon Marshall <simon@gnu.org>
parents:
18400
diff
changeset
|
191 (2 font-lock-constant-face))) |
99594
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
192 "Additional expressions to highlight in IELM buffers.") |
32367
7c181d033dae
use lisp-mode-shared-map instead of shared-lisp-mode-map
Sam Steingold <sds@gnu.org>
parents:
30644
diff
changeset
|
193 |
7267 | 194 ;;; Completion stuff |
195 | |
196 (defun ielm-tab nil | |
56790
80dba6d2451b
(ielm-tab, ielm-complete-symbol): Doc fix.
John Paul Wallington <jpw@pobox.com>
parents:
55296
diff
changeset
|
197 "Possibly indent the current line as Lisp code." |
7267 | 198 (interactive) |
99594
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
199 (when (or (eq (preceding-char) ?\n) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
200 (eq (char-syntax (preceding-char)) ?\s)) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
201 (ielm-indent-line) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
202 t)) |
32367
7c181d033dae
use lisp-mode-shared-map instead of shared-lisp-mode-map
Sam Steingold <sds@gnu.org>
parents:
30644
diff
changeset
|
203 |
7267 | 204 (defun ielm-complete-symbol nil |
56790
80dba6d2451b
(ielm-tab, ielm-complete-symbol): Doc fix.
John Paul Wallington <jpw@pobox.com>
parents:
55296
diff
changeset
|
205 "Complete the Lisp symbol before point." |
7275
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
206 ;; A wrapper for lisp-complete symbol that returns non-nil if |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
207 ;; completion has occurred |
7267 | 208 (let* ((btick (buffer-modified-tick)) |
7842
50676390b162
(ielm-complete-symbol): Likewise.
Richard M. Stallman <rms@gnu.org>
parents:
7275
diff
changeset
|
209 (cbuffer (get-buffer "*Completions*")) |
7267 | 210 (ctick (and cbuffer (buffer-modified-tick cbuffer)))) |
211 (lisp-complete-symbol) | |
212 ;; completion has occurred if: | |
32367
7c181d033dae
use lisp-mode-shared-map instead of shared-lisp-mode-map
Sam Steingold <sds@gnu.org>
parents:
30644
diff
changeset
|
213 (or |
7267 | 214 ;; the buffer has been modified |
32367
7c181d033dae
use lisp-mode-shared-map instead of shared-lisp-mode-map
Sam Steingold <sds@gnu.org>
parents:
30644
diff
changeset
|
215 (not (= btick (buffer-modified-tick))) |
14040 | 216 ;; a completions buffer has been modified or created |
7267 | 217 (if cbuffer |
218 (not (= ctick (buffer-modified-tick cbuffer))) | |
7842
50676390b162
(ielm-complete-symbol): Likewise.
Richard M. Stallman <rms@gnu.org>
parents:
7275
diff
changeset
|
219 (get-buffer "*Completions*"))))) |
7267 | 220 |
221 (defun ielm-complete-filename nil | |
7275
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
222 "Dynamically complete filename before point, if in a string." |
99594
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
223 (when (nth 3 (parse-partial-sexp comint-last-input-start (point))) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
224 (comint-dynamic-complete-filename))) |
32367
7c181d033dae
use lisp-mode-shared-map instead of shared-lisp-mode-map
Sam Steingold <sds@gnu.org>
parents:
30644
diff
changeset
|
225 |
7267 | 226 (defun ielm-indent-line nil |
7275
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
227 "Indent the current line as Lisp code if it is not a prompt line." |
30644
ce7385745191
(ielm-indent-line): Detect a "prompt" line by seeing if comint-bol
Miles Bader <miles@gnu.org>
parents:
21834
diff
changeset
|
228 (when (save-excursion (comint-bol) (bolp)) |
7267 | 229 (lisp-indent-line))) |
230 | |
7275
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
231 ;;; Working buffer manipulation |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
232 |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
233 (defun ielm-print-working-buffer nil |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
234 "Print the current IELM working buffer's name in the echo area." |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
235 (interactive) |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
236 (message "The current working buffer is: %s" (buffer-name ielm-working-buffer))) |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
237 |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
238 (defun ielm-display-working-buffer nil |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
239 "Display the current IELM working buffer. |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
240 Don't forget that selecting that buffer will change its value of `point' |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
241 to its value of `window-point'!" |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
242 (interactive) |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
243 (display-buffer ielm-working-buffer) |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
244 (ielm-print-working-buffer)) |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
245 |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
246 (defun ielm-change-working-buffer (buf) |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
247 "Change the current IELM working buffer to BUF. |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
248 This is the buffer in which all sexps entered at the IELM prompt are |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
249 evaluated. You can achieve the same effect with a call to |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
250 `set-buffer' at the IELM prompt." |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
251 (interactive "bSet working buffer to: ") |
99594
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
252 (let ((buffer (get-buffer buf))) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
253 (if (and buffer (buffer-live-p buffer)) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
254 (setq ielm-working-buffer buffer) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
255 (error "No such buffer: %S" buf))) |
7275
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
256 (ielm-print-working-buffer)) |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
257 |
7267 | 258 ;;; Other bindings |
259 | |
260 (defun ielm-return nil | |
7275
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
261 "Newline and indent, or evaluate the sexp before the prompt. |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
262 Complete sexps are evaluated; for incomplete sexps inserts a newline |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
263 and indents. If however `ielm-dynamic-return' is nil, this always |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
264 simply inserts a newline." |
7267 | 265 (interactive) |
32367
7c181d033dae
use lisp-mode-shared-map instead of shared-lisp-mode-map
Sam Steingold <sds@gnu.org>
parents:
30644
diff
changeset
|
266 (if ielm-dynamic-return |
7c181d033dae
use lisp-mode-shared-map instead of shared-lisp-mode-map
Sam Steingold <sds@gnu.org>
parents:
30644
diff
changeset
|
267 (let ((state |
7267 | 268 (save-excursion |
269 (end-of-line) | |
270 (parse-partial-sexp (ielm-pm) | |
271 (point))))) | |
272 (if (and (< (car state) 1) (not (nth 3 state))) | |
273 (ielm-send-input) | |
99594
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
274 (when (and ielm-dynamic-multiline-inputs |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
275 (save-excursion |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
276 (beginning-of-line) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
277 (looking-at-p comint-prompt-regexp))) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
278 (save-excursion |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
279 (goto-char (ielm-pm)) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
280 (newline 1))) |
7267 | 281 (newline-and-indent))) |
282 (newline))) | |
283 | |
17978
1471676365ac
(ielm-input): New defvar.
Richard M. Stallman <rms@gnu.org>
parents:
17976
diff
changeset
|
284 (defvar ielm-input) |
1471676365ac
(ielm-input): New defvar.
Richard M. Stallman <rms@gnu.org>
parents:
17976
diff
changeset
|
285 |
7267 | 286 (defun ielm-input-sender (proc input) |
32367
7c181d033dae
use lisp-mode-shared-map instead of shared-lisp-mode-map
Sam Steingold <sds@gnu.org>
parents:
30644
diff
changeset
|
287 ;; Just sets the variable ielm-input, which is in the scope of |
7275
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
288 ;; `ielm-send-input's call. |
7267 | 289 (setq ielm-input input)) |
290 | |
291 (defun ielm-send-input nil | |
7275
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
292 "Evaluate the Emacs Lisp expression after the prompt." |
7267 | 293 (interactive) |
55224
649d109f3222
(ielm-prompt-read-only, ielm-prompt): Update docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55146
diff
changeset
|
294 (let (ielm-input) ; set by ielm-input-sender |
7267 | 295 (comint-send-input) ; update history, markers etc. |
296 (ielm-eval-input ielm-input))) | |
297 | |
298 ;;; Utility functions | |
299 | |
91851
59ebf26b96e4
2008-02-15 Lawrence Mitchell <wence@gmx.li> (tiny change)
Bastien Guerry <bzg@altern.org>
parents:
87649
diff
changeset
|
300 (defun ielm-is-whitespace-or-comment (string) |
91877
66415e9a068a
* ielm.el (ielm-is-whitespace-or-comment): Docstring fix.
Bastien Guerry <bzg@altern.org>
parents:
91851
diff
changeset
|
301 "Return non-nil if STRING is all whitespace or a comment." |
99594
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
302 (or (string= string "") |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
303 (string-match-p "\\`[ \t\n]*\\(?:;.*\\)*\\'" string))) |
7267 | 304 |
305 ;;; Evaluation | |
306 | |
7275
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
307 (defun ielm-eval-input (ielm-string) |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
308 "Evaluate the Lisp expression IELM-STRING, and pretty-print the result." |
7267 | 309 ;; This is the function that actually `sends' the input to the |
7275
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
310 ;; `inferior Lisp process'. All comint-send-input does is works out |
7267 | 311 ;; what that input is. What this function does is evaluates that |
312 ;; input and produces `output' which gets inserted into the buffer, | |
313 ;; along with a new prompt. A better way of doing this might have | |
314 ;; been to actually send the output to the `cat' process, and write | |
315 ;; this as in output filter that converted sexps in the output | |
316 ;; stream to their evaluated value. But that would have involved | |
317 ;; more process coordination than I was happy to deal with. | |
7275
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
318 ;; |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
319 ;; NOTE: all temporary variables in this function will be in scope |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
320 ;; during the eval, and so need to have non-clashing names. |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
321 (let (ielm-form ; form to evaluate |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
322 ielm-pos ; End posn of parse in string |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
323 ielm-result ; Result, or error message |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
324 ielm-error-type ; string, nil if no error |
99594
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
325 (ielm-output "") ; result to display |
7275
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
326 (ielm-wbuf ielm-working-buffer) ; current buffer after evaluation |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
327 (ielm-pmark (ielm-pm))) |
99594
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
328 (unless (ielm-is-whitespace-or-comment ielm-string) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
329 (condition-case err |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
330 (let ((rout (read-from-string ielm-string))) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
331 (setq ielm-form (car rout) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
332 ielm-pos (cdr rout))) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
333 (error (setq ielm-result (error-message-string err)) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
334 (setq ielm-error-type "Read error"))) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
335 (unless ielm-error-type |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
336 ;; Make sure working buffer has not been killed |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
337 (if (not (buffer-name ielm-working-buffer)) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
338 (setq ielm-result "Working buffer has been killed" |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
339 ielm-error-type "IELM Error" |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
340 ielm-wbuf (current-buffer)) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
341 (if (ielm-is-whitespace-or-comment (substring ielm-string ielm-pos)) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
342 ;; To correctly handle the ielm-local variables *, |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
343 ;; ** and ***, we need a temporary buffer to be |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
344 ;; current at entry to the inner of the next two let |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
345 ;; forms. We need another temporary buffer to exit |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
346 ;; that same let. To avoid problems, neither of |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
347 ;; these buffers should be alive during the |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
348 ;; evaluation of ielm-form. |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
349 (let ((*1 *) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
350 (*2 **) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
351 (*3 ***) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
352 ielm-temp-buffer) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
353 (set-match-data ielm-match-data) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
354 (save-excursion |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
355 (with-temp-buffer |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
356 (condition-case err |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
357 (unwind-protect |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
358 ;; The next let form creates default |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
359 ;; bindings for *, ** and ***. But |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
360 ;; these default bindings are |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
361 ;; identical to the ielm-local |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
362 ;; bindings. Hence, during the |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
363 ;; evaluation of ielm-form, the |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
364 ;; ielm-local values are going to be |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
365 ;; used in all buffers except for |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
366 ;; other ielm buffers, which override |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
367 ;; them. Normally, the variables *1, |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
368 ;; *2 and *3 also have default |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
369 ;; bindings, which are not overridden. |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
370 (let ((* *1) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
371 (** *2) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
372 (*** *3)) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
373 (kill-buffer (current-buffer)) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
374 (set-buffer ielm-wbuf) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
375 (setq ielm-result (eval ielm-form)) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
376 (setq ielm-wbuf (current-buffer)) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
377 (setq |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
378 ielm-temp-buffer |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
379 (generate-new-buffer " *ielm-temp*")) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
380 (set-buffer ielm-temp-buffer)) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
381 (when ielm-temp-buffer |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
382 (kill-buffer ielm-temp-buffer))) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
383 (error (setq ielm-result (error-message-string err)) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
384 (setq ielm-error-type "Eval error")) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
385 (quit (setq ielm-result "Quit during evaluation") |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
386 (setq ielm-error-type "Eval error"))))) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
387 (setq ielm-match-data (match-data))) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
388 (setq ielm-error-type "IELM error") |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
389 (setq ielm-result "More than one sexp in input")))) |
7267 | 390 |
99594
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
391 ;; If the eval changed the current buffer, mention it here |
99630
c69e966c8062
(ielm-eval-input): Fix thinko in last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
99594
diff
changeset
|
392 (unless (eq ielm-wbuf ielm-working-buffer) |
99594
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
393 (message "current buffer is now: %s" ielm-wbuf) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
394 (setq ielm-working-buffer ielm-wbuf)) |
7267 | 395 |
99594
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
396 (goto-char ielm-pmark) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
397 (unless ielm-error-type |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
398 (condition-case err |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
399 ;; Self-referential objects cause loops in the printer, so |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
400 ;; trap quits here. May as well do errors, too |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
401 (setq ielm-output (concat ielm-output (pp-to-string ielm-result))) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
402 (error (setq ielm-error-type "IELM Error") |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
403 (setq ielm-result "Error during pretty-printing (bug in pp)")) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
404 (quit (setq ielm-error-type "IELM Error") |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
405 (setq ielm-result "Quit during pretty-printing")))) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
406 (if ielm-error-type |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
407 (progn |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
408 (when ielm-noisy (ding)) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
409 (setq ielm-output (concat ielm-output "*** " ielm-error-type " *** ")) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
410 (setq ielm-output (concat ielm-output ielm-result))) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
411 ;; There was no error, so shift the *** values |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
412 (setq *** **) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
413 (setq ** *) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
414 (setq * ielm-result)) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
415 (setq ielm-output (concat ielm-output "\n"))) |
55224
649d109f3222
(ielm-prompt-read-only, ielm-prompt): Update docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55146
diff
changeset
|
416 (setq ielm-output (concat ielm-output ielm-prompt-internal)) |
7275
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
417 (comint-output-filter (ielm-process) ielm-output))) |
7267 | 418 |
419 ;;; Process and marker utilities | |
420 | |
421 (defun ielm-process nil | |
7275
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
422 ;; Return the current buffer's process. |
7267 | 423 (get-buffer-process (current-buffer))) |
424 | |
425 (defun ielm-pm nil | |
7275
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
426 ;; Return the process mark of the current buffer. |
7267 | 427 (process-mark (get-buffer-process (current-buffer)))) |
428 | |
429 (defun ielm-set-pm (pos) | |
7275
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
430 ;; Set the process mark in the current buffer to POS. |
7267 | 431 (set-marker (process-mark (get-buffer-process (current-buffer))) pos)) |
432 | |
433 ;;; Major mode | |
434 | |
99594
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
435 (define-derived-mode inferior-emacs-lisp-mode comint-mode "IELM" |
7275
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
436 "Major mode for interactively evaluating Emacs Lisp expressions. |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
437 Uses the interface provided by `comint-mode' (which see). |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
438 |
47969
cdc87bc8e049
(inferior-emacs-lisp-mode): If hexl not found, use cat. point-min != 1.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47626
diff
changeset
|
439 * \\<ielm-map>\\[ielm-send-input] evaluates the sexp following the prompt. There must be at most |
cdc87bc8e049
(inferior-emacs-lisp-mode): If hexl not found, use cat. point-min != 1.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47626
diff
changeset
|
440 one top level sexp per prompt. |
7267 | 441 |
7275
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
442 * \\[ielm-return] inserts a newline and indents, or evaluates a |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
443 complete expression (but see variable `ielm-dynamic-return'). |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
444 Inputs longer than one line are moved to the line following the |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
445 prompt (but see variable `ielm-dynamic-multiline-inputs'). |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
446 |
32367
7c181d033dae
use lisp-mode-shared-map instead of shared-lisp-mode-map
Sam Steingold <sds@gnu.org>
parents:
30644
diff
changeset
|
447 * \\[comint-dynamic-complete] completes Lisp symbols (or filenames, within strings), |
7275
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
448 or indents the line if there is nothing to complete. |
7267 | 449 |
99594
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
450 The current working buffer may be changed (with a call to `set-buffer', |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
451 or with \\[ielm-change-working-buffer]), and its value is preserved between successive |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
452 evaluations. In this way, expressions may be evaluated in a different |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
453 buffer than the *ielm* buffer. By default, its name is shown on the |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
454 mode line; you can always display it with \\[ielm-print-working-buffer], or the buffer itself |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
455 with \\[ielm-display-working-buffer]. |
7267 | 456 |
47529
9b53ca22ace7
(*1, *2, *3): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
46942
diff
changeset
|
457 During evaluations, the values of the variables `*', `**', and `***' |
9b53ca22ace7
(*1, *2, *3): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
46942
diff
changeset
|
458 are the results of the previous, second previous and third previous |
9b53ca22ace7
(*1, *2, *3): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
46942
diff
changeset
|
459 evaluations respectively. If the working buffer is another IELM |
9b53ca22ace7
(*1, *2, *3): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
46942
diff
changeset
|
460 buffer, then the values in the working buffer are used. The variables |
9b53ca22ace7
(*1, *2, *3): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
46942
diff
changeset
|
461 `*1', `*2' and `*3', yield the process buffer values. |
9b53ca22ace7
(*1, *2, *3): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
46942
diff
changeset
|
462 |
7275
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
463 Expressions evaluated by IELM are not subject to `debug-on-quit' or |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
464 `debug-on-error'. |
7267 | 465 |
63253
20e759335619
(ielm-dynamic-return, inferior-emacs-lisp-mode): Fix spellings in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
62875
diff
changeset
|
466 The behavior of IELM may be customized with the following variables: |
55104
60202911eed0
(inferior-emacs-lisp-mode): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
52446
diff
changeset
|
467 * To stop beeping on error, set `ielm-noisy' to nil. |
7267 | 468 * If you don't like the prompt, you can change it by setting `ielm-prompt'. |
55121
06d6dda8a91c
(ielm-prompt-read-only): New user option.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55104
diff
changeset
|
469 * If you do not like that the prompt is (by default) read-only, set |
06d6dda8a91c
(ielm-prompt-read-only): New user option.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55104
diff
changeset
|
470 `ielm-prompt-read-only' to nil. |
55104
60202911eed0
(inferior-emacs-lisp-mode): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
52446
diff
changeset
|
471 * Set `ielm-dynamic-return' to nil for bindings like `lisp-interaction-mode'. |
7267 | 472 * Entry to this mode runs `comint-mode-hook' and `ielm-mode-hook' |
473 (in that order). | |
474 | |
55104
60202911eed0
(inferior-emacs-lisp-mode): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
52446
diff
changeset
|
475 Customized bindings may be defined in `ielm-map', which currently contains: |
7267 | 476 \\{ielm-map}" |
99594
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
477 :syntax-table emacs-lisp-mode-syntax-table |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
478 |
7267 | 479 (setq comint-prompt-regexp (concat "^" (regexp-quote ielm-prompt))) |
61878
75267b99e585
(inferior-emacs-lisp-mode): Set paragraph-separate buffer locally to
Luc Teirlinck <teirllm@auburn.edu>
parents:
61370
diff
changeset
|
480 (set (make-local-variable 'paragraph-separate) "\\'") |
99594
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
481 (set (make-local-variable 'paragraph-start) comint-prompt-regexp) |
7267 | 482 (setq comint-input-sender 'ielm-input-sender) |
483 (setq comint-process-echoes nil) | |
99594
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
484 (set (make-local-variable 'comint-dynamic-complete-functions) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
485 '(ielm-tab comint-replace-by-expanded-history |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
486 ielm-complete-filename ielm-complete-symbol)) |
55224
649d109f3222
(ielm-prompt-read-only, ielm-prompt): Update docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55146
diff
changeset
|
487 (set (make-local-variable 'ielm-prompt-internal) ielm-prompt) |
649d109f3222
(ielm-prompt-read-only, ielm-prompt): Update docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55146
diff
changeset
|
488 (set (make-local-variable 'comint-prompt-read-only) ielm-prompt-read-only) |
7275
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
489 (setq comint-get-old-input 'ielm-get-old-input) |
99594
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
490 (set (make-local-variable 'comint-completion-addsuffix) '("/" . "")) |
55135
0d9ec2b24429
(inferior-emacs-lisp-mode): Display working buffer on the mode line. Bind
Juanma Barranquero <lekktu@gmail.com>
parents:
55121
diff
changeset
|
491 (setq mode-line-process '(":%s on " (:eval (buffer-name ielm-working-buffer)))) |
7267 | 492 |
99594
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
493 (set (make-local-variable 'indent-line-function) 'ielm-indent-line) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
494 (set (make-local-variable 'ielm-working-buffer) (current-buffer)) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
495 (set (make-local-variable 'fill-paragraph-function) 'lisp-fill-paragraph) |
106482
806e9f7990d8
* minibuffer.el (completion-at-point-functions): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105798
diff
changeset
|
496 (add-hook 'completion-at-point-functions |
806e9f7990d8
* minibuffer.el (completion-at-point-functions): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105798
diff
changeset
|
497 'lisp-completion-at-point nil 'local) |
7267 | 498 |
7275
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
499 ;; Value holders |
99594
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
500 (set (make-local-variable '*) nil) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
501 (set (make-local-variable '**) nil) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
502 (set (make-local-variable '***) nil) |
43519
a604392198d7
(ielm-match-data): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43509
diff
changeset
|
503 (set (make-local-variable 'ielm-match-data) nil) |
7267 | 504 |
12439
6141f81a80e5
(ielm-font-lock-keywords): New variable
Richard M. Stallman <rms@gnu.org>
parents:
10981
diff
changeset
|
505 ;; font-lock support |
99594
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
506 (set (make-local-variable 'font-lock-defaults) |
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
507 '(ielm-font-lock-keywords nil nil ((?: . "w") (?- . "w") (?* . "w")))) |
32367
7c181d033dae
use lisp-mode-shared-map instead of shared-lisp-mode-map
Sam Steingold <sds@gnu.org>
parents:
30644
diff
changeset
|
508 |
7267 | 509 ;; A dummy process to keep comint happy. It will never get any input |
46942
15fab402303e
[original idea from Luc Teirlinck <teirllm@mail.auburn.edu>]
Miles Bader <miles@gnu.org>
parents:
45833
diff
changeset
|
510 (unless (comint-check-proc (current-buffer)) |
43509
d4b9f0aaf4f7
(inferior-emacs-lisp-mode): Use hexl for the dummy process.
Jason Rumney <jasonr@gnu.org>
parents:
32367
diff
changeset
|
511 ;; Was cat, but on non-Unix platforms that might not exist, so |
d4b9f0aaf4f7
(inferior-emacs-lisp-mode): Use hexl for the dummy process.
Jason Rumney <jasonr@gnu.org>
parents:
32367
diff
changeset
|
512 ;; use hexl instead, which is part of the Emacs distribution. |
47969
cdc87bc8e049
(inferior-emacs-lisp-mode): If hexl not found, use cat. point-min != 1.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47626
diff
changeset
|
513 (condition-case nil |
cdc87bc8e049
(inferior-emacs-lisp-mode): If hexl not found, use cat. point-min != 1.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47626
diff
changeset
|
514 (start-process "ielm" (current-buffer) "hexl") |
cdc87bc8e049
(inferior-emacs-lisp-mode): If hexl not found, use cat. point-min != 1.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47626
diff
changeset
|
515 (file-error (start-process "ielm" (current-buffer) "cat"))) |
56790
80dba6d2451b
(ielm-tab, ielm-complete-symbol): Doc fix.
John Paul Wallington <jpw@pobox.com>
parents:
55296
diff
changeset
|
516 (set-process-query-on-exit-flag (ielm-process) nil) |
7267 | 517 (goto-char (point-max)) |
49588
37645a051842
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49161
diff
changeset
|
518 |
46942
15fab402303e
[original idea from Luc Teirlinck <teirllm@mail.auburn.edu>]
Miles Bader <miles@gnu.org>
parents:
45833
diff
changeset
|
519 ;; Lisp output can include raw characters that confuse comint's |
15fab402303e
[original idea from Luc Teirlinck <teirllm@mail.auburn.edu>]
Miles Bader <miles@gnu.org>
parents:
45833
diff
changeset
|
520 ;; carriage control code. |
15fab402303e
[original idea from Luc Teirlinck <teirllm@mail.auburn.edu>]
Miles Bader <miles@gnu.org>
parents:
45833
diff
changeset
|
521 (set (make-local-variable 'comint-inhibit-carriage-motion) t) |
15fab402303e
[original idea from Luc Teirlinck <teirllm@mail.auburn.edu>]
Miles Bader <miles@gnu.org>
parents:
45833
diff
changeset
|
522 |
7267 | 523 ;; Add a silly header |
524 (insert ielm-header) | |
525 (ielm-set-pm (point-max)) | |
61878
75267b99e585
(inferior-emacs-lisp-mode): Set paragraph-separate buffer locally to
Luc Teirlinck <teirllm@auburn.edu>
parents:
61370
diff
changeset
|
526 (unless comint-use-prompt-regexp |
55135
0d9ec2b24429
(inferior-emacs-lisp-mode): Display working buffer on the mode line. Bind
Juanma Barranquero <lekktu@gmail.com>
parents:
55121
diff
changeset
|
527 (let ((inhibit-read-only t)) |
0d9ec2b24429
(inferior-emacs-lisp-mode): Display working buffer on the mode line. Bind
Juanma Barranquero <lekktu@gmail.com>
parents:
55121
diff
changeset
|
528 (add-text-properties |
0d9ec2b24429
(inferior-emacs-lisp-mode): Display working buffer on the mode line. Bind
Juanma Barranquero <lekktu@gmail.com>
parents:
55121
diff
changeset
|
529 (point-min) (point-max) |
0d9ec2b24429
(inferior-emacs-lisp-mode): Display working buffer on the mode line. Bind
Juanma Barranquero <lekktu@gmail.com>
parents:
55121
diff
changeset
|
530 '(rear-nonsticky t field output inhibit-line-move-field-capture t)))) |
55224
649d109f3222
(ielm-prompt-read-only, ielm-prompt): Update docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55146
diff
changeset
|
531 (comint-output-filter (ielm-process) ielm-prompt-internal) |
7267 | 532 (set-marker comint-last-input-start (ielm-pm)) |
99594
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
533 (set-process-filter (get-buffer-process (current-buffer)) 'comint-output-filter))) |
7267 | 534 |
7275
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
535 (defun ielm-get-old-input nil |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
536 ;; Return the previous input surrounding point |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
537 (save-excursion |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
538 (beginning-of-line) |
99594
f7610a7d319c
* ielm.el (ielm-noisy, ielm-dynamic-return, ielm-mode-hook)
Juanma Barranquero <lekktu@gmail.com>
parents:
94678
diff
changeset
|
539 (unless (looking-at-p comint-prompt-regexp) |
7275
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
540 (re-search-backward comint-prompt-regexp)) |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
541 (comint-skip-prompt) |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
542 (buffer-substring (point) (progn (forward-sexp 1) (point))))) |
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
543 |
7267 | 544 ;;; User command |
545 | |
105798
0ad1fc06bfc8
* puresize.h (BASE_PURESIZE): Increase to 1470000.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
100908
diff
changeset
|
546 ;;;###autoload (add-hook 'same-window-buffer-names (purecopy "*ielm*")) |
10981
54697b892d3a
(ielm): Use pop-to-buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7842
diff
changeset
|
547 |
7275
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
548 ;;;###autoload |
7267 | 549 (defun ielm nil |
7275
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
550 "Interactively evaluate Emacs Lisp expressions. |
10981
54697b892d3a
(ielm): Use pop-to-buffer.
Richard M. Stallman <rms@gnu.org>
parents:
7842
diff
changeset
|
551 Switches to the buffer `*ielm*', or creates it if it does not exist." |
7267 | 552 (interactive) |
55144
ab3d5c605cad
(ielm-prompt-read-only, ielm-prompt): Expand docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55135
diff
changeset
|
553 (let (old-point) |
ab3d5c605cad
(ielm-prompt-read-only, ielm-prompt): Expand docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55135
diff
changeset
|
554 (unless (comint-check-proc "*ielm*") |
ab3d5c605cad
(ielm-prompt-read-only, ielm-prompt): Expand docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55135
diff
changeset
|
555 (with-current-buffer (get-buffer-create "*ielm*") |
55224
649d109f3222
(ielm-prompt-read-only, ielm-prompt): Update docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55146
diff
changeset
|
556 (unless (zerop (buffer-size)) (setq old-point (point))) |
55144
ab3d5c605cad
(ielm-prompt-read-only, ielm-prompt): Expand docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55135
diff
changeset
|
557 (inferior-emacs-lisp-mode))) |
ab3d5c605cad
(ielm-prompt-read-only, ielm-prompt): Expand docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55135
diff
changeset
|
558 (pop-to-buffer "*ielm*") |
ab3d5c605cad
(ielm-prompt-read-only, ielm-prompt): Expand docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents:
55135
diff
changeset
|
559 (when old-point (push-mark old-point)))) |
7267 | 560 |
18383 | 561 (provide 'ielm) |
562 | |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91877
diff
changeset
|
563 ;; arch-tag: ef60e4c0-9c4f-4bdb-8402-271313329790 |
7275
cd1541f4c87c
(ielm-dynamic-multiline-inputs): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7267
diff
changeset
|
564 ;;; ielm.el ends here |