Mercurial > emacs
changeset 47529:9b53ca22ace7
(*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 ***.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 18 Sep 2002 16:01:43 +0000 |
parents | 227850832281 |
children | cfea5643ff62 |
files | lisp/ielm.el |
diffstat | 1 files changed, 73 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/ielm.el Wed Sep 18 16:01:21 2002 +0000 +++ b/lisp/ielm.el Wed Sep 18 16:01:43 2002 +0000 @@ -110,6 +110,27 @@ (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 @@ 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 @@ * \\[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 @@ 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 @@ (setq fill-paragraph-function 'lisp-fill-paragraph) ;; Value holders + (make-local-variable '*) (setq * nil) - (make-local-variable '*) + (make-local-variable '**) (setq ** nil) - (make-local-variable '**) + (make-local-variable '***) (setq *** nil) - (make-local-variable '***) (set (make-local-variable 'ielm-match-data) nil) ;; font-lock support