unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: Juri Linkov <juri@linkov.net>
Cc: 32607@debbugs.gnu.org
Subject: bug#32607: 27.0.50; pop-to-buffer in next-error-no-select
Date: Thu, 13 Sep 2018 21:34:24 -0400	[thread overview]
Message-ID: <jwvh8ishobl.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87y3c5ov87.fsf@mail.linkov.net> (Juri Linkov's message of "Fri,  14 Sep 2018 02:04:08 +0300")

>> Indeed.  I guess for this reason next-error-no-select might want to
>> let-bind display-buffer-overriding-action to something like
>> (nil (inhibit-same-window . t)) during the call to next-error.
>
> Then the same overriding should be applied to both:
>
> diff --git a/lisp/simple.el b/lisp/simple.el
> index ffd7fcc067..17ebcb2e16 100644
> --- a/lisp/simple.el
> +++ b/lisp/simple.el
> @@ -383,9 +383,10 @@ next-error-no-select
>  Finds and highlights the source line like \\[next-error], but does not
>  select the source buffer."
>    (interactive "p")
> -  (let ((next-error-highlight next-error-highlight-no-select))
> +  (let ((next-error-highlight next-error-highlight-no-select)
> +        (display-buffer-overriding-action '(nil (inhibit-same-window . t))))
>      (next-error n))
> -  (let ((display-buffer-overriding-action '(display-buffer-reuse-window)))
> +  (let ((display-buffer-overriding-action '(nil (inhibit-same-window . t))))
>      ;; Override user customization such as display-buffer-same-window
>      ;; and use display-buffer-reuse-window to ensure next-error-last-buffer
>      ;; is displayed somewhere, not necessarily in the same window (bug#32607).
>      (pop-to-buffer next-error-last-buffer)

The first inhibit-same-window should hopefully make the
second unnecessary.  If the first fails to do its job or somehow
indirectly causes the original buffer not to be displayed in the
original window, I'm not really sure what we should do about it.
IOW, for the second part I'm not sure either of
display-buffer-reuse-window or inhibit-same-window is clearly superior
to the other.

Maybe to get closer to "the ideal", we should go for something like:

    (let* ((orig-window (selected-window))
           (orig-buf (window-buffer orig-window)))
      (let ((next-error-highlight next-error-highlight-no-select)
            (display-buffer-overriding-action '(nil (inhibit-same-window . t))))
        (next-error n))
      (cond
       ((eql (window-buffer orig-window) next-error-last-buffer)
        ;; inhibit-same-window did its job, we can just return to the original
        ;; window.
        (select-window orig-window))
       ((eql orig-buf next-error-last-buffer)
        ;; Somehow the original window was affected by `next-error`, so
        ;; we need to work harder to bring the buffer back.
        (select-window orig-window)
        (pop-to-buffer-same-window next-error-last-buffer))
       (t
        ;; Something weird is going on.  We don't really know where we were
        ;; (orig-window was not showing the buffer where we were supposed
        ;; to "stay"), so let's just try and keep both buffers displayed
        ;; while at the same time trying not to gratuitously creating new
        ;; windows either.
        (let ((display-buffer-overriding-action '(display-buffer-reuse-window
                                                  (inhibit-same-window . t))))
          (pop-to-buffer next-error-last-buffer)))))

But maybe we should instead trust inhibit-same-window to do its job and
go for a simple:

      (save-selected-window
        (let ((next-error-highlight next-error-highlight-no-select)
              (display-buffer-overriding-action
               '(nil (inhibit-same-window . t))))
          (next-error n)))


-- Stefan





  reply	other threads:[~2018-09-14  1:34 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-01 22:32 bug#32607: 27.0.50; pop-to-buffer in next-error-no-select Juri Linkov
2018-09-02  7:14 ` martin rudalics
2018-09-02 22:43   ` Juri Linkov
2018-09-03  7:31     ` martin rudalics
2018-09-03 22:31       ` Juri Linkov
2018-09-04  7:51         ` martin rudalics
2018-09-04 21:28           ` Juri Linkov
2018-09-05  7:47             ` martin rudalics
2018-09-05 22:06               ` Juri Linkov
2018-09-06  7:04                 ` martin rudalics
2018-09-06 21:56                   ` Juri Linkov
2018-09-07  6:28                     ` Eli Zaretskii
2018-09-08 23:28                       ` Juri Linkov
2018-09-09  5:44                         ` Eli Zaretskii
2018-09-07  7:28                     ` martin rudalics
2018-09-08 23:46                       ` Juri Linkov
2018-09-09  8:40                         ` martin rudalics
2018-09-09 16:01                           ` Juri Linkov
2018-09-10  8:29                             ` martin rudalics
2018-09-11 23:47                               ` Juri Linkov
2018-09-12  6:33                                 ` martin rudalics
2018-09-12 21:47                                   ` Juri Linkov
2018-09-12 22:03                           ` Stefan Monnier
2018-09-12 22:21                             ` Juri Linkov
2018-09-12 22:06                           ` Stefan Monnier
2018-09-13  7:46                             ` martin rudalics
2018-09-13 11:26                               ` Stefan Monnier
2018-09-13 23:04                                 ` Juri Linkov
2018-09-14  1:34                                   ` Stefan Monnier [this message]
2018-09-15 23:31                                     ` Juri Linkov
2018-09-16  9:09                                       ` martin rudalics
2018-09-16 21:19                                         ` Stefan Monnier

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=jwvh8ishobl.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=32607@debbugs.gnu.org \
    --cc=juri@linkov.net \
    /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).