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:17:11 +0300
User-agent: Mutt/2.0.6 (2021-03-06)

* Eli Zaretskii <eliz@gnu.org> [2021-03-26 09:48]:
> > From: Robert Thorpe <rt@robertthorpeconsulting.com>
> > Date: Fri, 26 Mar 2021 05:52:22 +0000
> > Cc: help-gnu-emacs@gnu.org
> > 
> > For what it's worth Jean, I understand your problem with async buffers.
> > I've had the same problem.  I haven't found a solution to it.  If I find
> > one I'll tell you.
> 
> 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?

As when I put the function `rcd-last-async-buffer' into
`buffer-list-update-hook' with:

(add-hook 'buffer-list-update-hook 'rcd-last-async-buffer)

then from the function, when I invoke `M-& ls RET':

(defun rcd-last-async-buffer (&rest args)
  (let ((last-buffer (last-buffer))
        (current-buffer (current-buffer)))
  (message "Last buffer: %s, current buffer: %s" last-buffer current-buffer)))

I get this message:

Last buffer: *Completions*, current buffer: *Messages* [2 times]

and I was inspecting `&rest args' and did not get any variables
sent. My expectations were different, for example, that the hook would
give me the buffer name at least through a function invoked, or
alternatively by sending it as argument. 

If I cannot find last buffer created by M-& then I would need to list
buffers and again, how do I find the last one created if they are not
created one after the other really... the next empty number will be
filled with new async buffer.



reply via email to

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