From mboxrd@z Thu Jan  1 00:00:00 1970
Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail
From: Eli Zaretskii <eliz@gnu.org>
Newsgroups: gmane.emacs.help
Subject: Re: Finding last *Async Shell Command* buffer?
Date: Fri, 26 Mar 2021 14:31:17 +0300
Message-ID: <83v99ep2wq.fsf@gnu.org>
References: <87k0puihrd.fsf@robertthorpeconsulting.com>
 <83a6qqqulz.fsf@gnu.org> <YF2Kd/TqHJdOK9Zb@protected.localdomain>
 <834kgyqrtm.fsf@gnu.org> <YF2TH1TEOkEoPj1B@protected.localdomain>
Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214";
	logging-data="1790"; mail-complaints-to="usenet@ciao.gmane.io"
To: help-gnu-emacs@gnu.org
Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Mar 26 12:32:31 2021
Return-path: <help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org>
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 <help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org>)
	id 1lPkhb-0000Mq-NR
	for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 26 Mar 2021 12:32:31 +0100
Original-Received: from localhost ([::1]:52752 helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org>)
	id 1lPkha-00072U-Lq
	for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 26 Mar 2021 07:32:30 -0400
Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42480)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@gnu.org>) id 1lPkgS-00071b-Bs
 for help-gnu-emacs@gnu.org; Fri, 26 Mar 2021 07:31:20 -0400
Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:57207)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@gnu.org>) id 1lPkgS-0007zD-1E
 for help-gnu-emacs@gnu.org; Fri, 26 Mar 2021 07:31:20 -0400
Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:2140
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <eliz@gnu.org>) id 1lPkgN-0004M7-MO
 for help-gnu-emacs@gnu.org; Fri, 26 Mar 2021 07:31:16 -0400
In-Reply-To: <YF2TH1TEOkEoPj1B@protected.localdomain> (message from Jean Louis
 on Fri, 26 Mar 2021 10:54:07 +0300)
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 <help-gnu-emacs.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/help-gnu-emacs>,
 <mailto:help-gnu-emacs-request@gnu.org?subject=unsubscribe>
List-Archive: <https://lists.gnu.org/archive/html/help-gnu-emacs>
List-Post: <mailto:help-gnu-emacs@gnu.org>
List-Help: <mailto:help-gnu-emacs-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/help-gnu-emacs>,
 <mailto:help-gnu-emacs-request@gnu.org?subject=subscribe>
Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org
Original-Sender: "help-gnu-emacs"
 <help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org>
Xref: news.gmane.io gmane.emacs.help:128615
Archived-At: <http://permalink.gmane.org/gmane.emacs.help/128615>

> Date: Fri, 26 Mar 2021 10:54:07 +0300
> From: Jean Louis <bugs@gnu.support>
> Cc: help-gnu-emacs@gnu.org
> 
> > > I have tried using that function, but again, how do I get the last
> > > buffer?
> > 
> > By comparing the current buffer-list with the previous one?
> 
> My naive attempt does not show any difference, as I am doing something
> wrong.
> 
> (setq last-buffer-list nil)
> 
> (defun rcd-last-async-buffer (&rest args)
>   (let ((last (set-difference last-buffer-list (buffer-list))))
>     (message "Last buffer: %s" last))
>   (setq last-buffer-list (buffer-list)))
> 
> (add-hook 'buffer-list-update-hook 'rcd-last-async-buffer)

That hook is called for events other than buffer creation.  Are you
sure you looked at those where a buffer was created?