Subject: Re: bug#74700: [PATCH] Revert Dired buffer when clicking on last segment of directory name

From: Visuwesh <[email-masked]>
Date: Thu, 05 Dec 2024 14:32:18 +0530

[வியாழன் டிசம்பர் 05, 2024] Eli Zaretskii wrote:

>> I removed the whitespace.  But isn't that way to make lists such as
>> 
>>     ( 1
>>       2
>>       3)
>> 
>> aligned without manual intervention?
>
> Typing something like
>
>    (setq foo (1
>               2
>               3)
>
> aligns the members for me.  So I don't think I understand what you are
> saying here.

Try to align

    (setq foo '(1 2
                3))

instead.  3 would end up aligning at 2 instead of 1.  Adding a space
after ( prevents this.

>> >> +              keymap ,(define-keymap
>> >> +                        "<mouse-2>" #'revert-buffer
>> >> +                        "<follow-link>" 'follow-link
>> >> +                        "RET" #'revert-buffer))))))))
>> >
>> > Should we perhaps call dired-revert directly?
>> 
>> revert-buffer-function is set to dired-revert by dired.  If someone has
>> changed it, for some reason, using revert-buffer would heed their
>> customisation.  So I've left it as revert-buffer.
>
> That's exactly what I wonder: should we call whatever customized value
> of revert-buffer-function?  It could be something completely
> different, not a function that refreshes the directory listing.

I was about to point out find-dired's value of revert-buffer-function
which is different than dired-revert but as the directory is inserted as

    /home/user/lib/ports/emacs/

always, the change wouldn't affect the 'emacs' part.  We could "fix"
this as

diff --git a/lisp/find-dired.el b/lisp/find-dired.el
index 13c8bf722c3..12fc64c2151 100644
--- a/lisp/find-dired.el
+++ b/lisp/find-dired.el
@@ -281,7 +281,7 @@ find-dired-with-command
     (setq buffer-read-only nil)
     ;; Subdir headlerline must come first because the first marker in
     ;; subdir-alist points there.
-    (insert "  " dir ":\n")
+    (insert "  " (directory-file-name dir) ":\n")
     (when dired-make-directory-clickable
       (dired--make-directory-clickable))
     ;; Make second line a ``find'' line in analogy to the ``total'' or

to make it insert

    /home/user/lib/ports/emacs

but I think clicking on 'emacs' to open the Dired buffer for
~/lib/ports/emacs is also a good option.