help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Finding last *Async Shell Command* buffer?


From: Jean Louis
Subject: Re: Finding last *Async Shell Command* buffer?
Date: Fri, 26 Mar 2021 10:54:07 +0300
User-agent: Mutt/2.0.6 (2021-03-06)

* Eli Zaretskii <eliz@gnu.org> [2021-03-26 10:48]:
> > Date: Fri, 26 Mar 2021 10:17:11 +0300
> > From: Jean Louis <bugs@gnu.support>
> > Cc: help-gnu-emacs@gnu.org
> > 
> > > Did you try writing a simple function to put on
> > > buffer-list-update-hook?  Then you can in that function define a
> > > buffer-local variable whose value is a simple monotonically increasing
> > > counter, or even the time when the buffer was created.  Then write a
> > > command to sort buffers in the order determined by that variable.
> > 
> > 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)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]