mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-11-27 07:37:33 +00:00
(*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 ***.
This commit is contained in:
parent
8eb5250314
commit
5d9655bb64
102
lisp/ielm.el
102
lisp/ielm.el
@ -110,6 +110,27 @@ such as `edebug-defun' to work with such inputs."
|
|||||||
(defvar ielm-match-data nil
|
(defvar ielm-match-data nil
|
||||||
"Match data saved at the end of last command.")
|
"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
|
;;; System variables
|
||||||
|
|
||||||
(defvar ielm-working-buffer nil
|
(defvar ielm-working-buffer nil
|
||||||
@ -299,30 +320,51 @@ simply inserts a newline."
|
|||||||
ielm-error-type "IELM Error"
|
ielm-error-type "IELM Error"
|
||||||
ielm-wbuf (current-buffer))
|
ielm-wbuf (current-buffer))
|
||||||
(if (ielm-is-whitespace (substring ielm-string ielm-pos))
|
(if (ielm-is-whitespace (substring ielm-string ielm-pos))
|
||||||
;; need this awful let convolution to work around
|
;; To correctly handle the ielm-local variables *,
|
||||||
;; an Emacs bug involving local vbls and let binding
|
;; ** and ***, we need a temporary buffer to be
|
||||||
(let ((*save *)
|
;; current at entry to the inner of the next two let
|
||||||
(**save **)
|
;; forms. We need another temporary buffer to exit
|
||||||
(***save ***))
|
;; 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)
|
(set-match-data ielm-match-data)
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(set-buffer ielm-working-buffer)
|
(with-temp-buffer
|
||||||
(condition-case err
|
(condition-case err
|
||||||
(let ((* *save)
|
(unwind-protect
|
||||||
(** **save)
|
;; The next let form creates default
|
||||||
(*** ***save)
|
;; bindings for *, ** and ***. But
|
||||||
(ielm-obuf (current-buffer)))
|
;; these default bindings are
|
||||||
(setq ielm-result (eval ielm-form))
|
;; identical to the ielm-local
|
||||||
(setq ielm-wbuf (current-buffer))
|
;; bindings. Hence, during the
|
||||||
;; The eval may have changed current-buffer;
|
;; evaluation of ielm-form, the
|
||||||
;; need to set it back here to avoid a bug
|
;; ielm-local values are going to be
|
||||||
;; in let. Don't want to use save-excursion
|
;; used in all buffers except for
|
||||||
;; because we want to allow changes in point.
|
;; other ielm buffers, which override
|
||||||
(set-buffer ielm-obuf))
|
;; them. Normally, the variables *1,
|
||||||
(error (setq ielm-result (error-message-string err))
|
;; *2 and *3 also have default
|
||||||
(setq ielm-error-type "Eval error"))
|
;; bindings, which are not overridden.
|
||||||
(quit (setq ielm-result "Quit during evaluation")
|
(let ((* *1)
|
||||||
(setq ielm-error-type "Eval error"))))
|
(** *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-match-data (match-data)))
|
||||||
(setq ielm-error-type "IELM error")
|
(setq ielm-error-type "IELM error")
|
||||||
(setq ielm-result "More than one sexp in input"))))
|
(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),
|
* \\[comint-dynamic-complete] completes Lisp symbols (or filenames, within strings),
|
||||||
or indents the line if there is nothing to complete.
|
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
|
The current working buffer may be changed (with a call to
|
||||||
`set-buffer', or with \\[ielm-change-working-buffer]), and its value
|
`set-buffer', or with \\[ielm-change-working-buffer]), and its value
|
||||||
is preserved between successive evaluations. In this way, expressions
|
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],
|
Display the name of the working buffer with \\[ielm-print-working-buffer],
|
||||||
or the buffer itself with \\[ielm-display-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
|
Expressions evaluated by IELM are not subject to `debug-on-quit' or
|
||||||
`debug-on-error'.
|
`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)
|
(setq fill-paragraph-function 'lisp-fill-paragraph)
|
||||||
|
|
||||||
;; Value holders
|
;; Value holders
|
||||||
(setq * nil)
|
|
||||||
(make-local-variable '*)
|
(make-local-variable '*)
|
||||||
(setq ** nil)
|
(setq * nil)
|
||||||
(make-local-variable '**)
|
(make-local-variable '**)
|
||||||
(setq *** nil)
|
(setq ** nil)
|
||||||
(make-local-variable '***)
|
(make-local-variable '***)
|
||||||
|
(setq *** nil)
|
||||||
(set (make-local-variable 'ielm-match-data) nil)
|
(set (make-local-variable 'ielm-match-data) nil)
|
||||||
|
|
||||||
;; font-lock support
|
;; font-lock support
|
||||||
|
Loading…
Reference in New Issue
Block a user