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 09:54:48 +0300 Organization: LINKOV.NET Message-ID: <86fs64maiv.fsf@mail.linkov.net> References: <86fs6ertto.fsf@mail.linkov.net> <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> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13266"; 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 08:58:57 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 1qGa01-0003If-NQ for ged-emacs-devel@m.gmane-mx.org; Tue, 04 Jul 2023 08:58:57 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGZzD-00052n-Oz; Tue, 04 Jul 2023 02:58:07 -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 1qGZzC-00052B-NI for emacs-devel@gnu.org; Tue, 04 Jul 2023 02:58:06 -0400 Original-Received: from relay7-d.mail.gandi.net ([217.70.183.200]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qGZzA-0001tw-JS for emacs-devel@gnu.org; Tue, 04 Jul 2023 02:58:06 -0400 X-GND-Sasl: juri@linkov.net X-GND-Sasl: juri@linkov.net Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 32CE320005; Tue, 4 Jul 2023 06:58:00 +0000 (UTC) In-Reply-To: (Arthur Miller's message of "Tue, 04 Jul 2023 00:24:39 +0200") Received-SPF: pass client-ip=217.70.183.200; envelope-from=juri@linkov.net; helo=relay7-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_H4=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:307403 Archived-At: >> But AFAIU, what you need is only to use with-current-buffer >> wrapped around the interactive spec? There is no need >> to select another window/frame while reading from the minibuffer? > > As said earlier, that highly depends on the work done in the interactive form; > but for the majority of commands, and those in info.el specifically, it should > be enough I believe. I agree, so commands that don't read the default value from the buffer don't need even with-current-buffer. > This works: > > (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 then better to use 'call-interactively'. 'interactive-form' is more suitable for being called from the interactive spec of the wrapper. >>> About wrapping; I agree that it is messy to go through each and every command as >>> I did to modify them, so for old existing commands, it is definitely easier to >>> do the wrapping, if possible. I just hope we get a better way for future command >>> writing. >> >> I don't like creating wrapper commands too, but it seems there is no >> better way, at least no one proposed anything better. > > You were against wrapping everything into with-selected-window, now you > everything wrapped into another function :). I still think that adding new wrapper commands is less wrong than wrapping existing commands into with-selected-window. > The positive about wrappers is they will work with old commands, and if you turn > that into a:core package in Elpa, then even users of older Emacsens can use > it. So I am definitely not against wrappers per se; nor do I believe we should > rewrite each and every user command. > > But for writing new commands, I do suggest to implement better macro; because > all this can abstracted away, so we don't double all the commands in the future. I'm not sure if this should be a new coding convention for writing new commands that should be mentioned in (info "(elisp) Programming Tips").