From 83da5ad8ef930ed6d093b6b5dec2322599fac763 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 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 "" 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: revert this buffer" + keymap ,(define-keymap + "" #'revert-buffer + "" 'follow-link + "RET" #'revert-buffer)))))))) (defun dired--get-ellipsis-length () "Return length of ellipsis." -- 2.45.2