* Proposing elisp-eval-target for eval-last-sexp and related commands
@ 2021-08-17 16:11 Psionic K
2021-08-17 17:30 ` Eduardo Ochs
2021-08-17 18:10 ` Stefan Monnier
0 siblings, 2 replies; 6+ messages in thread
From: Psionic K @ 2021-08-17 16:11 UTC (permalink / raw)
To: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 1191 bytes --]
Proposing to patch the eslip module so that if a buffer-local
`elisp-eval-target` has been set, `eval-last-sexp` and similar commands
will execute lisp in the context of another buffer.
The use case is when developing elisp to operate on non-elisp buffers,
interacting with functionality for other languages such as when using LSP.
This change would bring buffer-based development in line with ielm's
`ielm-change-working-buffer` behavior.
While the `eval-last-sexp` commands are very ergonomic, there is no way to
direct them at another buffer without wrapping the last sexp in
`with-current-buffer`. Advising deep into `eval-last-sexp` is difficult
because we must call `set-buffer` after computing the elisp we want to
evaluate.
With this support available, the users can then update the buffer local in
shortcut commands for buffer-based development of elisp for other modes.
I intend to develop a patch. The main difficulty I can identify so far is
setting the buffer at the correct points so that the setup for evaluation
continues to occur in the correct context.
--
Psionic K <psionik@positron.solutions>
Software Engineer
*Positron Solutions <https://positron.solutions>*
[-- Attachment #2: Type: text/html, Size: 1914 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Proposing elisp-eval-target for eval-last-sexp and related commands
2021-08-17 16:11 Proposing elisp-eval-target for eval-last-sexp and related commands Psionic K
@ 2021-08-17 17:30 ` Eduardo Ochs
2021-08-18 5:22 ` Psionic K
2021-08-17 18:10 ` Stefan Monnier
1 sibling, 1 reply; 6+ messages in thread
From: Eduardo Ochs @ 2021-08-17 17:30 UTC (permalink / raw)
To: Psionic K; +Cc: Emacs developers
[-- Attachment #1: Type: text/plain, Size: 1631 bytes --]
Have you considered the possibility of implementing a _variant_ of
eval-last-sexp that does what you want? That's what I do in eev... take a
look at the section "0. How to use this" of this tutorial:
http://angg.twu.net/eev-intros/find-lexical-intro.html
Cheers,
Eduardo Ochs
http://angg.twu.net/#eev
On Tue, 17 Aug 2021, 13:41 Psionic K, <psionik@positron.solutions> wrote:
> Proposing to patch the eslip module so that if a buffer-local
> `elisp-eval-target` has been set, `eval-last-sexp` and similar commands
> will execute lisp in the context of another buffer.
>
> The use case is when developing elisp to operate on non-elisp buffers,
> interacting with functionality for other languages such as when using LSP.
>
> This change would bring buffer-based development in line with ielm's
> `ielm-change-working-buffer` behavior.
>
> While the `eval-last-sexp` commands are very ergonomic, there is no way to
> direct them at another buffer without wrapping the last sexp in
> `with-current-buffer`. Advising deep into `eval-last-sexp` is difficult
> because we must call `set-buffer` after computing the elisp we want to
> evaluate.
>
> With this support available, the users can then update the buffer local in
> shortcut commands for buffer-based development of elisp for other modes.
>
> I intend to develop a patch. The main difficulty I can identify so far is
> setting the buffer at the correct points so that the setup for evaluation
> continues to occur in the correct context.
>
> --
> Psionic K <psionik@positron.solutions>
> Software Engineer
>
> *Positron Solutions <https://positron.solutions>*
>
[-- Attachment #2: Type: text/html, Size: 2848 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Proposing elisp-eval-target for eval-last-sexp and related commands
2021-08-17 17:30 ` Eduardo Ochs
@ 2021-08-18 5:22 ` Psionic K
0 siblings, 0 replies; 6+ messages in thread
From: Psionic K @ 2021-08-18 5:22 UTC (permalink / raw)
To: Eduardo Ochs; +Cc: Psionic K, Emacs developers
[-- Attachment #1: Type: text/plain, Size: 2151 bytes --]
Yes, I did consider redefining the functions in my package, but monkey
patching emacs internal api's can't be good for maintenance. Because ielm
supports this behavior, the change would bring buffer-based development to
parity with ielm, making emacs itself more consistent.
On Wed, Aug 18, 2021 at 1:30 AM Eduardo Ochs <eduardoochs@gmail.com> wrote:
> Have you considered the possibility of implementing a _variant_ of
> eval-last-sexp that does what you want? That's what I do in eev... take a
> look at the section "0. How to use this" of this tutorial:
> http://angg.twu.net/eev-intros/find-lexical-intro.html
>
> Cheers,
> Eduardo Ochs
> http://angg.twu.net/#eev
>
>
>
> On Tue, 17 Aug 2021, 13:41 Psionic K, <psionik@positron.solutions> wrote:
>
>> Proposing to patch the eslip module so that if a buffer-local
>> `elisp-eval-target` has been set, `eval-last-sexp` and similar commands
>> will execute lisp in the context of another buffer.
>>
>> The use case is when developing elisp to operate on non-elisp buffers,
>> interacting with functionality for other languages such as when using LSP.
>>
>> This change would bring buffer-based development in line with ielm's
>> `ielm-change-working-buffer` behavior.
>>
>> While the `eval-last-sexp` commands are very ergonomic, there is no way
>> to direct them at another buffer without wrapping the last sexp in
>> `with-current-buffer`. Advising deep into `eval-last-sexp` is difficult
>> because we must call `set-buffer` after computing the elisp we want to
>> evaluate.
>>
>> With this support available, the users can then update the buffer local
>> in shortcut commands for buffer-based development of elisp for other modes.
>>
>> I intend to develop a patch. The main difficulty I can identify so far
>> is setting the buffer at the correct points so that the setup for
>> evaluation continues to occur in the correct context.
>>
>> --
>> Psionic K <psionik@positron.solutions>
>> Software Engineer
>>
>> *Positron Solutions <https://positron.solutions>*
>>
>
--
Psionic K <psionik@positron.solutions>
Software Engineer
*Positron Solutions <https://positron.solutions>*
[-- Attachment #2: Type: text/html, Size: 4422 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Proposing elisp-eval-target for eval-last-sexp and related commands
2021-08-17 16:11 Proposing elisp-eval-target for eval-last-sexp and related commands Psionic K
2021-08-17 17:30 ` Eduardo Ochs
@ 2021-08-17 18:10 ` Stefan Monnier
2021-08-18 5:19 ` Psionic K
1 sibling, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2021-08-17 18:10 UTC (permalink / raw)
To: Psionic K; +Cc: emacs-devel
Psionic K [2021-08-18 00:11:01] wrote:
> Proposing to patch the eslip module so that if a buffer-local
> `elisp-eval-target` has been set, `eval-last-sexp` and similar commands
> will execute lisp in the context of another buffer.
>
> The use case is when developing elisp to operate on non-elisp buffers,
> interacting with functionality for other languages such as when using LSP.
`M-x ielm` lets you do just that.
Having a dedicated buffer also lets it print the result more comfortably
and show the "target buffer" in the mode line.
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Proposing elisp-eval-target for eval-last-sexp and related commands
2021-08-17 18:10 ` Stefan Monnier
@ 2021-08-18 5:19 ` Psionic K
2021-08-21 14:37 ` Stefan Monnier
0 siblings, 1 reply; 6+ messages in thread
From: Psionic K @ 2021-08-18 5:19 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Psionic K, emacs-devel
[-- Attachment #1: Type: text/plain, Size: 1303 bytes --]
Indeed ielm is my workflow for this use case. When I shared a shortcut on
Reddit for the `ielm-change-working-buffer` solution, it was obvious that
many users have a strong preference for working in an elisp major mode
buffer. I can't provide a shortcut however because the `eval-last-sexp`
style functions don't have any `working-buffer` concept like the ielm
implementation. The change I'm proposing will allow the extremely low
friction of the ielm solution but with the freedom of an elisp major mode
buffer.
On Wed, Aug 18, 2021 at 2:11 AM Stefan Monnier <monnier@iro.umontreal.ca>
wrote:
> Psionic K [2021-08-18 00:11:01] wrote:
> > Proposing to patch the eslip module so that if a buffer-local
> > `elisp-eval-target` has been set, `eval-last-sexp` and similar commands
> > will execute lisp in the context of another buffer.
> >
> > The use case is when developing elisp to operate on non-elisp buffers,
> > interacting with functionality for other languages such as when using
> LSP.
>
> `M-x ielm` lets you do just that.
>
> Having a dedicated buffer also lets it print the result more comfortably
> and show the "target buffer" in the mode line.
>
>
> Stefan
>
>
--
Psionic K <psionik@positron.solutions>
Software Engineer
*Positron Solutions <https://positron.solutions>*
[-- Attachment #2: Type: text/html, Size: 2507 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Proposing elisp-eval-target for eval-last-sexp and related commands
2021-08-18 5:19 ` Psionic K
@ 2021-08-21 14:37 ` Stefan Monnier
0 siblings, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2021-08-21 14:37 UTC (permalink / raw)
To: Psionic K; +Cc: emacs-devel
> Indeed ielm is my workflow for this use case. When I shared a shortcut on
> Reddit for the `ielm-change-working-buffer` solution, it was obvious that
> many users have a strong preference for working in an elisp major mode
> buffer. I can't provide a shortcut however because the `eval-last-sexp`
> style functions don't have any `working-buffer` concept like the ielm
> implementation. The change I'm proposing will allow the extremely low
> friction of the ielm solution but with the freedom of an elisp major mode
> buffer.
I see. I don't use `eval-last-sexp` often enough to have a clear idea
of what the impact of that patch would be in practice, so I'll let
others judge.
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-08-21 14:37 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-17 16:11 Proposing elisp-eval-target for eval-last-sexp and related commands Psionic K
2021-08-17 17:30 ` Eduardo Ochs
2021-08-18 5:22 ` Psionic K
2021-08-17 18:10 ` Stefan Monnier
2021-08-18 5:19 ` Psionic K
2021-08-21 14:37 ` Stefan Monnier
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).