From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.help Subject: [solved]: Re: Finding last *Async Shell Command* buffer? Date: Fri, 26 Mar 2021 10:25:10 +0300 Message-ID: References: <87k0puihrd.fsf@robertthorpeconsulting.com> <838s6aqtlv.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2422"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/2.0.6 (2021-03-06) Cc: help-gnu-emacs@gnu.org To: Eli Zaretskii Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Mar 26 08:29:24 2021 Return-path: 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 ) id 1lPguK-0000WG-80 for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 26 Mar 2021 08:29:24 +0100 Original-Received: from localhost ([::1]:58172 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lPguJ-0005Of-8p for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 26 Mar 2021 03:29:23 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49796) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPgtw-0005OY-Vj for help-gnu-emacs@gnu.org; Fri, 26 Mar 2021 03:29:01 -0400 Original-Received: from stw1.rcdrun.com ([217.170.207.13]:41219) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPgtu-00075k-V4; Fri, 26 Mar 2021 03:29:00 -0400 Original-Received: from localhost ([::ffff:41.210.143.10]) (AUTH: PLAIN securesender, TLS: TLS1.3,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA id 000000000001E1C3.00000000605D8D37.000050A7; Fri, 26 Mar 2021 00:28:54 -0700 Mail-Followup-To: Eli Zaretskii , help-gnu-emacs@gnu.org Content-Disposition: inline In-Reply-To: <838s6aqtlv.fsf@gnu.org> Received-SPF: pass client-ip=217.170.207.13; envelope-from=bugs@gnu.support; helo=stw1.rcdrun.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:128600 Archived-At: * Eli Zaretskii [2021-03-26 10:09]: > > Date: Fri, 26 Mar 2021 10:01:31 +0300 > > From: Jean Louis > > Cc: help-gnu-emacs@gnu.org > > > > Please look here: > > https://lists.gnu.org/archive/html/help-gnu-emacs/2021-03/msg00250.html > > > > As maybe you can help me figure out why I cannot invoke that function > > from a key like M-& -- as when I solve that, I will easily be able to > > switch to last buffer with a key. > > Emacs told you what's wrong: "Wrong number of arguments". What isn't > clear about that error message? It is confusing as I was thinking I gave it enough arguments, but it requires `interactive' so I copied it from original function. Now it is solved intermittently: (defun rcd-async-shell-command (&rest args) "Remembers last async shell command on `C-c l'" (interactive (list (read-shell-command (if shell-command-prompt-show-cwd (format-message "Async shell command in `%s': " (abbreviate-file-name default-directory)) "Async shell command: ") nil nil (let ((filename (cond (buffer-file-name) ((eq major-mode 'dired-mode) (dired-get-filename nil t))))) (and filename (file-relative-name filename)))) current-prefix-arg shell-command-default-error-buffer)) (let* ((shell-command-buffer-name-async (concat "RCD Async: " (format-time-string "%Y%m%d%H%M%S"))) (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 args))) Now I can bind it: (global-set-key (kbd "M-&") 'rcd-async-shell-command) And now it works, when I wish to get the last async buffer I just press `C-c l'. Because buffers are named by year and time: (concat "RCD Async: " (format-time-string "%Y%m%d%H%M%S") I can then make a function to browse backwards in time those async buffers. Jean