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:04:54 +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.

OK, good insight into possibility.

Personally I have almost solved it, can you please look here:
https://lists.gnu.org/archive/html/help-gnu-emacs/2021-03/msg00250.html

This function is to replace the `async-shell-command' on a key M-&:

(defun rcd-async-shell-command (command &rest args)
  "Remembers last async shell command on `C-c l'"
  (interactive)
  (let* ((shell-command-buffer-name-async (concat "RCD Async: " 
(format-time-string "%T")))
         (last-buffer shell-command-buffer-name-async))
    (global-set-key (kbd "C-c l") `(lambda () 
                                     (interactive)
                                     (switch-to-buffer ,last-buffer)))
    (apply #'async-shell-command command args)))

(rcd-async-shell-command "gimp") → works, I can find last buffer with C-c l

(global-set-key (kbd "M-&") 'rcd-async-shell-command) → not working, as when I 
press M-& I get funcall-interactively: Wrong number of arguments: (lambda 
(command &rest args) "Remembers last async shell command on `C-c l'" 
(interactive) (let* ((shell-command-buffer-name-async (concat "RCD Async: " 
(format-time-string "%T"))) (last-buffer shell-command-buffer-name-async)) 
(global-set-key (kbd "C-c l") (list 'lambda nil '(interactive) (list 
'switch-to-buffer last-buffer))) (apply #'async-shell-command command
args))), 0

That would be simplest solution, but I cannot see to what "Wrong
number of arguments" relate exactly.



reply via email to

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