[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Info-mode patch
From: |
Juri Linkov |
Subject: |
Re: Info-mode patch |
Date: |
Tue, 04 Jul 2023 20:51:00 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) |
>>> (defun info-menu-wrapper ()
>>> (interactive)
>>> (let ((window (info-window)))
>>> (with-current-buffer (window-buffer window)
>>> (let ((args (eval (cadr (interactive-form 'Info-menu)))))
>>> (with-selected-window window
>>> (apply #'Info-menu args))))))
>>>
>>> I would still take it with a grain of salt that it will do in all cases, you
>>> should test each and every, but in majority cases it should work I think.
>>
>> If you prefer calling the original command from the body
>
> I am callling the function, not the command, on purpose.
>
>> then better to use 'call-interactively'. 'interactive-form' is
>> more suitable for being called from the interactive spec of the wrapper.
>
> Sounds like a complication to me, but I am not as advanced with
> elisp. Anyway according to the docs interactive-form returns what it
> says, the interactive form, which as I understand, can be evaled
> separately in another context to create the list of args one can just
> pass to the function and not risk extra prompts. I am sure it is
> possible to do it in more complicated ways then the above too.
It would be inconsistent to call interactive-form in the body.
Better to do this in the interactive spec:
(defun info-menu-wrapper (window &rest args)
(interactive
(let ((window (info-window)))
(with-current-buffer (window-buffer window)
(cons window (eval (cadr (interactive-form 'Info-menu)))))))
(with-selected-window window
(apply #'Info-menu args)))
> If there was an option to say to Emacs that prompts should always stay
> on the frame where a command loop is initiated, then the gymnastics with
> wrapping interactive-from into target buffer could be skipped, and new
> commands would only need to wrap their body into with-selected-window.
Such option could be added to the third argument of the interactive spec.
There is a new feature added in Emacs 28 where the second argument defines
to which mode the command is applicable, for example, Info-mode:
(interactive "P" Info-mode)
The third argument could define which window the command should select.
For example:
(interactive "P" Info-mode (info-window))
Re: Info-mode patch, Arthur Miller, 2023/07/02
- Re: Info-mode patch, Juri Linkov, 2023/07/03
- Re: Info-mode patch, Arthur Miller, 2023/07/03
- Re: Info-mode patch, Juri Linkov, 2023/07/04
- Re: Info-mode patch, Arthur Miller, 2023/07/04
- Re: Info-mode patch,
Juri Linkov <=
- Re: Info-mode patch, Arthur Miller, 2023/07/04
- Re: Info-mode patch, Juri Linkov, 2023/07/05
- Re: Info-mode patch, Arthur Miller, 2023/07/05