From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.bugs Subject: bug#26649: 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> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1493108181 10550 195.159.176.226 (25 Apr 2017 08:16:21 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 25 Apr 2017 08:16:21 +0000 (UTC) To: 26649@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Apr 25 10:16:13 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d2vds-0002YR-5p for geb-bug-gnu-emacs@m.gmane.org; Tue, 25 Apr 2017 10:16:12 +0200 Original-Received: from localhost ([::1]:47693 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d2vdx-0007db-Si for geb-bug-gnu-emacs@m.gmane.org; Tue, 25 Apr 2017 04:16:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42694) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d2vdp-0007dH-CP for bug-gnu-emacs@gnu.org; Tue, 25 Apr 2017 04:16:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d2vdj-0001nd-9c for bug-gnu-emacs@gnu.org; Tue, 25 Apr 2017 04:16:09 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:40596) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d2vdj-0001nX-09 for bug-gnu-emacs@gnu.org; Tue, 25 Apr 2017 04:16:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1d2vdi-0003Nc-MB for bug-gnu-emacs@gnu.org; Tue, 25 Apr 2017 04:16:02 -0400 X-Loop: help-debbugs@gnu.org 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: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.149310814612960 (code B ref -1); Tue, 25 Apr 2017 08:16:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 25 Apr 2017 08:15:46 +0000 Original-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 Original-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 Original-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 Original-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 Original-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 Original-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 Original-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 Original-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) Original-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) 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:131950 Archived-At: 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