From: Arthur Miller <arthur.miller@live.com>
To: Juri Linkov <juri@linkov.net>
Cc: emacs-devel@gnu.org
Subject: Re: Info-mode patch
Date: Wed, 28 Jun 2023 01:09:57 +0200 [thread overview]
Message-ID: <AM9PR09MB497725FDB052AA56DE2084D49627A@AM9PR09MB4977.eurprd09.prod.outlook.com> (raw)
In-Reply-To: <867cropyh3.fsf@mail.linkov.net> (Juri Linkov's message of "Tue, 27 Jun 2023 21:11:04 +0300")
Juri Linkov <juri@linkov.net> writes:
>>> But it seems this is not enough because with-selected-frame
>>> still fails to switch focus to another frame. You need also
>>> to use select-frame-set-input-focus.
>> Where it fails? For me it prompts me on correct frame. I didn't want to switch
>> focus on the info frame. I am aware of select-frame-set-input-focus, have used
>> it in some test actually.
>
> Probably the behaviour depends on the window manager.
Yes, I am quite sure it isn't "probably" but "surely" :), as I wrote earlier by
the way.
> With my window manager with-selected-frame displays
> the prompt in another frame, but input is inserted
> into the original buffer. Maybe we should have
> a new option whether to use select-frame-set-input-focus?
I am not sure I understand what you mean with input being inserted in the
original buffer.
>> Have you tested *everything*? Interactively and from lisp?
>
> I see no problems with this both interactively and from lisp:
If you don't care to ask the user which window to choose when ambigous, then you
don't have to care about this at all. If you don't want to take care of
multiple windows with possibly ambigous names, user misstyping a name and
possibly irregular name, then you don't need to prompt the user at all, just
take the first info buffer you find or force user to *always* select manually a
window and you are all good. But in my opinion it is not hard to have it slightly
more polished and automated as I did.
> #+begin_src emacs-lisp
> (defmacro with-selected-window-frame (window &rest body)
> `(let ((old-frame (selected-frame))
> (frame (window-frame ,window)))
> (unless (eq frame old-frame)
> (select-frame frame 'norecord)
> (select-frame-set-input-focus frame 'norecord))
> (prog1 (with-selected-window ,window
> ,@body)
> (select-frame old-frame 'norecord)
> (select-frame-set-input-focus old-frame 'norecord))))
>
> (defun Info-index-other-window (topic &optional window)
> (interactive
> (with-selected-window-frame (info-window)
> (append (eval (cadr (interactive-form 'Info-index)))
> (list (selected-window)))))
> (with-selected-window (or window (info-window))
> (Info-index topic)))
> #+end_src
>
> You can't avoid adding the window argument. Otherwise, you need
> to invent such hacks as sending the window selected by the user
> to the command body via a symbol property.
> But in the wrapper command like above there is no problem
> of adding the window argument to the new command.
I wasn't familiar with interactive form enough and didn't know how to connect
the optional argument from within interactive form. Symbol-plist was just
workaround for lack of a better knowledge :). I stated that explicitly in the
mail with the patch, but you perhaps didn't have time to read the mail?
Anyway, I understand now how is it done:
(append (eval (cadr (interactive-form 'Info-index)))
(list (selected-window)))
I have to return a list of all arguments from interactive form; it was that
simple. Thanks for the example.
> Maybe it's possible even to write a macro that will generate
> such wrapper commands automatically from existing commands.
>
> It seems you assume that all commands should take a window.
Why would I assume that? I wrote explicitly which commands were extended with
an optional window argument and why. I don't feel for repeating entire text here,
if you have interest, please take a look at the original email, you don't seem
to have read it all. That mail answered your opening question, but I didn't want
to point it out earlier to not sound impolite, instead I tried to clarify the
problems and choices further.
> But there are no such assumption for most commands that work
> only in the selected window.
I am not sure what you are trying to say here. If we have several live buffers
and wish to act on one, then the user has to choose one somehow, no? We can
either try to automate stuff as I have tried in this patch, by prompting the
user in ambigous case when system can't figure it on its own, or we can have a
dumb system that forces user to *always* select a window prior to acting on a
buffer. If you take a look at the original mail you will understand which commands
has got the optional window argument and why, but if you don't prompt the user,
than you don't need that argument at all.
There is also a problem of prompting and input focus. As I wrote in response to
Eli, each command is its own little program, and can prompt user for whatever
reason whenever. Thus each command should be written with the assumption that
input should be presented to user on the frame where user types and with
assumption that user is not executing it from the buffer/window on which it
should act. You can achieve all this with tools already in Emacs, no need to
introduce any new concepts or macros, and it will also work regardless of the
window manager (I think).
It is just that the old commands are not written with those assumptions, so I
rewrote Info commands in this patch. I am not sure you can achive that
with wrapping, but perhaps there is a way, you can try.
In my opinion wrapping is OK if we for some reason can't alter the code, but in
the case of Info and help mode, I don't see such reason, especially since it is
possible to do everything backwards compatible. On the negative side,
wrapping introduces double set of commands, so what are you saving? You are
wrapping code from "outside", while I have done it from "inside", but overall,
the principle is the same. On a plus side for wrappers is that you can actually
write a codegen for wrappers, hopefully in form of a macro and it will work for
other modes. So it is not only negatives, but you could also have both
approaches at the same time too :).
next prev parent reply other threads:[~2023-06-27 23:09 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-26 16:09 Info-mode patch Arthur Miller
2023-06-26 17:56 ` Juri Linkov
2023-06-26 20:17 ` Arthur Miller
2023-06-27 6:32 ` Juri Linkov
2023-06-27 7:54 ` Arthur Miller
2023-06-27 18:11 ` Juri Linkov
2023-06-27 23:09 ` Arthur Miller [this message]
2023-06-28 6:50 ` Juri Linkov
2023-06-28 21:52 ` Arthur Miller
2023-06-29 6:44 ` Juri Linkov
2023-06-29 12:42 ` Arthur Miller
2023-06-29 15:00 ` [External] : " Drew Adams
2023-06-29 16:24 ` Arthur Miller
2023-06-29 17:44 ` Juri Linkov
2023-06-29 22:28 ` Arthur Miller
2023-06-30 7:13 ` Juri Linkov
2023-06-30 8:41 ` Arthur Miller
2023-06-30 17:57 ` Juri Linkov
2023-07-01 9:11 ` Arthur Miller
2023-07-02 17:53 ` Juri Linkov
2023-07-02 18:39 ` Eli Zaretskii
2023-07-02 22:43 ` Arthur Miller
2023-07-03 11:46 ` Eli Zaretskii
2023-07-03 12:57 ` Arthur Miller
2023-07-03 13:17 ` Eli Zaretskii
2023-07-03 18:40 ` Juri Linkov
2023-07-03 18:57 ` Eli Zaretskii
2023-07-04 6:50 ` easy-menu-define keys for key-valid-p (was: Info-mode patch) Juri Linkov
2023-07-04 11:33 ` Eli Zaretskii
2023-07-03 21:07 ` Info-mode patch Arthur Miller
2023-07-04 7:59 ` Andreas Schwab
2023-07-04 8:44 ` Arthur Miller
2023-07-03 17:07 ` Eli Zaretskii
2023-07-04 23:58 ` Stefan Monnier
2023-07-08 8:14 ` Eli Zaretskii
2023-07-02 22:05 ` Arthur Miller
2023-07-03 18:45 ` Juri Linkov
2023-07-03 22:24 ` Arthur Miller
2023-07-04 6:54 ` Juri Linkov
2023-07-04 9:43 ` Arthur Miller
2023-07-04 17:51 ` Juri Linkov
2023-07-04 21:40 ` Arthur Miller
2023-07-05 6:17 ` Juri Linkov
2023-07-05 14:25 ` Arthur Miller
2023-07-01 9:59 ` Getting Gnus to highlight citations in long mails (was: Info-mode patch) Kévin Le Gouguec
2023-07-01 12:40 ` Getting Gnus to highlight citations in long mails Arthur Miller
2023-07-02 17:56 ` Juri Linkov
2023-06-27 11:45 ` Info-mode patch Eli Zaretskii
2023-06-27 12:15 ` Arthur Miller
2023-06-27 12:42 ` Eli Zaretskii
2023-06-27 15:28 ` Arthur Miller
2023-06-27 16:03 ` Eli Zaretskii
2023-06-27 16:33 ` Arthur Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AM9PR09MB497725FDB052AA56DE2084D49627A@AM9PR09MB4977.eurprd09.prod.outlook.com \
--to=arthur.miller@live.com \
--cc=emacs-devel@gnu.org \
--cc=juri@linkov.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).