From unknown Sun Aug 17 04:17:27 2025 X-Loop: help-debbugs@gnu.org Subject: bug#26649: 26.0.50; buffer-command: Return the cmd that started a process in buffer Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 25 Apr 2017 08:16:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 26649 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 26649@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.149310814612960 (code B ref -1); Tue, 25 Apr 2017 08:16:02 +0000 Received: (at submit) by debbugs.gnu.org; 25 Apr 2017 08:15:46 +0000 Received: from localhost ([127.0.0.1]:38795 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d2vdR-0003My-OV for submit@debbugs.gnu.org; Tue, 25 Apr 2017 04:15:46 -0400 Received: from eggs.gnu.org ([208.118.235.92]:51603) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d2vdP-0003Mk-SC for submit@debbugs.gnu.org; Tue, 25 Apr 2017 04:15:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d2vdJ-0001hc-CC for submit@debbugs.gnu.org; Tue, 25 Apr 2017 04:15:38 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_20,FREEMAIL_FROM, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:60119) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d2vdJ-0001hK-96 for submit@debbugs.gnu.org; Tue, 25 Apr 2017 04:15:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42566) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d2vdH-0007LW-Tg for bug-gnu-emacs@gnu.org; Tue, 25 Apr 2017 04:15:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d2vdD-0001fO-QT for bug-gnu-emacs@gnu.org; Tue, 25 Apr 2017 04:15:35 -0400 Received: from mail-pg0-x231.google.com ([2607:f8b0:400e:c05::231]:35058) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d2vdD-0001ew-KC for bug-gnu-emacs@gnu.org; Tue, 25 Apr 2017 04:15:31 -0400 Received: by mail-pg0-x231.google.com with SMTP id 72so24836927pge.2 for ; Tue, 25 Apr 2017 01:15:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version; bh=TjW/E2wfnPa8gNby8gp97IqLKD4PkDMqUHgf0/6tjIM=; b=Ni7GRxy5ZfRlYHF9Qq1xFWyhAZH29Y/3EoaaPSO/dxCuX1rYycCAOUCL7TIjHXKVJ0 BDyMODb8K5XaiupKIvH9l99B5VoONFL1/zzmorxSq6wdz1VmFgINgKdsdyR5CpO6DcoM 3D7dkafbcop0TktM6PZwqhrzLckqZV8Dxe7A11DZx5LwNGuI71mZY83tiUzTeH8DsaHs pDstfThxzeeacdeWC5KHHvMVTKOhwQmgxd4t/9XmSG6St65JaqoFCnITrhpQtF2sjvEf ZovGHgxFe/X2SVUVawNZHM+5/sYuIDqHy6uJmLfGqP6LtPJMI/2CNaXm3orEmOQteWp2 iILg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=TjW/E2wfnPa8gNby8gp97IqLKD4PkDMqUHgf0/6tjIM=; b=h3amMwzF85RXNS/93S8bakhEhblrxKv2vcFbuae1FWBOM6h9LkeAGWoFLOJA5Ybha1 FuiFKYzzl3EL6u+iIaJW1RcPaXOSqm5VBUC0YZZDfX3iGsoP3ni1HipLgYvR0zDylX3t +k2YFfExpJoma8HSuTBVqSB3jLUArhDvS2tDS39cAkgCsENkc8jY/wfjX8qhkw+Dmn8c Y93V2rz1YQCwzte3ny2Pqv24Li+Y2MtaXkEZ0ajKeEbKBbHEBoMNAMgeLvgbhWMQzUj5 CXw7GPnjUbzgPFwkCo8k7wpKFN/zM35Xacmy8nAmNj2i6YBjZFhZCVIUHHOm+WYyqBMX SkMw== X-Gm-Message-State: AN3rC/5Mn/1MunqBkPMOmkvh/QhkVYZuNgnNABqzXBwOk3M5pj5ud/WL m5zswkzveGHLR41S X-Received: by 10.84.229.2 with SMTP id b2mr37238159plk.154.1493108130269; Tue, 25 Apr 2017 01:15:30 -0700 (PDT) Received: from calancha-pc (222.139.137.133.dy.bbexcite.jp. [133.137.139.222]) by smtp.gmail.com with ESMTPSA id g5sm35024200pgn.38.2017.04.25.01.15.28 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Apr 2017 01:15:29 -0700 (PDT) From: Tino Calancha Date: Tue, 25 Apr 2017 17:15:26 +0900 Message-ID: <87a874299d.fsf@calancha-pc> MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) Severity: wishlist I define in my private customization a command `buffer-command', which calls `process-command' on the process associated with the current buffer. Interactively, it shows in the echo area the command as the last column of `list-processes' does. Is anyone interested in adding this feature? --8<-----------------------------cut here---------------start------------->8--- >From 59ee6e113b7ff557ba5208b79ddf57a26b4578b2 Mon Sep 17 00:00:00 2001 From: Tino Calancha Date: Tue, 25 Apr 2017 17:07:07 +0900 Subject: [PATCH] buffer-command: Return the cmd that started a process in buffer * lisp/simple.el (buffer-command): Return command executed to start a process in BUFFER (Bug#26649). * doc/lispref/processes.texi (Process Information): Document new command. * test/lisp/subr-tests.el (subr-tests--buffer-command): Add test ; * etc/NEWS: Add news entry. --- doc/lispref/processes.texi | 7 +++++++ etc/NEWS | 4 ++++ lisp/simple.el | 18 ++++++++++++++++++ test/lisp/subr-tests.el | 11 +++++++++++ 4 files changed, 40 insertions(+) diff --git a/doc/lispref/processes.texi b/doc/lispref/processes.texi index 630853384e..b182842614 100644 --- a/doc/lispref/processes.texi +++ b/doc/lispref/processes.texi @@ -975,6 +975,13 @@ Process Information @end smallexample @end defun +@deffn Command buffer-command &optional buffer +This command calls @code{process-command} on the process associated +with @var{buffer}. @var{buffer} defaults to the current buffer. +If @var{buffer} is not associated with a running process, then returns +@code{nil}. +@end deffn + @defun process-contact process &optional key This function returns information about how a network, a serial, or a pipe connection was set up. When @var{key} is @code{nil}, it returns diff --git a/etc/NEWS b/etc/NEWS index 9d4c72d6dc..87d6c93fa1 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -886,6 +886,10 @@ instead of its first. * Lisp Changes in Emacs 26.1 +++ +** New command 'buffer-command' calls 'process-command' on the +process associated with the current buffer. + ++++ ** Emacs now supports records for user-defined types, via the new functions 'make-record', 'record', and 'recordp'. Records are now used internally to represent cl-defstruct and defclass instances, for diff --git a/lisp/simple.el b/lisp/simple.el index a58164a112..2aed47502e 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -3967,6 +3967,24 @@ list-processes (tabulated-list-print)) (display-buffer buffer) nil) + +(defun buffer-command (&optional buffer) + "Return the command that was executed to start the process in BUFFER. +Buffer defaults to the current buffer. +This runs `process-command' on the process associated with BUFFER. +If BUFFER is not associated with a process, then return nil." + (interactive) + (when (and buffer (not (buffer-live-p (get-buffer buffer)))) + (error "Not a living buffer '%S'" buffer)) + (let* ((buf (get-buffer (or buffer (current-buffer)))) + (proc (get-buffer-process buf)) + (cmd (and proc (process-command proc)))) + (cond ((null cmd) + (message "No process in buffer '%s'" (buffer-name buf)) + nil) + (t + (message "%s" (mapconcat #'identity cmd " ")) + cmd)))) ;;;; Prefix commands diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el index 0d243cc5d8..f4e6640f9c 100644 --- a/test/lisp/subr-tests.el +++ b/test/lisp/subr-tests.el @@ -291,5 +291,16 @@ subr-test--frames-1 (should-error (eval '(dolist "foo") t) :type 'wrong-type-argument)) +(ert-deftest subr-tests--buffer-command () + (let ((program (executable-find "sleep")) + (timeout "10") proc) + (with-temp-buffer + (should-not (buffer-command)) + (when program + (setq proc + (start-process "sleep" (current-buffer) program timeout)) + (set-process-query-on-exit-flag proc nil) + (should (equal (buffer-command) (list program timeout))))))) + (provide 'subr-tests) ;;; subr-tests.el ends here -- 2.11.0 --8<-----------------------------cut here---------------end--------------->8--- In GNU Emacs 26.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.11) of 2017-04-25 Repository revision: 5b0fdefb4ca54b0d3dac3047ac1e4b380beb6ba7 From unknown Sun Aug 17 04:17:27 2025 X-Loop: help-debbugs@gnu.org Subject: bug#26649: 26.0.50; buffer-command: Return the cmd that started a process in buffer Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 26 Apr 2017 10:05:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 26649 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Tino Calancha Cc: 26649@debbugs.gnu.org Reply-To: Eli Zaretskii Received: via spool by 26649-submit@debbugs.gnu.org id=B26649.149320106520619 (code B ref 26649); Wed, 26 Apr 2017 10:05:01 +0000 Received: (at 26649) by debbugs.gnu.org; 26 Apr 2017 10:04:25 +0000 Received: from localhost ([127.0.0.1]:40579 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d3Jo8-0005MV-TV for submit@debbugs.gnu.org; Wed, 26 Apr 2017 06:04:25 -0400 Received: from eggs.gnu.org ([208.118.235.92]:54863) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d3Jo7-0005MI-Vi for 26649@debbugs.gnu.org; Wed, 26 Apr 2017 06:04:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3Jnz-0000Wo-K9 for 26649@debbugs.gnu.org; Wed, 26 Apr 2017 06:04:18 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:52394) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3Jnz-0000Wi-H2; Wed, 26 Apr 2017 06:04:15 -0400 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:3549 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1d3Jny-00059b-To; Wed, 26 Apr 2017 06:04:15 -0400 Date: Wed, 26 Apr 2017 13:03:36 +0300 Message-Id: <83a873pjt3.fsf@gnu.org> From: Eli Zaretskii In-reply-to: <87a874299d.fsf@calancha-pc> (message from Tino Calancha on Tue, 25 Apr 2017 17:15:26 +0900) References: <87a874299d.fsf@calancha-pc> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) > From: Tino Calancha > Date: Tue, 25 Apr 2017 17:15:26 +0900 > > Severity: wishlist > > I define in my private customization a command `buffer-command', which > calls `process-command' on the process associated with the current > buffer. > Interactively, it shows in the echo area the command as the last column > of `list-processes' does. > Is anyone interested in adding this feature? I don't have an opinion on this, perhaps others will offer theirs. I do have a few comments: > Subject: [PATCH] buffer-command: Return the cmd that started a process in > buffer ^^^^^^ Not "return", "display". > * lisp/simple.el (buffer-command): Return command executed to > start a process in BUFFER (Bug#26649). Likewise. Also, we generally use just "new command" in these cases. > * doc/lispref/processes.texi (Process Information): Document new command. It is better to mention the name of the command. > +@deffn Command buffer-command &optional buffer I think it would be better to have the command's name start with "process-", so something like process-command-in-buffer. > +This command calls @code{process-command} on the process associated > +with @var{buffer}. This describes the implementation; it should instead describe the effect of the command. > +If @var{buffer} is not associated with a running process, then returns > +@code{nil}. The value returned by a command is not interesting, you should describe the effect of invoking this command in a buffer that has n o associated process. > +(defun buffer-command (&optional buffer) > + "Return the command that was executed to start the process in BUFFER. Same comment here: describe the effect, not the return value. If the returned value is important for non-interactive invocations, it should be described in addition to the effect of an interactive invocation. > +Buffer defaults to the current buffer. ^^^^^^ BUFFER > + (error "Not a living buffer '%S'" buffer)) "Not a live buffer '%S'" > + (cond ((null cmd) > + (message "No process in buffer '%s'" (buffer-name buf)) It is better to say something like Buffer '%s' is not associated with any process Btw, why %s here and %S in the error message? > + (t > + (message "%s" (mapconcat #'identity cmd " ")) What will this produce if some of the command-line arguments include embedded whitespace? > +(ert-deftest subr-tests--buffer-command () > + (let ((program (executable-find "sleep")) > + (timeout "10") proc) Instead of bypassing the test where 'sleep' doesn't exist, how about if you use the Emacs executable instead? That will always exist. Thanks. From unknown Sun Aug 17 04:17:27 2025 X-Loop: help-debbugs@gnu.org Subject: bug#26649: 26.0.50; buffer-command: Return the cmd that started a process in buffer Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 26 Apr 2017 22:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 26649 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Tino Calancha Cc: 26649@debbugs.gnu.org Received: via spool by 26649-submit@debbugs.gnu.org id=B26649.1493244772430 (code B ref 26649); Wed, 26 Apr 2017 22:13:02 +0000 Received: (at 26649) by debbugs.gnu.org; 26 Apr 2017 22:12:52 +0000 Received: from localhost ([127.0.0.1]:42110 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d3VB6-00006q-L9 for submit@debbugs.gnu.org; Wed, 26 Apr 2017 18:12:52 -0400 Received: from sub3.mail.dreamhost.com ([69.163.253.7]:42886 helo=homiemail-a11.g.dreamhost.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d3VB4-00006d-N9 for 26649@debbugs.gnu.org; Wed, 26 Apr 2017 18:12:51 -0400 Received: from homiemail-a11.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a11.g.dreamhost.com (Postfix) with ESMTP id A5BE2314C069; Wed, 26 Apr 2017 15:12:49 -0700 (PDT) Received: from localhost.linkov.net (m83-179-141-227.cust.tele2.ee [83.179.141.227]) (Authenticated sender: jurta@jurta.org) by homiemail-a11.g.dreamhost.com (Postfix) with ESMTPA id C36E8314C066; Wed, 26 Apr 2017 15:12:48 -0700 (PDT) From: Juri Linkov Organization: LINKOV.NET References: <87a874299d.fsf@calancha-pc> Date: Thu, 27 Apr 2017 01:09:12 +0300 In-Reply-To: <87a874299d.fsf@calancha-pc> (Tino Calancha's message of "Tue, 25 Apr 2017 17:15:26 +0900") Message-ID: <8737cu254r.fsf@localhost> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.8 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.8 (--) > Severity: wishlist > > I define in my private customization a command `buffer-command', which > calls `process-command' on the process associated with the current > buffer. > Interactively, it shows in the echo area the command as the last column > of `list-processes' does. > Is anyone interested in adding this feature? The command name =E2=80=98buffer-command=E2=80=99 is confusing. At first= I thought it should read a command in the minibuffer like =E2=80=98shell-command=E2=80= =99 and execute it in the buffer's process. But actually it just displays the same info that is available in =E2=80=98list-processes=E2=80=99. From unknown Sun Aug 17 04:17:27 2025 X-Loop: help-debbugs@gnu.org Subject: bug#26649: 26.0.50; buffer-command: Return the cmd that started a process in buffer Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 27 Apr 2017 03:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 26649 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Juri Linkov Cc: 26649@debbugs.gnu.org Received: via spool by 26649-submit@debbugs.gnu.org id=B26649.149326333928794 (code B ref 26649); Thu, 27 Apr 2017 03:23:02 +0000 Received: (at 26649) by debbugs.gnu.org; 27 Apr 2017 03:22:19 +0000 Received: from localhost ([127.0.0.1]:42208 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d3a0Z-0007UL-Cr for submit@debbugs.gnu.org; Wed, 26 Apr 2017 23:22:19 -0400 Received: from mail-pf0-f182.google.com ([209.85.192.182]:34678) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d3a0W-0007U6-SZ for 26649@debbugs.gnu.org; Wed, 26 Apr 2017 23:22:17 -0400 Received: by mail-pf0-f182.google.com with SMTP id c198so12808198pfc.1 for <26649@debbugs.gnu.org>; Wed, 26 Apr 2017 20:22:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=467nVJpOD6uBwqeS1Bpjj9geNOUfjjBdB0qKg6Uqoxg=; b=HUAucaySiqrU76hAwic3QVcyt9UeQF4U0A6E0YIGkaDJlDGZqLXRH7gckJl876i71z ga92Ag+CvGCb2NirLgODr/3Z+8K1aV8UdUOLmWwtiGS/7PNUvY51z28kixUDOi2jV/1e +KhR2TfpPg//oqjeIXd83MLzYmCPhlx5BvAevzQekY1jxUY38AcxA4Jk8FziiQztVg+H zHUqMTvSBlNdIY8DENc91lOEu6gs9GS67Jkdc15lZAoXD3f0i1My+XncCc9vD2xf67nh 2SEBX+HWSTBdIRImNgpV9g20ovnOCvvm6h2VYEcKwIOxeG3FIEu4bh9vQnPBlRXIDud8 w4Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=467nVJpOD6uBwqeS1Bpjj9geNOUfjjBdB0qKg6Uqoxg=; b=ginZBs7CCs8fnOoJaLwCpeKxJ35/OZGqU222A5xgXJUdzDegn6XnoN8LUqhaHd3PUs He3zIbYxcWx4PCAFNIdiUP2/xVvdRhP3N+k6aaovbK7OwfCV6qcROrRXHluEc6lEIxJL ph+Wc8ITp2jqKavy7NM2SPViwDsJHmeTJYIzCHW7jDYtotGXVKsMxm+oA72O/mZYk3tH 3K+xpkqQ2LXOvYJHexNm1VUvEQovF83UcCzJSZSaHGHZQ2HzqAAbUfqifzZp4l21V0yW xX9Fpoji6P2BRi3EgoBdtRWy8V5z4uk+qOmuqKKuPODXEwYB4yJLEJjieHBPyd3SbCzg nriw== X-Gm-Message-State: AN3rC/6muwwHANS0xjSCPJ+fZjzUjYfHgD41jTOdxOGH5NIDnAZTAeNM WjU8BeBOsnZnkA== X-Received: by 10.84.179.193 with SMTP id b59mr4235543plc.56.1493263331000; Wed, 26 Apr 2017 20:22:11 -0700 (PDT) Received: from calancha-pc (222.139.137.133.dy.bbexcite.jp. [133.137.139.222]) by smtp.gmail.com with ESMTPSA id a187sm1100497pfa.59.2017.04.26.20.22.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Apr 2017 20:22:10 -0700 (PDT) From: Tino Calancha X-Google-Original-From: Tino Calancha Date: Thu, 27 Apr 2017 12:22:07 +0900 (JST) X-X-Sender: calancha@calancha-pc In-Reply-To: <8737cu254r.fsf@localhost> Message-ID: References: <87a874299d.fsf@calancha-pc> <8737cu254r.fsf@localhost> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: multipart/mixed; BOUNDARY="8323329-610242372-1493263329=:8025" X-Spam-Score: -2.8 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.8 (--) --8323329-610242372-1493263329=:8025 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8BIT On Thu, 27 Apr 2017, Juri Linkov wrote: >> Severity: wishlist >> >> I define in my private customization a command `buffer-command', which >> calls `process-command' on the process associated with the current >> buffer. >> Interactively, it shows in the echo area the command as the last column >> of `list-processes' does. >> Is anyone interested in adding this feature? > > The command name ‘buffer-command’ is confusing. At first I thought it > should read a command in the minibuffer like ‘shell-command’ and execute > it in the buffer's process. But actually it just displays the same info > that is available in ‘list-processes’. Yeah, this command seems very specific to my workflow. It doesn't add nothing to `list-process', so i agree it's worthless adding it into Emacs. --8323329-610242372-1493263329=:8025-- From unknown Sun Aug 17 04:17:27 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Tino Calancha Subject: bug#26649: closed (Re: bug#26649: 26.0.50; buffer-command: Return the cmd that started a process in buffer) Message-ID: References: <87h912tkhg.fsf@calancha-pc> <87a874299d.fsf@calancha-pc> X-Gnu-PR-Message: they-closed 26649 X-Gnu-PR-Package: emacs Reply-To: 26649@debbugs.gnu.org Date: Wed, 03 May 2017 08:26:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1493799962-19716-1" This is a multi-part message in MIME format... ------------=_1493799962-19716-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #26649: 26.0.50; buffer-command: Return the cmd that started a process in b= uffer which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 26649@debbugs.gnu.org. --=20 26649: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D26649 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1493799962-19716-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 26649-done) by debbugs.gnu.org; 3 May 2017 08:25:59 +0000 Received: from localhost ([127.0.0.1]:51878 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d5pbj-00057k-9G for submit@debbugs.gnu.org; Wed, 03 May 2017 04:25:59 -0400 Received: from mail-pg0-f50.google.com ([74.125.83.50]:33765) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d5pbh-00057T-Nb for 26649-done@debbugs.gnu.org; Wed, 03 May 2017 04:25:57 -0400 Received: by mail-pg0-f50.google.com with SMTP id y4so69356989pge.0 for <26649-done@debbugs.gnu.org>; Wed, 03 May 2017 01:25:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:references:date:in-reply-to:message-id:user-agent :mime-version:content-transfer-encoding; bh=vd9+/dw9P7BVFdFAdf7bQ4XvunNGGWLsO9LUkjmkiSs=; b=iXuIQq+1vk0g8KwO/ukfJMla0C+GtsK2zj+3dzdBlyo/xr5Bpt53nz6m1pK/RmQIYq eMeKMX7g74dAP5obcjAa+JmWDa1SQDxaEfK7CnB4yeNaJ8CETigT8qSCrfP3Id0OxKcq 1I58DCcM7RPj0/4dCfDenwNYbB0eCLwYcG5uJ9qK4+PVM48MefzIg0gCMm5UEHxmipbM NznVtTOjbvbMR5iFvGsWFHkq/+3kP73YuEuJTRblX3vJLahx6Vad6cEvui6sL0ardKL7 lNCjPLbfb79NYm5ftu/3VR21Y8+WO3xUuFDRgt6Z3ZwKxbBpWAvehaZk9+De/TLW2exc tUvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=vd9+/dw9P7BVFdFAdf7bQ4XvunNGGWLsO9LUkjmkiSs=; b=Rd8kQjPj2BpHT0NAMPOLE2R86GRSZAQfwzHMmEgBC5+bl2McMd6KVd/q8U1hKAeWDI 1oVhdBrCAyGPDscBZo8xw8NVgcGyJzJOZUmAMS0zIz/Hu+2ot8Ii9hfBmtI0pcil5Eib FzZo/EiH0t5Ka9sPdzbvRvfCo3g4L0xX2jkMNuhJJv340cCico613223FepfbSchUlGh 4bPxUTRmH4wnpURIjlRrdc1VSV+Ob7yEgrkX7Paa4tiAkN5JWSkyb6WP3WxHU/3Pffby qSxtuJPX6f8U2wlOrwOdIRKTr+UG9sWv/4Z6DI4bk3SEWmfBYGE1hvZ/ID13EJ6uJiyZ iKDA== X-Gm-Message-State: AN3rC/532QMvg9Q1qz0PlrAfoG8xjeNkRh63A4mL60nEtFR+tb5ZV/wN ldB0pS7qAaj0nlns X-Received: by 10.84.192.37 with SMTP id b34mr47658643pld.174.1493799951853; Wed, 03 May 2017 01:25:51 -0700 (PDT) Received: from calancha-pc ([240f:6e:ebf5:1:5263:364f:45c9:b038]) by smtp.gmail.com with ESMTPSA id o62sm3299087pfj.87.2017.05.03.01.25.49 for <26649-done@debbugs.gnu.org> (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 May 2017 01:25:50 -0700 (PDT) From: Tino Calancha To: 26649-done@debbugs.gnu.org Subject: Re: bug#26649: 26.0.50; buffer-command: Return the cmd that started a process in buffer References: <87a874299d.fsf@calancha-pc> <8737cu254r.fsf@localhost> Date: Wed, 03 May 2017 17:25:47 +0900 In-Reply-To: (Tino Calancha's message of "Thu, 27 Apr 2017 12:22:07 +0900 (JST)") Message-ID: <87h912tkhg.fsf@calancha-pc> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 26649-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Tino Calancha writes: > On Thu, 27 Apr 2017, Juri Linkov wrote: > >>> Severity: wishlist >>> >>> I define in my private customization a command `buffer-command', which >>> calls `process-command' on the process associated with the current >>> buffer. >>> Interactively, it shows in the echo area the command as the last column >>> of `list-processes' does. >>> Is anyone interested in adding this feature? >> >> The command name =E2=80=98buffer-command=E2=80=99 is confusing. At firs= t I thought it >> should read a command in the minibuffer like =E2=80=98shell-command=E2= =80=99 and execute >> it in the buffer's process. But actually it just displays the same info >> that is available in =E2=80=98list-processes=E2=80=99. > Yeah, this command seems very specific to my workflow. It doesn't add > nothing to `list-process', so i agree it's worthless adding it into > Emacs. There is no general interest in this proposal, so i am closing the report. ------------=_1493799962-19716-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 25 Apr 2017 08:15:46 +0000 Received: from localhost ([127.0.0.1]:38795 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d2vdR-0003My-OV for submit@debbugs.gnu.org; Tue, 25 Apr 2017 04:15:46 -0400 Received: from eggs.gnu.org ([208.118.235.92]:51603) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d2vdP-0003Mk-SC for submit@debbugs.gnu.org; Tue, 25 Apr 2017 04:15:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d2vdJ-0001hc-CC for submit@debbugs.gnu.org; Tue, 25 Apr 2017 04:15:38 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_20,FREEMAIL_FROM, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:60119) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d2vdJ-0001hK-96 for submit@debbugs.gnu.org; Tue, 25 Apr 2017 04:15:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42566) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d2vdH-0007LW-Tg for bug-gnu-emacs@gnu.org; Tue, 25 Apr 2017 04:15:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d2vdD-0001fO-QT for bug-gnu-emacs@gnu.org; Tue, 25 Apr 2017 04:15:35 -0400 Received: from mail-pg0-x231.google.com ([2607:f8b0:400e:c05::231]:35058) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d2vdD-0001ew-KC for bug-gnu-emacs@gnu.org; Tue, 25 Apr 2017 04:15:31 -0400 Received: by mail-pg0-x231.google.com with SMTP id 72so24836927pge.2 for ; Tue, 25 Apr 2017 01:15:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version; bh=TjW/E2wfnPa8gNby8gp97IqLKD4PkDMqUHgf0/6tjIM=; b=Ni7GRxy5ZfRlYHF9Qq1xFWyhAZH29Y/3EoaaPSO/dxCuX1rYycCAOUCL7TIjHXKVJ0 BDyMODb8K5XaiupKIvH9l99B5VoONFL1/zzmorxSq6wdz1VmFgINgKdsdyR5CpO6DcoM 3D7dkafbcop0TktM6PZwqhrzLckqZV8Dxe7A11DZx5LwNGuI71mZY83tiUzTeH8DsaHs pDstfThxzeeacdeWC5KHHvMVTKOhwQmgxd4t/9XmSG6St65JaqoFCnITrhpQtF2sjvEf ZovGHgxFe/X2SVUVawNZHM+5/sYuIDqHy6uJmLfGqP6LtPJMI/2CNaXm3orEmOQteWp2 iILg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=TjW/E2wfnPa8gNby8gp97IqLKD4PkDMqUHgf0/6tjIM=; b=h3amMwzF85RXNS/93S8bakhEhblrxKv2vcFbuae1FWBOM6h9LkeAGWoFLOJA5Ybha1 FuiFKYzzl3EL6u+iIaJW1RcPaXOSqm5VBUC0YZZDfX3iGsoP3ni1HipLgYvR0zDylX3t +k2YFfExpJoma8HSuTBVqSB3jLUArhDvS2tDS39cAkgCsENkc8jY/wfjX8qhkw+Dmn8c Y93V2rz1YQCwzte3ny2Pqv24Li+Y2MtaXkEZ0ajKeEbKBbHEBoMNAMgeLvgbhWMQzUj5 CXw7GPnjUbzgPFwkCo8k7wpKFN/zM35Xacmy8nAmNj2i6YBjZFhZCVIUHHOm+WYyqBMX SkMw== X-Gm-Message-State: AN3rC/5Mn/1MunqBkPMOmkvh/QhkVYZuNgnNABqzXBwOk3M5pj5ud/WL m5zswkzveGHLR41S X-Received: by 10.84.229.2 with SMTP id b2mr37238159plk.154.1493108130269; Tue, 25 Apr 2017 01:15:30 -0700 (PDT) Received: from calancha-pc (222.139.137.133.dy.bbexcite.jp. [133.137.139.222]) by smtp.gmail.com with ESMTPSA id g5sm35024200pgn.38.2017.04.25.01.15.28 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Apr 2017 01:15:29 -0700 (PDT) From: Tino Calancha To: bug-gnu-emacs@gnu.org Subject: 26.0.50; buffer-command: Return the cmd that started a process in buffer Date: Tue, 25 Apr 2017 17:15:26 +0900 Message-ID: <87a874299d.fsf@calancha-pc> MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) Severity: wishlist I define in my private customization a command `buffer-command', which calls `process-command' on the process associated with the current buffer. Interactively, it shows in the echo area the command as the last column of `list-processes' does. Is anyone interested in adding this feature? --8<-----------------------------cut here---------------start------------->8--- >From 59ee6e113b7ff557ba5208b79ddf57a26b4578b2 Mon Sep 17 00:00:00 2001 From: Tino Calancha Date: Tue, 25 Apr 2017 17:07:07 +0900 Subject: [PATCH] buffer-command: Return the cmd that started a process in buffer * lisp/simple.el (buffer-command): Return command executed to start a process in BUFFER (Bug#26649). * doc/lispref/processes.texi (Process Information): Document new command. * test/lisp/subr-tests.el (subr-tests--buffer-command): Add test ; * etc/NEWS: Add news entry. --- doc/lispref/processes.texi | 7 +++++++ etc/NEWS | 4 ++++ lisp/simple.el | 18 ++++++++++++++++++ test/lisp/subr-tests.el | 11 +++++++++++ 4 files changed, 40 insertions(+) diff --git a/doc/lispref/processes.texi b/doc/lispref/processes.texi index 630853384e..b182842614 100644 --- a/doc/lispref/processes.texi +++ b/doc/lispref/processes.texi @@ -975,6 +975,13 @@ Process Information @end smallexample @end defun +@deffn Command buffer-command &optional buffer +This command calls @code{process-command} on the process associated +with @var{buffer}. @var{buffer} defaults to the current buffer. +If @var{buffer} is not associated with a running process, then returns +@code{nil}. +@end deffn + @defun process-contact process &optional key This function returns information about how a network, a serial, or a pipe connection was set up. When @var{key} is @code{nil}, it returns diff --git a/etc/NEWS b/etc/NEWS index 9d4c72d6dc..87d6c93fa1 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -886,6 +886,10 @@ instead of its first. * Lisp Changes in Emacs 26.1 +++ +** New command 'buffer-command' calls 'process-command' on the +process associated with the current buffer. + ++++ ** Emacs now supports records for user-defined types, via the new functions 'make-record', 'record', and 'recordp'. Records are now used internally to represent cl-defstruct and defclass instances, for diff --git a/lisp/simple.el b/lisp/simple.el index a58164a112..2aed47502e 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -3967,6 +3967,24 @@ list-processes (tabulated-list-print)) (display-buffer buffer) nil) + +(defun buffer-command (&optional buffer) + "Return the command that was executed to start the process in BUFFER. +Buffer defaults to the current buffer. +This runs `process-command' on the process associated with BUFFER. +If BUFFER is not associated with a process, then return nil." + (interactive) + (when (and buffer (not (buffer-live-p (get-buffer buffer)))) + (error "Not a living buffer '%S'" buffer)) + (let* ((buf (get-buffer (or buffer (current-buffer)))) + (proc (get-buffer-process buf)) + (cmd (and proc (process-command proc)))) + (cond ((null cmd) + (message "No process in buffer '%s'" (buffer-name buf)) + nil) + (t + (message "%s" (mapconcat #'identity cmd " ")) + cmd)))) ;;;; Prefix commands diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el index 0d243cc5d8..f4e6640f9c 100644 --- a/test/lisp/subr-tests.el +++ b/test/lisp/subr-tests.el @@ -291,5 +291,16 @@ subr-test--frames-1 (should-error (eval '(dolist "foo") t) :type 'wrong-type-argument)) +(ert-deftest subr-tests--buffer-command () + (let ((program (executable-find "sleep")) + (timeout "10") proc) + (with-temp-buffer + (should-not (buffer-command)) + (when program + (setq proc + (start-process "sleep" (current-buffer) program timeout)) + (set-process-query-on-exit-flag proc nil) + (should (equal (buffer-command) (list program timeout))))))) + (provide 'subr-tests) ;;; subr-tests.el ends here -- 2.11.0 --8<-----------------------------cut here---------------end--------------->8--- In GNU Emacs 26.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.11) of 2017-04-25 Repository revision: 5b0fdefb4ca54b0d3dac3047ac1e4b380beb6ba7 ------------=_1493799962-19716-1--