emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Control help- and Info-mode buffers from other buffers


From: Arthur Miller
Subject: Re: Control help- and Info-mode buffers from other buffers
Date: Thu, 01 Jun 2023 05:16:41 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

Juri Linkov <juri@linkov.net> writes:

>>> since it would be nice to have a general function
>>> that will delegate key presses to any window,
>>
>> I think it is similar, but still a different problem then remotely executing 
>> commands available in other buffer. To start with there is a nice trick
>> via pre/post command hooks, someone posted to me on Reddit:
>>
>> https://www.reddit.com/r/emacs/comments/x0r0pe/share_your_otherwindow_commands/
>
> A hook-based approach looks promising.
>
> When such simplest prototype that demonstrates this solution
> conceptually works well
>
>   (progn
>     (add-hook 'pre-command-hook (lambda () (other-window 1)))
>     (add-hook 'post-command-hook (lambda () (other-window -1))))
>
> then it could be extended by adding customization, etc.
>
>> It works quite well in some cases, but not in all. For example it does not 
>> work
>> with Info-menu when invoked from other buffer either.
>
> If the code above doesn't work in all cases, this means we have a bug.

You are conceptually definitely correct :), but I believe that we are in this 
case
treating symptoms instead of the cause.

The reason we would like to send input to other-window (or any window) is to be
able to invoke some command in that window. Why can't we just invoke the command
directly, via M-x, when anything bound to a key is an interactive command by
definition? The reason is that commands are written with (or without) some
assumptions. The most notorius here is that many commands are written to act in
current buffer on selected window. It is not an unreasonable assumption, I am
just saying that commands are ordinary lisp code that can do anything, and
if they are not written with assumption to be run in some other buffer or
window, than there can be problems.I am not sure I would call it a bug, this was
just a natural assumption to make commands act on selected window and
current-buffer, but in certain cases, it is indeed a limitation, or perhaps
better to say, a noise, since it causes this extra switching between windows.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]