From 9f8621f4050b56a1b14f58d6e53e4d09f33a9a34 Mon Sep 17 00:00:00 2001 From: Visuwesh Date: Thu, 5 Dec 2024 11:40:02 +0530 Subject: [PATCH] Revert Dired buffer when clicking on basename of directory * lisp/dired.el (dired--make-directory-clickable): Make clicking on basename of the directory revert the Dired buffer. * etc/NEWS: Announce the change. (Bug#74700) (cherry picked from commit eb9ba4830e4c7853150eaed93f89225c00d6e52a) --- etc/NEWS | 5 +++++ lisp/dired.el | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/etc/NEWS b/etc/NEWS index 19825bfea68..694a0e49b05 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -574,6 +574,11 @@ Without dired-hide-details-hide-absolute-location: /absolute/path/to/my/important/project: (100 GiB available) +--- +*** Clicking on base name of directory reverts buffer. +When 'dired-make-directory-clickable' is non-nil, clicking on the base +name of the directory now reverts the Dired buffer. + ** Grep +++ diff --git a/lisp/dired.el b/lisp/dired.el index bf19f247c81..8999c55004b 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -2075,7 +2075,16 @@ mouse-2: visit this file in other window" "" click "" '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: re-read this buffer's directory" + keymap ,(define-keymap + "" #'revert-buffer + "" 'follow-link + "RET" #'revert-buffer)))))))) (defun dired--get-ellipsis-length () "Return length of ellipsis." -- 2.39.2