From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.bugs Subject: bug#64394: [PATCH] Fix `async-shell-command-display-buffer' display Date: Sun, 2 Jul 2023 09:09:37 +0200 Message-ID: <02b09ae9-52ba-4dab-02a2-adf0ef5a4d28@gmx.at> References: <873528cuoe.fsf@eliza.sh> <833528rt62.fsf@gnu.org> <87h6qo6pbz.fsf@eliza.sh> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38955"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 64394@debbugs.gnu.org, juri@linkov.net To: Eliza Velasquez , Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jul 02 09:10:25 2023 Return-path: Envelope-to: geb-bug-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 1qFrE0-0009ya-Sa for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 02 Jul 2023 09:10:24 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qFrDh-0003BX-Dk; Sun, 02 Jul 2023 03:10:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qFrDg-0003BP-62 for bug-gnu-emacs@gnu.org; Sun, 02 Jul 2023 03:10:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qFrDf-0005ql-KX for bug-gnu-emacs@gnu.org; Sun, 02 Jul 2023 03:10:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qFrDe-0007f1-I2 for bug-gnu-emacs@gnu.org; Sun, 02 Jul 2023 03:10:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: martin rudalics Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 02 Jul 2023 07:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64394 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 64394-submit@debbugs.gnu.org id=B64394.168828179129424 (code B ref 64394); Sun, 02 Jul 2023 07:10:02 +0000 Original-Received: (at 64394) by debbugs.gnu.org; 2 Jul 2023 07:09:51 +0000 Original-Received: from localhost ([127.0.0.1]:59077 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qFrDT-0007eV-AU for submit@debbugs.gnu.org; Sun, 02 Jul 2023 03:09:51 -0400 Original-Received: from mout.gmx.net ([212.227.15.15]:39259) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qFrDQ-0007eG-CS for 64394@debbugs.gnu.org; Sun, 02 Jul 2023 03:09:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.at; s=s31663417; t=1688281779; x=1688886579; i=rudalics@gmx.at; bh=tCBQHNoPGznrFbaMbvxJ1X5TdoElxyQgLGPNMzCpN9E=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From:In-Reply-To; b=ITcMwMVG8d/bBcKiZIjTSHVBSA8OrPmJOVUZaMfoYQiaFxpJFBqZJBKBJAt1kE95WxZsDNT Dvt5VepFWmULwFg8ST4X2F+jn2sKmg5ajzNOSXKop9qnYjT/JLPP9aUUtWb3j+jkYzoEZWY/v CmgY2NC24q0fk+QCS2O8zINHLafyGMWFE3sZjks6/VbnXshVsIn2E/0Xd47Tf1fFKp6E10EWV /OYVa/7S0EODK0SILcJUkJCJN9O6PtmrtPzwDRdGWXQasNqpw6zRXK1mstSYro4mpH9tNb4u6 a5I/zpcnF0XQLbWHmUoUFGp17o77ANepDzmczhX+K0UtxJ1/t2kg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from [192.168.1.100] ([213.142.96.247]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MV63g-1qQLLR01ck-00S6yW; Sun, 02 Jul 2023 09:09:39 +0200 Content-Language: en-US In-Reply-To: <87h6qo6pbz.fsf@eliza.sh> X-Provags-ID: V03:K1:aVCOOY6cnpQc0nC9bUIY0luET7+jyB2Dvh4Y+CdUHw0NOM6IFgA 4kohyWk0GwavL0bLsf5faRJ66A0qe0MnzM4T3OG2cbf5OCD6lsC18eTK9jjiXA+UxtGjK4x 32os6+iUH+rWurtaLgKI3UfcbaQyhbsjI8QBbwfKAXR/Sfg1J2j+22BH4yatTEoFXFm2pny IySb/SbOqqz/giuUgXjLA== UI-OutboundReport: notjunk:1;M01:P0:LkjInUxov1Q=;kdbsmDqRq7R/PsApd5pqYbN6w62 WFhYhEUXVcGY6MVu4jnGDfkWCJtQkOOEb5u9JF/Xep1+TKV6E9g3C3EdVvLkbmatvAwmIOUff p8CCDzE+fdt9l8012WMp2US9tfb/kYx7OqPvTPLNuA3wKs1WWZcmOMaLRpi6+wGvqIT6Q0s0c EFyOfqxj4gs2KUmSHMmw64Jpggw0dAzOw6HZoRobvAEb9qSSUxZ1mJuPvQyVRy2Pys8TxLHzP 1TLZGVnwRpHYWiLg6y0ahSwvh5Qk2Z7ti1PGsjdxXSBrQ6YMpnB4MfZdqlCHRldc5CixfjDCP MzSO8E2R/4h5rHIJD3SYhoiRwFUC2nSh3JJsYZE5NVj+l/0NPYRGlXLCqMJ4u/vEpnTQVyy/k 455GH3lVsqG0HYsVUrCkO1Go5pQQKP/8HHZWWspa+I1gLrpPNdsNt6tjkBScrAiuuGPjH0Oj+ yjH+hkOQyFIscZdde+4FSa0af6RyRPY5arQKUAUlsqBmI6NKxhK9y3JkyygT5qGhOZNBIaIeJ kPnrfaCYbHh1Ulxs8SLKDLKrh/q73dtUvySV7ROsRFNum1fxj2Zt8v9m38ayKMgi/ufrRFIvd vu3y8yLBZIaLsrOPIZpnSPrOPgmD4BGM0IGo+n6RISbRwxYbfgLdTtiBIhDadRYKRsq/ePokD qBq0pniwYRvLgJBL6hQjjGCcD1v8yCh5R5/I26dw7TIa3sLzkLXXHpc4OAZshlmQIPAyoEeQl 3E59gK1glnOqq9ZHrsl4UCBkX2ELSpI6s/BFa7G6QF7KtmnYQY6yhmJQUGKNToTXoCBEsvTD X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:264451 Archived-At: >> I'm probably missing something, but how can display-buffer fail to >> support any action function, such as display-buffer-no-window? >> >> Martin, what am I missing here? We may have to ask Juri, he conceived the "allow-no-window" concept. > I was also confused. Based on the documentation for > `display-buffer-no-window', it seems that callers are supposed to > explicitly pass an `(allow-no-window . t)' cons pair when calling > `display-buffer' as a signal that they can correctly handle a return > value of nil. If it's absent, `display-buffer-no-window' seems to err > on the side of caution, assume the caller can't handle nil, displays the > window anyway, and returns it like all the other display functions. I think that's the idea, yes. > Technically it seems that you can add `(allow-no-window . t)' to > `display-buffer-alist' to always force the buffer never to appear, but > that doesn't seem at all like its intended use. Maybe "force" is too strong here. You can "force" it by adding an 'allow-no-window' entry to the alist _and_ a 'display-buffer-no-window' action in a position that precedes any other display buffer action. >> That's fine, but those are your preferences. I'd feel uncomfortable >> with forcing them on everyone, if we already have a way of tailoring >> this behavior by user customizations. > > I might not have been clear with what I meant here, sorry; I mean that > in my own personal config, when I run `mpv', its output appears in a > buffer named `*shell:mpv*' instead of `*Async Shell Command*', and I > have an explicit entry for it in `display-buffer-alist' so that it > doesn't appear via `display-buffer-no-window'. This was functioning > well, except the moment I set `async-shell-command-display-buffer' to > nil, the buffer displayed itself the moment mpv began to write to > stdout. > > A minimally reproable example in `emacs -Q': > > --8<---------------cut here---------------start------------->8--- > (setq display-buffer-alist > '(("\\*Async Shell Command\\*" > (display-buffer-no-window)))) > (setq async-shell-command-display-buffer nil) > --8<---------------cut here---------------end--------------->8--- > > `M-& echo foo RET' will unexpectedly show the `*Async Shell Command*' > buffer. I suppose (Juri will correct me) that this snippet in 'shell-command' (if async-shell-command-display-buffer ;; Display buffer immediately. (display-buffer buffer '(nil (allow-no-window . t))) <<<<< ;; Defer displaying buffer until first process output. ;; Use disposable named advice so that the buffer is ;; displayed at most once per process lifetime. (let ((nonce (make-symbol "nonce"))) (add-function :before (process-filter proc) (lambda (proc _string) (let ((buf (process-buffer proc))) (when (buffer-live-p buf) (remove-function (process-filter proc) nonce) (display-buffer buf)))) <<<<< `((name . ,nonce))))))) adding an 'allow-no-window' entry if and only if 'async-shell-command-display-buffer' is non-nil is responsible for the behavior Eliza sees. I have no idea whether adding such an entry in the second case could cause problems. We could give 'async-shell-command-display-buffer' a third value, say 'allow-no-window and, if a user has set it to that value, have 'shell-command' add an 'allow-no-window' entry in the second case too. martin