unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: martin rudalics <rudalics@gmx.at>
Cc: Eliza Velasquez <eliza@eliza.sh>, Eli Zaretskii <eliz@gnu.org>,
	64394@debbugs.gnu.org
Subject: bug#64394: [PATCH] Fix `async-shell-command-display-buffer' display
Date: Sun, 02 Jul 2023 21:03:58 +0300	[thread overview]
Message-ID: <86cz1axjtl.fsf@mail.linkov.net> (raw)
In-Reply-To: <02b09ae9-52ba-4dab-02a2-adf0ef5a4d28@gmx.at> (martin rudalics's message of "Sun, 2 Jul 2023 09:09:37 +0200")

>>> 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 don't remember the details why we decided to design it that way.
But now I don't see why not enable allow-no-window by default,
i.e. why not to make it opt-out instead of opt-in.

>> 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.

Indeed, it's possible to add 'allow-no-window' in customization:

  (setq display-buffer-alist
        '(("\\*Async Shell Command\\*"
           display-buffer-no-window
           (allow-no-window . t))))
  (setq async-shell-command-display-buffer nil)

> 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.

I think it's a plain bug that the first call of 'display-buffer'
sets 'allow-no-window' to t, but the second call doesn't.

These two 'display-buffer' calls were intended to do the same thing.
Only the second call is delayed until input arrives.





  reply	other threads:[~2023-07-02 18:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-01  1:00 bug#64394: [PATCH] Fix `async-shell-command-display-buffer' display Eliza Velasquez
2023-07-01  7:24 ` Eli Zaretskii
2023-07-01  7:52   ` Eliza Velasquez
2023-07-01  8:12     ` Eli Zaretskii
2023-07-01  8:42       ` Eliza Velasquez
2023-07-02  7:09     ` martin rudalics
2023-07-02 18:03       ` Juri Linkov [this message]
2023-07-03  6:46         ` martin rudalics
2023-07-04  1:18           ` Eliza Velasquez
2023-07-04 17:54             ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86cz1axjtl.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=64394@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=eliza@eliza.sh \
    --cc=rudalics@gmx.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).