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: Eli Zaretskii
Subject: Re: Finding last *Async Shell Command* buffer?
Date: Fri, 26 Mar 2021 10:18:04 +0300

> Date: Fri, 26 Mar 2021 10:04:54 +0300
> From: Jean Louis <bugs@gnu.support>
> Cc: help-gnu-emacs@gnu.org
> 
> (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.

Ask yourself 2 questions:

 . How many arguments does this function expect?
 . How many arguments are provided by the interactive call via "M-&"?

The discrepancy between these two is what causes the error.



reply via email to

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