Subject: bug#27243: closed (Re: bug#27243: dired-auto-revert-buffer jumps point to beginning of buffer)

From: Antoine Levitt <[email-masked]>
Date: Sat, 22 Jul 2017 17:28:59 +0200

Sorry to be the bearer of bad news, but still not completely fixed ;-)
>From emacs -Q, (setq dired-auto-revert-buffer t), C-x C-f RET, C-x b
RET, C-x C-f RET, and point jumps.

17 July 2017 11:22 +02, Stephen Berman <[email-masked]>:
> On Sun, 09 Jul 2017 19:37:53 +0200 Antoine Levitt <[email-masked]> wrote:
>
>> Works for me, feel free to merge!
>>
>> Best,
>> Antoine
>>
>> 17 June 2017 15:32 +02, Stephen Berman <[email-masked]>:
>>> On Sat, 17 Jun 2017 14:16:01 +0200 Antoine Levitt <[email-masked]> wrote:
>>>
>>>> I just noticed this is not yet completely fixed: starting from emacs -Q,
>>>> (setq dired-auto-revert-buffer t), open dired, open any file in that
>>>> directory, C-x d RET to run dired again, the point jumps back to the
>>>> beginning of the buffer.
>>>
>>> I suppose the command `dired' should not use switch-to-buffer.  With the
>>> following patch, executing the above recipe does not move point.
>>>
>>> diff --git a/lisp/dired.el b/lisp/dired.el
>>> index 8396652d50..aa59f01af9 100644
>>> --- a/lisp/dired.el
>>> +++ b/lisp/dired.el
>>> @@ -786,7 +786,8 @@ dired
>>>  If DIRNAME is already in a Dired buffer, that buffer is used without refresh."
>>>    ;; Cannot use (interactive "D") because of wildcards.
>>>    (interactive (dired-read-dir-and-switches ""))
>>> -  (switch-to-buffer (dired-noselect dirname switches)))
>>> +  (set-window-buffer (selected-window)
>>> +                     (set-buffer (dired-noselect dirname switches))))
>>>  
>>>  ;;;###autoload (define-key ctl-x-4-map "d" 'dired-other-window)
>>>  ;;;###autoload
>>>
>>> Steve Berman
>
> On Sat, 15 Jul 2017 09:36:41 +0200 martin rudalics <[email-masked]> wrote:
>
>>> +  (set-window-buffer (selected-window)
>>> +                     (set-buffer (dired-noselect dirname switches))))
>>
>> This really should be
>>
>>      (pop-to-buffer-same-window (dired-noselect dirname switches))
>>
>> Even if people disliked it in the past and some still dislike it: Try
>>
>> C-h f
>> M-x dired
>
> I installed the fix Martin recommended to master as commit b2150e0
> (after confirming that it indeed DTRT).  I also added a test for this
> case and the first one.
>
> Steve Berman