From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.help Subject: Re: Finding last *Async Shell Command* buffer? Date: Thu, 25 Mar 2021 22:31:04 +0300 Message-ID: References: <8735wjp95u.fsf@zoho.eu> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="376"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/2.0.6 (2021-03-06) Cc: Help GNU Emacs To: Skip Montanaro Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Thu Mar 25 20:34:25 2021 Return-path: Envelope-to: geh-help-gnu-emacs@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 1lPVkP-000AYQ-Az for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 25 Mar 2021 20:34:25 +0100 Original-Received: from localhost ([::1]:53338 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lPVkO-0003kI-CS for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 25 Mar 2021 15:34:24 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46108) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPVjw-0003jz-0q for help-gnu-emacs@gnu.org; Thu, 25 Mar 2021 15:33:56 -0400 Original-Received: from stw1.rcdrun.com ([217.170.207.13]:35011) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPVju-00043H-1w for help-gnu-emacs@gnu.org; Thu, 25 Mar 2021 15:33:55 -0400 Original-Received: from localhost ([::ffff:41.210.143.10]) (AUTH: PLAIN securesender, TLS: TLS1.3,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA id 000000000001E1D1.00000000605CE59E.00000598; Thu, 25 Mar 2021 12:33:49 -0700 Mail-Followup-To: Skip Montanaro , Help GNU Emacs Content-Disposition: inline In-Reply-To: Received-SPF: pass client-ip=217.170.207.13; envelope-from=bugs@gnu.support; helo=stw1.rcdrun.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:128574 Archived-At: * Skip Montanaro [2021-03-25 18:53]: > > > The *Buffer List* should be sorted but if you want even > > > faster, tell me what these buffers are called exactly... > > > > To find out the buffer by listing, I would need to enter each buffer > > and review it if it is the right one. > > You forgot to answer the last bit. How are these *Async Shell Command* > buffers named? If there is just one, that is, by definition, the last > one, I believe. If some counter is incremented each time one is > created to avoid name collisions, choose the one with the largest > number. I have not inspected enough the function to understand how they are created. But I know function `generate-new-buffer' and it seem like it is created that way. It adds to the name of the buffer: (generate-new-buffer "My new buffer") → My new buffer (generate-new-buffer "My new buffer") → My new buffer<2> (generate-new-buffer "My new buffer") → My new buffer<3> (generate-new-buffer "My new buffer") → My new buffer<4> Now if I delete buffer 2 by mistake or intentionally: (kill-buffer "My new buffer<2>") what happens in the next invokation is: (generate-new-buffer "My new buffer") → My new buffer<2> So that way among hundreds of buffer is difficult to find the buffer that belongs to last invoked command. > Can you give an example of how to create one or more of these > buffers? I invoke often commands by using M-S-& or in dired with & and it is difficult to quickly find the output of last command. Sometimes is output important. > I'm not sure I've ever used an async shell before. I am launching new programs and some Emacs commands also invoke async shell. Sometimes I am using rsync as async-shell, so copy process goes without blocking the interface. Programmatically it should be easier to invoke it or I could even change the function. But I was thinking there is maybe some way to find the last async buffer. >From description form M-&: `async-shell-command': The output appears in the buffer whose name is stored in the variable ‘shell-command-buffer-name-async’. That buffer is in shell mode. Programmatically I could then make a function that changes the above value by getting instead of the available number on the end, the date or time part on the end, as that way it would be easy to parse list of buffers created and find the last one. I I then replace M-& with that new function that provides different buffer name by date/time, then it is solved. That seem like direction forward.