From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: "Basil L. Contovounesios" Newsgroups: gmane.emacs.bugs Subject: bug#30213: 26.0.91; shell buffer not displayed when not erased and async-shell-command-display-buffer is used Date: Tue, 23 Jan 2018 22:44:06 +0000 Message-ID: <87zi54jivd.fsf@tcd.ie> References: <87a7x5ejsu.fsf@gmail.com> <878tcpfmnz.fsf@tcd.ie> <87607s62zt.fsf@gmail.com> <874lnc62sj.fsf@gmail.com> <877es8xv8m.fsf@tcd.ie> <83a7x4nzjq.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1516747418 27199 195.159.176.226 (23 Jan 2018 22:43:38 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 23 Jan 2018 22:43:38 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: alex.branham@gmail.com, 30213@debbugs.gnu.org, Reuben Thomas To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Jan 23 23:43:33 2018 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 1ee7Hh-0005pw-Mr for geb-bug-gnu-emacs@m.gmane.org; Tue, 23 Jan 2018 23:43:17 +0100 Original-Received: from localhost ([::1]:58623 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ee7Ji-0003FK-32 for geb-bug-gnu-emacs@m.gmane.org; Tue, 23 Jan 2018 17:45:22 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37849) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ee7JS-0003CS-AR for bug-gnu-emacs@gnu.org; Tue, 23 Jan 2018 17:45:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ee7JO-0001ui-9U for bug-gnu-emacs@gnu.org; Tue, 23 Jan 2018 17:45:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:60448) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ee7JO-0001uK-5z for bug-gnu-emacs@gnu.org; Tue, 23 Jan 2018 17:45:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ee7JN-00039d-Qz for bug-gnu-emacs@gnu.org; Tue, 23 Jan 2018 17:45:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: "Basil L. Contovounesios" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 23 Jan 2018 22:45:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 30213 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 30213-submit@debbugs.gnu.org id=B30213.151674746012054 (code B ref 30213); Tue, 23 Jan 2018 22:45:01 +0000 Original-Received: (at 30213) by debbugs.gnu.org; 23 Jan 2018 22:44:20 +0000 Original-Received: from localhost ([127.0.0.1]:40112 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ee7Ii-00038L-AF for submit@debbugs.gnu.org; Tue, 23 Jan 2018 17:44:20 -0500 Original-Received: from mail-wm0-f68.google.com ([74.125.82.68]:34882) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ee7Ig-000385-2R for 30213@debbugs.gnu.org; Tue, 23 Jan 2018 17:44:18 -0500 Original-Received: by mail-wm0-f68.google.com with SMTP id r78so5010193wme.0 for <30213@debbugs.gnu.org>; Tue, 23 Jan 2018 14:44:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=c8KY+2dCHrvWMSF40j0l2H0D3dGanlhgSihhp+/AS0Q=; b=uw1KjMUfyNbuHePXsuK8NrhmXa2djT1ZVbvav8Cxlnwjyz25qj3cAvhS2WWoR8Gwgj CwCtyGUVjZmYA2LkFK3WzbSjYPwGolxUo95tW0W2XAGWHYMStlqi+Dvkt8VWSXvFNaKy jna9yCuER6EPcDK/YcvbI5Idg5QSlpgqXwD5f7oSkUng+wFsJtZwqeZknzqbSCWGsAQR Pj0mzb5EybHOTEEs2pUQcp4FYxxPFBKJAsHStsB/U9qttBsHaKKgxVzpHqOEaOonSwWS DUyEAMR6aJJTebKh54zPv5A5ZJbyXqKBYhwp5L9kscQbvw+w+2+3bVy+n6U8wwdtGPfH pjow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=c8KY+2dCHrvWMSF40j0l2H0D3dGanlhgSihhp+/AS0Q=; b=IMxKJqAFAk2Er3jh83BMYwD5x9+gRmmneXU3u0blAXGjk2o5dd9u592c2la7qTaLkm jw/cKMjsuqpkQvanHUlrwdcJoxoPBLLcE2SWeMyWIHEf7a25bNlgn2W71GQBAypXhHck 6aHuuS5Nv/oJpJZqogZuMrGGxawUuhNejw6YCBEDMQRReqM0I5I7lP+mwGPEo3Pmaw7h m5/RCgxNxU+EhHpqzVxqWIC7PBFxZbbmsmsuX2ob3/37KumjI1IL3jGNztphzLUVr3Uj 38S8vzkM/fZw4k8RdpCm8BHRufmHmgHkdr1ioX+eSkk0s1zIogZep/dxbtHshz4Fr9Ry A/uQ== X-Gm-Message-State: AKwxytfgUL3hqmxc346Bxlb2HT6hhZXAIk6j35Kxqj5g9NP6D7ytJ7T5 LvLy7LeEVl+vwiutmIvBGbJiig== X-Google-Smtp-Source: AH8x226Dpjw95LlALN9VrT6z+k6eqULeQwFfasN9ndWtl/zgKT2UtBdEsOqx8RG7KsjA8SjAmzARKw== X-Received: by 10.80.181.15 with SMTP id y15mr20817578edd.29.1516747452301; Tue, 23 Jan 2018 14:44:12 -0800 (PST) Original-Received: from localhost ([2a02:8084:4f41:8c80:9929:5bdb:4629:fab8]) by smtp.gmail.com with ESMTPSA id z49sm13452892edd.93.2018.01.23.14.44.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Jan 2018 14:44:11 -0800 (PST) In-Reply-To: <83a7x4nzjq.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 23 Jan 2018 21:30:17 +0200") 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:142453 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> From: "Basil L. Contovounesios" >> Date: Tue, 23 Jan 2018 18:53:13 +0000 >> Cc: 30213@debbugs.gnu.org >> >> * lisp/simple.el (shell-command): Display async command buffer on >> process output for every invocation, not just the first. (bug#30213) >> --- >> lisp/simple.el | 4 +--- >> 1 file changed, 1 insertion(+), 3 deletions(-) >> >> diff --git a/lisp/simple.el b/lisp/simple.el >> index 3ac6b86381..20e22bf98f 100644 >> --- a/lisp/simple.el >> +++ b/lisp/simple.el >> @@ -3551,9 +3551,7 @@ shell-command >> (add-function :before (process-filter proc) >> (lambda (process _string) >> (let ((buf (process-buffer process))) >> - (when (and (zerop (buffer-size buf)) >> - (string= (buffer-name buf) >> - bname)) >> + (when (string= (buffer-name buf) bname) >> (display-buffer buf)))))))) >> ;; Otherwise, command is executed synchronously. >> (shell-command-on-region (point) (point) command > > Looks like you are removing the feature we just introduced in Emacs > 26, see commit 85512e7: it shows the shell buffer only if there is > some output there. Or am I missing something? This feature is implemented by the surrounding add-function advice on the process filter, which I am not removing. Here is my patch in the surrounding context of the async-shell-command-display-buffer switch: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=diff.diff diff --git a/lisp/simple.el b/lisp/simple.el index 3ac6b86381..20e22bf98f 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -3549,13 +3549,11 @@ shell-command (if async-shell-command-display-buffer (display-buffer buffer '(nil (allow-no-window . t))) (add-function :before (process-filter proc) (lambda (process _string) (let ((buf (process-buffer process))) - (when (and (zerop (buffer-size buf)) - (string= (buffer-name buf) - bname)) + (when (string= (buffer-name buf) bname) (display-buffer buf)))))))) ;; Otherwise, command is executed synchronously. (shell-command-on-region (point) (point) command output-buffer nil error-buffer))))))) --=-=-= Content-Type: text/plain When async-shell-command-display-buffer is non-nil, the output buffer is displayed immediately. Otherwise, the buffer is displayed by the (advised) process filter, which should only be invoked for output-producing shell commands[1]. For example, the Unix null command M-& : RET does not invoke the process filter. Without my patch, the process filter advice only displays the output buffer if it is already empty, i.e. if no previous shell-command invocation has written output to the process buffer. This guard seems to contradict the purpose of a non-nil shell-command-dont-erase-buffer setting. So, my patch continues to allow the immediate display of the output buffer, irrespective of command output, when async-shell-command-display-buffer is non-nil, as well as the deferred and repeated display of the output buffer, irrespective of shell-command-dont-erase-buffer and subject to command output, when async-shell-command-display-buffer is nil. [1] This assumption is based on observation, not expertise in process filters; I cannot guarantee the absence of obscure edge cases. -- Basil --=-=-=--