aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2002-09-18 16:01:43 +0000
committerRichard M. Stallman2002-09-18 16:01:43 +0000
commit5d9655bb64d6da68b13ff15a4ae555264b771402 (patch)
tree752b758f96262296397ed86d810c3edd42d4559e
parent8eb525031430fb01a1b367595f248a7d39f9c05c (diff)
downloademacs-5d9655bb64d6da68b13ff15a4ae555264b771402.tar.gz
emacs-5d9655bb64d6da68b13ff15a4ae555264b771402.zip
(*1, *2, *3): New variables.
(ielm-eval-input): Make temporary buffers current on entry and exit to the let bindings for *, ** and ***. (inferior-emacs-lisp-mode): Mention *1, *2 and *3 in the docstring. Do not overrule global bindings for *, ** and ***.
-rw-r--r--lisp/ielm.el102
1 files changed, 73 insertions, 29 deletions
diff --git a/lisp/ielm.el b/lisp/ielm.el
index 55d1e59857f..3a9e5e05743 100644
--- a/lisp/ielm.el
+++ b/lisp/ielm.el
@@ -110,6 +110,27 @@ such as `edebug-defun' to work with such inputs."
110(defvar ielm-match-data nil 110(defvar ielm-match-data nil
111 "Match data saved at the end of last command.") 111 "Match data saved at the end of last command.")
112 112
113(defvar ielm-*1 nil
114 "During IELM evaluation, most recent value evaluated in IELM.
115Normally identical to `*'. However, if the working buffer is an IELM
116buffer, distinct from the process buffer, then `*' gives the value in
117the working buffer, `*1' the value in the process buffer.
118The intended value is only accessible during IELM evaluation.")
119
120(defvar *2 nil
121 "During IELM evaluation, second-most-recent value evaluated in IELM.
122Normally identical to `**'. However, if the working buffer is an IELM
123buffer, distinct from the process buffer, then `**' gives the value in
124the working buffer, `*2' the value in the process buffer.
125The intended value is only accessible during IELM evaluation.")
126
127(defvar *3 nil
128 "During IELM evaluation, third-most-recent value evaluated in IELM.
129Normally identical to `***'. However, if the working buffer is an IELM
130buffer, distinct from the process buffer, then `***' gives the value in
131the working buffer, `*3' the value in the process buffer.
132The intended value is only accessible during IELM evaluation.")
133
113;;; System variables 134;;; System variables
114 135
115(defvar ielm-working-buffer nil 136(defvar ielm-working-buffer nil
@@ -299,30 +320,51 @@ simply inserts a newline."
299 ielm-error-type "IELM Error" 320 ielm-error-type "IELM Error"
300 ielm-wbuf (current-buffer)) 321 ielm-wbuf (current-buffer))
301 (if (ielm-is-whitespace (substring ielm-string ielm-pos)) 322 (if (ielm-is-whitespace (substring ielm-string ielm-pos))
302 ;; need this awful let convolution to work around 323 ;; To correctly handle the ielm-local variables *,
303 ;; an Emacs bug involving local vbls and let binding 324 ;; ** and ***, we need a temporary buffer to be
304 (let ((*save *) 325 ;; current at entry to the inner of the next two let
305 (**save **) 326 ;; forms. We need another temporary buffer to exit
306 (***save ***)) 327 ;; that same let. To avoid problems, neither of
328 ;; these buffers should be alive during the
329 ;; evaluation of ielm-form.
330 (let ((*1 *)
331 (*2 **)
332 (*3 ***)
333 ielm-temp-buffer)
307 (set-match-data ielm-match-data) 334 (set-match-data ielm-match-data)
308 (save-excursion 335 (save-excursion
309 (set-buffer ielm-working-buffer) 336 (with-temp-buffer
310 (condition-case err 337 (condition-case err
311 (let ((* *save) 338 (unwind-protect
312 (** **save) 339 ;; The next let form creates default
313 (*** ***save) 340 ;; bindings for *, ** and ***. But
314 (ielm-obuf (current-buffer))) 341 ;; these default bindings are
315 (setq ielm-result (eval ielm-form)) 342 ;; identical to the ielm-local
316 (setq ielm-wbuf (current-buffer)) 343 ;; bindings. Hence, during the
317 ;; The eval may have changed current-buffer; 344 ;; evaluation of ielm-form, the
318 ;; need to set it back here to avoid a bug 345 ;; ielm-local values are going to be
319 ;; in let. Don't want to use save-excursion 346 ;; used in all buffers except for
320 ;; because we want to allow changes in point. 347 ;; other ielm buffers, which override
321 (set-buffer ielm-obuf)) 348 ;; them. Normally, the variables *1,
322 (error (setq ielm-result (error-message-string err)) 349 ;; *2 and *3 also have default
323 (setq ielm-error-type "Eval error")) 350 ;; bindings, which are not overridden.
324 (quit (setq ielm-result "Quit during evaluation") 351 (let ((* *1)
325 (setq ielm-error-type "Eval error")))) 352 (** *2)
353 (*** *3))
354 (kill-buffer (current-buffer))
355 (set-buffer ielm-wbuf)
356 (setq ielm-result (eval ielm-form))
357 (setq ielm-wbuf (current-buffer))
358 (setq
359 ielm-temp-buffer
360 (generate-new-buffer " *ielm-temp*"))
361 (set-buffer ielm-temp-buffer))
362 (when ielm-temp-buffer
363 (kill-buffer ielm-temp-buffer)))
364 (error (setq ielm-result (ielm-format-error err))
365 (setq ielm-error-type "Eval error"))
366 (quit (setq ielm-result "Quit during evaluation")
367 (setq ielm-error-type "Eval error")))))
326 (setq ielm-match-data (match-data))) 368 (setq ielm-match-data (match-data)))
327 (setq ielm-error-type "IELM error") 369 (setq ielm-error-type "IELM error")
328 (setq ielm-result "More than one sexp in input")))) 370 (setq ielm-result "More than one sexp in input"))))
@@ -388,10 +430,6 @@ Uses the interface provided by `comint-mode' (which see).
388* \\[comint-dynamic-complete] completes Lisp symbols (or filenames, within strings), 430* \\[comint-dynamic-complete] completes Lisp symbols (or filenames, within strings),
389 or indents the line if there is nothing to complete. 431 or indents the line if there is nothing to complete.
390 432
391During evaluations, the values of the variables `*', `**', and `***'
392are the results of the previous, second previous and third previous
393evaluations respectively.
394
395The current working buffer may be changed (with a call to 433The current working buffer may be changed (with a call to
396`set-buffer', or with \\[ielm-change-working-buffer]), and its value 434`set-buffer', or with \\[ielm-change-working-buffer]), and its value
397is preserved between successive evaluations. In this way, expressions 435is preserved between successive evaluations. In this way, expressions
@@ -399,6 +437,12 @@ may be evaluated in a different buffer than the *ielm* buffer.
399Display the name of the working buffer with \\[ielm-print-working-buffer], 437Display the name of the working buffer with \\[ielm-print-working-buffer],
400or the buffer itself with \\[ielm-display-working-buffer]. 438or the buffer itself with \\[ielm-display-working-buffer].
401 439
440During evaluations, the values of the variables `*', `**', and `***'
441are the results of the previous, second previous and third previous
442evaluations respectively. If the working buffer is another IELM
443buffer, then the values in the working buffer are used. The variables
444`*1', `*2' and `*3', yield the process buffer values.
445
402Expressions evaluated by IELM are not subject to `debug-on-quit' or 446Expressions evaluated by IELM are not subject to `debug-on-quit' or
403`debug-on-error'. 447`debug-on-error'.
404 448
@@ -438,12 +482,12 @@ Customised bindings may be defined in `ielm-map', which currently contains:
438 (setq fill-paragraph-function 'lisp-fill-paragraph) 482 (setq fill-paragraph-function 'lisp-fill-paragraph)
439 483
440 ;; Value holders 484 ;; Value holders
441 (setq * nil)
442 (make-local-variable '*) 485 (make-local-variable '*)
443 (setq ** nil) 486 (setq * nil)
444 (make-local-variable '**) 487 (make-local-variable '**)
445 (setq *** nil) 488 (setq ** nil)
446 (make-local-variable '***) 489 (make-local-variable '***)
490 (setq *** nil)
447 (set (make-local-variable 'ielm-match-data) nil) 491 (set (make-local-variable 'ielm-match-data) nil)
448 492
449 ;; font-lock support 493 ;; font-lock support