From: Visuwesh <visuweshm@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 74700@debbugs.gnu.org
Subject: bug#74700: [PATCH] Revert Dired buffer when clicking on last segment of directory name
Date: Thu, 05 Dec 2024 13:56:44 +0530 [thread overview]
Message-ID: <87zflamt6j.fsf@gmail.com> (raw)
In-Reply-To: <86ttbiy5na.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 05 Dec 2024 09:02:01 +0200")
[-- Attachment #1: Type: text/plain, Size: 2192 bytes --]
[வியாழன் டிசம்பர் 05, 2024] Eli Zaretskii wrote:
>> From: Visuwesh <visuweshm@gmail.com>
>> Date: Thu, 05 Dec 2024 11:42:08 +0530
>>
>> 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.
>
> 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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Revert-Dired-buffer-when-clicking-on-basename-of-dir.patch --]
[-- Type: text/x-diff, Size: 1850 bytes --]
From 642338b96d5f39f3b11285fff319f744c1a07164 Mon Sep 17 00:00:00 2001
From: Visuwesh <visuweshm@gmail.com>
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)
---
etc/NEWS | 5 +++++
lisp/dired.el | 11 ++++++++++-
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/etc/NEWS b/etc/NEWS
index e63132efeda..1ed529b0792 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 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 f79a2220bea..9895229694a 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: re-read this buffer's directory"
+ 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
next prev parent reply other threads:[~2024-12-05 8:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-05 6:12 bug#74700: [PATCH] Revert Dired buffer when clicking on last segment of directory name Visuwesh
2024-12-05 7:02 ` Eli Zaretskii
2024-12-05 8:26 ` Visuwesh [this message]
2024-12-05 8:41 ` Eli Zaretskii
2024-12-05 9:02 ` Visuwesh
2024-12-05 9:24 ` Eli Zaretskii
2024-12-05 10:42 ` Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-05 17:56 ` Juri Linkov
2024-12-12 10:31 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87zflamt6j.fsf@gmail.com \
--to=visuweshm@gmail.com \
--cc=74700@debbugs.gnu.org \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.