unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: martin rudalics <rudalics@gmx.at>
To: Stephen Berman <stephen.berman@gmx.net>, Glenn Morris <rgm@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: master b2150e0: Preserve point under 'dired-auto-revert-buffer' (second case)
Date: Wed, 19 Jul 2017 10:18:32 +0200	[thread overview]
Message-ID: <596F15D8.207@gmx.at> (raw)
In-Reply-To: <87a841c056.fsf@rosalinde>

[-- Attachment #1: Type: text/plain, Size: 2375 bytes --]

 > If I debugged this correctly, it seems that the crucial
 > difference is that, on calling quit-window after
 > pop-to-buffer-same-window, the window displaying the directory has a
 > non-nil quit-restore window parameter (in fact, its value contains the
 > buffer visiting the todo-file), while on calling quit-window after
 > switch-to-buffer, the quit-restore window parameter is nil.  Is this
 > correct (cc'ing Martin)?

Yes.  ‘switch-to-buffer’ misses a number of features which make it
behave differently from ‘display-buffer’ based functions.  In
particular, it cannot be used for displaying buffers temporarily.

 > The only difference in the buffer lists of the two outputs is after
 > quit-window (the last line in each output).  Is this difference due to
 > the different quit-restore window parameter values?

‘quit-window’ works on a per window basis.  Earlier the situation was as
follows: Consider two windows showing two different portions of the same
buffer.  If in one of these windows you temporarily worked on another
buffer, then quitting that window would not restore the buffer
previously shown in it because there is already another window showing
that buffer.  Even if it did restore the buffer, it would not have
restored that window's position of point.  ‘quit-window’ simply tries to
restore the buffer as previously shown in that window regardless of what
the buffer list says.

 > If so, I'm not sure
 > what the best course of action is.  This is what's supposed to happen
 > (what the test tests for): (1) the todo-mode buffer is displayed in a
 > window; (2) calling dired makes the window display a directory; (3)
 > calling todo-show makes the window display the todo-mode buffer again;
 > (4) calling todo-quit buries the todo-mode buffer, so the window
 > displays the directory again; (5) now immediately calling quit-window in
 > the directory should not make the window display the todo-mode buffer
 > again, if there is an alternative.  This worked when dired used
 > switch-to-buffer, but no longer works now that dired uses
 > pop-to-buffer-same-window.  I'd be grateful for any advice.

The problematic step is (4).  ‘quit-window’ has no idea of the semantics
of ‘bury-buffer’ (neither do I).  But if no one objects we could install
the attached patch.

martin

[-- Attachment #2: window.el.diff --]
[-- Type: text/plain, Size: 787 bytes --]

diff --git a/lisp/window.el b/lisp/window.el
index 2b979f4..20864c6 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -4627,6 +4627,15 @@ bury-buffer
      ((or buffer-or-name (not (eq buffer (window-buffer)))))
      ((window--delete nil t))
      (t
+      (let ((quit-restore (window-parameter nil 'quit-restore))
+	    quad)
+	(when (and (eq (car quit-restore) 'other)
+		   (consp (setq quad (nth 1 quit-restore)))
+		   (eq (car quad) buffer))
+	  ;; Reset selected window's 'quit-restore' parameter to avoid
+	  ;; that the buffer is restored in that window by a subsequent
+	  ;; ‘quit-window'.
+	  (set-window-parameter nil 'quit-restore nil)))
       ;; Switch to another buffer in window.
       (set-window-dedicated-p nil nil)
       (switch-to-prev-buffer nil 'bury)))

  reply	other threads:[~2017-07-19  8:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20170717091700.5734.53572@vcs0.savannah.gnu.org>
     [not found] ` <20170717091702.497B522E0A@vcs0.savannah.gnu.org>
2017-07-17 23:58   ` master b2150e0: Preserve point under 'dired-auto-revert-buffer' (second case) Glenn Morris
2017-07-18 14:03     ` Stephen Berman
2017-07-19  8:18       ` martin rudalics [this message]
2017-07-19 10:23         ` Stephen Berman

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=596F15D8.207@gmx.at \
    --to=rudalics@gmx.at \
    --cc=emacs-devel@gnu.org \
    --cc=rgm@gnu.org \
    --cc=stephen.berman@gmx.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).