diff options
author | Richard M. Stallman <rms@gnu.org> | 2002-09-18 16:01:43 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 2002-09-18 16:01:43 +0000 |
commit | 5d9655bb64d6da68b13ff15a4ae555264b771402 (patch) | |
tree | 752b758f96262296397ed86d810c3edd42d4559e /lisp/ielm.el | |
parent | 8eb525031430fb01a1b367595f248a7d39f9c05c (diff) | |
download | emacs-5d9655bb64d6da68b13ff15a4ae555264b771402.tar.gz |
(*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 ***.
Diffstat (limited to 'lisp/ielm.el')
-rw-r--r-- | lisp/ielm.el | 102 |
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." (defvar ielm-match-data nil "Match data saved at the end of last command.") +(defvar ielm-*1 nil + "During IELM evaluation, most recent value evaluated in IELM. +Normally identical to `*'. However, if the working buffer is an IELM +buffer, distinct from the process buffer, then `*' gives the value in +the working buffer, `*1' the value in the process buffer. +The intended value is only accessible during IELM evaluation.") + +(defvar *2 nil + "During IELM evaluation, second-most-recent value evaluated in IELM. +Normally identical to `**'. However, if the working buffer is an IELM +buffer, distinct from the process buffer, then `**' gives the value in +the working buffer, `*2' the value in the process buffer. +The intended value is only accessible during IELM evaluation.") + +(defvar *3 nil + "During IELM evaluation, third-most-recent value evaluated in IELM. +Normally identical to `***'. However, if the working buffer is an IELM +buffer, distinct from the process buffer, then `***' gives the value in +the working buffer, `*3' the value in the process buffer. +The intended value is only accessible during IELM evaluation.") + ;;; System variables (defvar ielm-working-buffer nil @@ -299,30 +320,51 @@ simply inserts a newline." ielm-error-type "IELM Error" ielm-wbuf (current-buffer)) (if (ielm-is-whitespace (substring ielm-string ielm-pos)) - ;; need this awful let convolution to work around - ;; an Emacs bug involving local vbls and let binding - (let ((*save *) - (**save **) - (***save ***)) + ;; To correctly handle the ielm-local variables *, + ;; ** and ***, we need a temporary buffer to be + ;; current at entry to the inner of the next two let + ;; forms. We need another temporary buffer to exit + ;; that same let. To avoid problems, neither of + ;; these buffers should be alive during the + ;; evaluation of ielm-form. + (let ((*1 *) + (*2 **) + (*3 ***) + ielm-temp-buffer) (set-match-data ielm-match-data) (save-excursion - (set-buffer ielm-working-buffer) - (condition-case err - (let ((* *save) - (** **save) - (*** ***save) - (ielm-obuf (current-buffer))) - (setq ielm-result (eval ielm-form)) - (setq ielm-wbuf (current-buffer)) - ;; The eval may have changed current-buffer; - ;; need to set it back here to avoid a bug - ;; in let. Don't want to use save-excursion - ;; because we want to allow changes in point. - (set-buffer ielm-obuf)) - (error (setq ielm-result (error-message-string err)) - (setq ielm-error-type "Eval error")) - (quit (setq ielm-result "Quit during evaluation") - (setq ielm-error-type "Eval error")))) + (with-temp-buffer + (condition-case err + (unwind-protect + ;; The next let form creates default + ;; bindings for *, ** and ***. But + ;; these default bindings are + ;; identical to the ielm-local + ;; bindings. Hence, during the + ;; evaluation of ielm-form, the + ;; ielm-local values are going to be + ;; used in all buffers except for + ;; other ielm buffers, which override + ;; them. Normally, the variables *1, + ;; *2 and *3 also have default + ;; bindings, which are not overridden. + (let ((* *1) + (** *2) + (*** *3)) + (kill-buffer (current-buffer)) + (set-buffer ielm-wbuf) + (setq ielm-result (eval ielm-form)) + (setq ielm-wbuf (current-buffer)) + (setq + ielm-temp-buffer + (generate-new-buffer " *ielm-temp*")) + (set-buffer ielm-temp-buffer)) + (when ielm-temp-buffer + (kill-buffer ielm-temp-buffer))) + (error (setq ielm-result (ielm-format-error err)) + (setq ielm-error-type "Eval error")) + (quit (setq ielm-result "Quit during evaluation") + (setq ielm-error-type "Eval error"))))) (setq ielm-match-data (match-data))) (setq ielm-error-type "IELM error") (setq ielm-result "More than one sexp in input")))) @@ -388,10 +430,6 @@ Uses the interface provided by `comint-mode' (which see). * \\[comint-dynamic-complete] completes Lisp symbols (or filenames, within strings), or indents the line if there is nothing to complete. -During evaluations, the values of the variables `*', `**', and `***' -are the results of the previous, second previous and third previous -evaluations respectively. - The current working buffer may be changed (with a call to `set-buffer', or with \\[ielm-change-working-buffer]), and its value is preserved between successive evaluations. In this way, expressions @@ -399,6 +437,12 @@ may be evaluated in a different buffer than the *ielm* buffer. Display the name of the working buffer with \\[ielm-print-working-buffer], or the buffer itself with \\[ielm-display-working-buffer]. +During evaluations, the values of the variables `*', `**', and `***' +are the results of the previous, second previous and third previous +evaluations respectively. If the working buffer is another IELM +buffer, then the values in the working buffer are used. The variables +`*1', `*2' and `*3', yield the process buffer values. + Expressions evaluated by IELM are not subject to `debug-on-quit' or `debug-on-error'. @@ -438,12 +482,12 @@ Customised bindings may be defined in `ielm-map', which currently contains: (setq fill-paragraph-function 'lisp-fill-paragraph) ;; Value holders - (setq * nil) (make-local-variable '*) - (setq ** nil) + (setq * nil) (make-local-variable '**) - (setq *** nil) + (setq ** nil) (make-local-variable '***) + (setq *** nil) (set (make-local-variable 'ielm-match-data) nil) ;; font-lock support |