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

From: [email-masked] (GNU bug Tracking System)
Date: Thu, 12 Dec 2024 10:32:02 +0000

Your bug report

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

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
74700: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=74700
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#74700: [PATCH] Revert Dired buffer when clicking on last segment of directory name
From: Eli Zaretskii <[email-masked]>
To: Visuwesh <[email-masked]>
Cc: [email-masked]
Date: Thu, 12 Dec 2024 12:31:15 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

> From: Visuwesh <[email-masked]>
> Cc: [email-masked]
> Date: Thu, 05 Dec 2024 13:56:44 +0530
> 
> > Thanks, a few comments below.
> >
> >> +---
> >> +*** Clicking on last segment of directory reverts buffer
> >> +When 'dired-make-directory-clickable' is non-nil, clicking on the last
> >> +segment of the directory name now reverts the Dired buffer.
> >
> > We don't call these "segments", we call them "components".  And since
> > you are talking about the last one, you could also say "base name of
> > the directory".
> 
> I've changed it to base name.
> 
> >> +        (when (search-forward ":" bound t)
> >> +          (add-text-properties
> >> +           segment-start (1- (point))
> >> +           `( mouse-face highlight
> >                ^^
> > We don't leave whitespace after the opening parenthesis.
> 
> I removed the whitespace.  But isn't that way to make lists such as
> 
>     ( 1
>       2
>       3)
> 
> aligned without manual intervention?  It is used in the list above too.
> 
> >> +              help-echo "mouse-1: revert this buffer"
> >
> > I think the help-echo should say something more similar to what we say
> > for the other components of the directory shown in the header line.
> > Something like "re-read this buffer's directory".
> 
> Now done.
> 
> >> +              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.

Thanks, installed on master, and closing the bug.

Subject: [PATCH] Revert Dired buffer when clicking on last segment of directory name
From: Visuwesh <[email-masked]>
To: [email-masked]
Date: Thu, 05 Dec 2024 11:42:08 +0530
List-Id: <debbugs-submit.debbugs.gnu.org>

Tags: patch

Attached patch makes it possible to revert the current Dired buffer by
clicking on the last segment of the directory line.  With the patch
applied,

  /home/viz/lib/ports/emacs:

clicking on 'emacs' now reverts the buffer that shows ~/lib/ports/emacs.
Previously, it did nothing.  This makes it possible to update the Dired
listing without needing to use the keyboard.

In GNU Emacs 31.0.50 (build 25, x86_64-pc-linux-gnu, X toolkit, cairo
 version 1.18.2, Xaw scroll bars) of 2024-11-10 built on astatine
Repository revision: 1704fa4fb4164a15c7e258b922dbba190811d92d
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101014
System Description: Debian GNU/Linux trixie/sid

Configured using:
 'configure --with-sound=alsa --with-x-toolkit=lucid --without-xaw3d
 --without-gconf --without-libsystemd --with-cairo CFLAGS=-g3'
>From 83da5ad8ef930ed6d093b6b5dec2322599fac763 Mon Sep 17 00:00:00 2001
From: Visuwesh <[email-masked]>
Date: Thu, 5 Dec 2024 11:40:02 +0530
Subject: [PATCH] Revert Dired buffer when clicking on last segment of
 directory name

* lisp/dired.el (dired--make-directory-clickable): Make clicking
on the last segment of the directory line revert the Dired
buffer.
* etc/NEWS: Announce the change.
---
 etc/NEWS      |  5 +++++
 lisp/dired.el | 11 ++++++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/etc/NEWS b/etc/NEWS
index e63132efeda..e35f007dbe1 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -587,6 +587,11 @@ Without 'dired-hide-details-hide-absolute-location':
 
     /absolute/path/to/my/important/project: (100 GiB available)
 
+---
+*** Clicking on last segment of directory reverts buffer
+When 'dired-make-directory-clickable' is non-nil, clicking on the last
+segment of the directory name now reverts the Dired buffer.
+
 ** Grep
 
 +++
diff --git a/lisp/dired.el b/lisp/dired.el
index f79a2220bea..4e300879f88 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -2082,7 +2082,16 @@ dired--make-directory-clickable
                           "<mouse-2>" click
                           "<follow-link>" 'mouse-face
                           "RET" click))))
-          (setq segment-start (point)))))))
+          (setq segment-start (point)))
+        (when (search-forward ":" bound t)
+          (add-text-properties
+           segment-start (1- (point))
+           `( mouse-face highlight
+              help-echo "mouse-1: revert this buffer"
+              keymap ,(define-keymap
+                        "<mouse-2>" #'revert-buffer
+                        "<follow-link>" 'follow-link
+                        "RET" #'revert-buffer))))))))
 
 (defun dired--get-ellipsis-length ()
   "Return length of ellipsis."
-- 
2.45.2