emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: master b2150e0: Preserve point under 'dired-auto-revert-buffer' (sec


From: Stephen Berman
Subject: Re: master b2150e0: Preserve point under 'dired-auto-revert-buffer' (second case)
Date: Tue, 18 Jul 2017 16:03:49 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

On Mon, 17 Jul 2017 19:58:53 -0400 Glenn Morris <address@hidden> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]