unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stephen Berman <stephen.berman@gmx.net>
To: Glenn Morris <rgm@gnu.org>
Cc: martin rudalics <rudalics@gmx.at>, emacs-devel@gnu.org
Subject: Re: master b2150e0: Preserve point under 'dired-auto-revert-buffer' (second case)
Date: Tue, 18 Jul 2017 16:03:49 +0200	[thread overview]
Message-ID: <87a841c056.fsf@rosalinde> (raw)
In-Reply-To: <nak236sjia.fsf@fencepost.gnu.org> (Glenn Morris's message of "Mon, 17 Jul 2017 19:58:53 -0400")

On Mon, 17 Jul 2017 19:58:53 -0400 Glenn Morris <rgm@gnu.org> wrote:

> Stephen Berman wrote:
>
>> branch: master
>> commit b2150e0b02fa4a7ad4c1461e0b4ff8fd632c0fb8
>
> This change causes todo-test-todo-quit02 (which uses dired) to fail.
>
> Ref eg http://hydra.nixos.org/build/56529421

Sorry about that; I swear to Saint IGNUcius I'll always run `make check'
before pushing any future test changes.

I think I see what the problem is, but I don't know what to do about it.

The test fails now because, after the change to dired (replacing
switch-to-buffer by pop-to-buffer-same-window), calling quit-window in
the directory results in buffer-list returning a different order of the
buffers than the order returned before the change, and the test assumes
the previous order (as does todo-quit, which is what is being tested
here).  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)?

Here is a recipe that shows the same effect without using todo-mode or
dired:

Start Emacs with -Q and evaluate the following sexp:

(progn
  (require 'cl-lib)
  (defun bl (l)
    (cl-remove-if (lambda (x) (string-match " \\*" (buffer-name x))) l))
  (message "First: %S" (bl (buffer-list)))
  (set-window-buffer (selected-window)
                     (set-buffer (find-file-noselect "bla")))
  (message "After s-w-b 1: %S" (bl (buffer-list)))
  (pop-to-buffer-same-window default-directory)
  (message "After pop: %S" (bl (buffer-list)))
  ;; (switch-to-buffer default-directory)
  ;; (message "After switch: %S" (bl (buffer-list)))
  (set-window-buffer (selected-window)
                     (set-buffer (find-file-noselect "bla")))
  (message "After s-w-b 2: %S" (bl (buffer-list)))
  (bury-buffer)
  (message "After bury-buffer: %S" (bl (buffer-list)))
  (quit-window)
  (message "After quit-window: %S" (bl (buffer-list))))

This is what *Messages* shows:

First: (#<buffer *scratch*> #<buffer *Messages*>)
(New file)
After s-w-b 1: (#<buffer *scratch*> #<buffer *Messages*> #<buffer bla>)
After pop: (#<buffer /home/steve/> #<buffer *scratch*> #<buffer *Messages*> #<buffer bla>)
After s-w-b 2: (#<buffer /home/steve/> #<buffer *scratch*> #<buffer *Messages*> #<buffer bla>)
After bury-buffer: (#<buffer /home/steve/> #<buffer *scratch*> #<buffer *Messages*> #<buffer bla>)
After quit-window: (#<buffer bla> #<buffer *scratch*> #<buffer *Messages*> #<buffer /home/steve/>)

Now start Emacs with -Q again, yank in the above sexp, uncomment the two
commented out lines and comment out the two lines preceding these (so
switch-to-buffer and the appropriate message are used), then evaluate
the sexp; now *Messages* shows this:

First: (#<buffer *scratch*> #<buffer *Messages*>)
(New file)
After s-w-b 1: (#<buffer *scratch*> #<buffer *Messages*> #<buffer bla>)
After switch: (#<buffer /home/steve/> #<buffer *scratch*> #<buffer *Messages*> #<buffer bla>)
After s-w-b 2: (#<buffer /home/steve/> #<buffer *scratch*> #<buffer *Messages*> #<buffer bla>)
After bury-buffer: (#<buffer /home/steve/> #<buffer *scratch*> #<buffer *Messages*> #<buffer bla>)
After quit-window: (#<buffer *scratch*> #<buffer *Messages*> #<buffer bla> #<buffer /home/steve/>)

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

Steve Berman



  reply	other threads:[~2017-07-18 14:03 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 [this message]
2017-07-19  8:18       ` martin rudalics
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=87a841c056.fsf@rosalinde \
    --to=stephen.berman@gmx.net \
    --cc=emacs-devel@gnu.org \
    --cc=rgm@gnu.org \
    --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).