From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: Info-mode patch Date: Tue, 04 Jul 2023 20:51:00 +0300 Organization: LINKOV.NET Message-ID: <86sfa3bpvf.fsf@mail.linkov.net> References: <86wmzpqva6.fsf@mail.linkov.net> <867cropyh3.fsf@mail.linkov.net> <86mt0kulli.fsf@mail.linkov.net> <86wmzmzs1s.fsf@mail.linkov.net> <86edluyxhl.fsf@mail.linkov.net> <86bkgxfm34.fsf@mail.linkov.net> <86zg4gddtf.fsf@mail.linkov.net> <86v8f2xkr4.fsf@mail.linkov.net> <86v8f04yws.fsf@mail.linkov.net> <86fs64maiv.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3477"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) Cc: emacs-devel@gnu.org To: Arthur Miller Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Jul 04 19:57:06 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qGkGw-0000kn-4d for ged-emacs-devel@m.gmane-mx.org; Tue, 04 Jul 2023 19:57:06 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGkGg-0002yo-Td; Tue, 04 Jul 2023 13:56:50 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qGkGf-0002xp-4M for emacs-devel@gnu.org; Tue, 04 Jul 2023 13:56:49 -0400 Original-Received: from relay2-d.mail.gandi.net ([217.70.183.194]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qGkGc-0002wG-Sh for emacs-devel@gnu.org; Tue, 04 Jul 2023 13:56:48 -0400 X-GND-Sasl: juri@linkov.net X-GND-Sasl: juri@linkov.net Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 44DB240006; Tue, 4 Jul 2023 17:56:42 +0000 (UTC) In-Reply-To: (Arthur Miller's message of "Tue, 04 Jul 2023 11:43:38 +0200") Received-SPF: pass client-ip=217.70.183.194; envelope-from=juri@linkov.net; helo=relay2-d.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:307439 Archived-At: >>> (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))