[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [External] : Re: Does the command loop even look at the return value
From: |
Drew Adams |
Subject: |
RE: [External] : Re: Does the command loop even look at the return values of commands executed? |
Date: |
Thu, 26 Aug 2021 16:52:02 +0000 |
> > I am pretty sure that the command loop discards anything returned by
> > a command invoked via a keybinding or M-x, but I couldn't find anything
> > about it in the Elisp reference. Is that true? Is it documented
> > anywhere?
>
> Yes, we ignore the value returned by commands. No, it isn't
> documented, AFAICT.
Just for info, in case it's somehow relevant to
Marcin: There is global variable `values'.
(elisp) node `Eval' tells us:
___
Variable: values
The value of this variable is a list of the values returned by all
the expressions that were read, evaluated, and printed from buffers
(including the minibuffer) by the standard Emacs commands which do
this. (Note that this does _not_ include evaluation in ‘*ielm*’
buffers, nor evaluation using ‘C-j’, ‘C-x C-e’, and similar
evaluation commands in ‘lisp-interaction-mode’.) The elements are
ordered most recent first.
(setq x 1)
⇒ 1
(list 'A (1+ 2) auto-save-default)
⇒ (A 3 t)
values
⇒ ((A 3 t) 1 ...)
This variable is useful for referring back to values of forms
recently evaluated. It is generally a bad idea to print the value
of ‘values’ itself, since this may be very long. Instead, examine
particular elements, like this:
;; Refer to the most recent evaluation result.
(nth 0 values)
⇒ (A 3 t)
;; That put a new element on,
;; so all elements move back one.
(nth 1 values)
⇒ (A 3 t)
;; This gets the element that was next-to-most-recent
;; before this example.
(nth 3 values)
⇒ 1
___
Although it doesn't apply to `C-x C-e', it does apply
to `M-:'.
Re: Does the command loop even look at the return values of commands executed?, Marcin Borkowski, 2021/08/26