* bug#74700: [PATCH] Revert Dired buffer when clicking on last segment of directory name
@ 2024-12-05 6:12 Visuwesh
2024-12-05 7:02 ` Eli Zaretskii
0 siblings, 1 reply; 14+ messages in thread
From: Visuwesh @ 2024-12-05 6:12 UTC (permalink / raw)
To: 74700
[-- Attachment #1: Type: text/plain, Size: 882 bytes --]
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'
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Revert-Dired-buffer-when-clicking-on-last-segment-of.patch --]
[-- Type: text/patch, Size: 1863 bytes --]
From 83da5ad8ef930ed6d093b6b5dec2322599fac763 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 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
^ permalink raw reply related [flat|nested] 14+ messages in thread
* bug#74700: [PATCH] Revert Dired buffer when clicking on last segment of directory name
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
0 siblings, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2024-12-05 7:02 UTC (permalink / raw)
To: Visuwesh; +Cc: 74700
> 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".
> + (when (search-forward ":" bound t)
> + (add-text-properties
> + segment-start (1- (point))
> + `( mouse-face highlight
^^
We don't leave whitespace after the opening parenthesis.
> + 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".
> + keymap ,(define-keymap
> + "<mouse-2>" #'revert-buffer
> + "<follow-link>" 'follow-link
> + "RET" #'revert-buffer))))))))
Should we perhaps call dired-revert directly?
^ permalink raw reply [flat|nested] 14+ messages in thread
* bug#74700: [PATCH] Revert Dired buffer when clicking on last segment of directory name
2024-12-05 7:02 ` Eli Zaretskii
@ 2024-12-05 8:26 ` Visuwesh
2024-12-05 8:41 ` Eli Zaretskii
2024-12-12 10:31 ` Eli Zaretskii
0 siblings, 2 replies; 14+ messages in thread
From: Visuwesh @ 2024-12-05 8:26 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 74700
[-- 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
^ permalink raw reply related [flat|nested] 14+ messages in thread
* bug#74700: [PATCH] Revert Dired buffer when clicking on last segment of directory name
2024-12-05 8:26 ` Visuwesh
@ 2024-12-05 8:41 ` Eli Zaretskii
2024-12-05 9:02 ` Visuwesh
2024-12-12 10:31 ` Eli Zaretskii
1 sibling, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2024-12-05 8:41 UTC (permalink / raw)
To: Visuwesh; +Cc: 74700
> From: Visuwesh <visuweshm@gmail.com>
> Cc: 74700@debbugs.gnu.org
> Date: Thu, 05 Dec 2024 13:56:44 +0530
>
> >> + (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?
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.
> >> + 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.
What do people think about this?
^ permalink raw reply [flat|nested] 14+ messages in thread
* bug#74700: [PATCH] Revert Dired buffer when clicking on last segment of directory name
2024-12-05 8:41 ` Eli Zaretskii
@ 2024-12-05 9:02 ` Visuwesh
2024-12-05 9:24 ` Eli Zaretskii
2024-12-05 17:56 ` Juri Linkov
0 siblings, 2 replies; 14+ messages in thread
From: Visuwesh @ 2024-12-05 9:02 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 74700
[வியாழன் டிசம்பர் 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.
^ permalink raw reply related [flat|nested] 14+ messages in thread
* bug#74700: [PATCH] Revert Dired buffer when clicking on last segment of directory name
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
1 sibling, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2024-12-05 9:24 UTC (permalink / raw)
To: Visuwesh; +Cc: 74700
> From: Visuwesh <visuweshm@gmail.com>
> Cc: 74700@debbugs.gnu.org
> 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.
Yes, and why is that a problem? This is the standard Lisp indentation
in Emacs. It makes it easy to find the end of the sexps.
> Adding a space after ( prevents this.
I'm not sure I understand why overriding the standard indentation
would be a good idea.
^ permalink raw reply [flat|nested] 14+ messages in thread
* bug#74700: [PATCH] Revert Dired buffer when clicking on last segment of directory name
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
0 siblings, 0 replies; 14+ messages in thread
From: Stephen Berman via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-12-05 10:42 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 74700, Visuwesh
On Thu, 05 Dec 2024 11:24:23 +0200 Eli Zaretskii <eliz@gnu.org> wrote:
>> From: Visuwesh <visuweshm@gmail.com>
>> Cc: 74700@debbugs.gnu.org
>> 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.
>
> Yes, and why is that a problem? This is the standard Lisp indentation
> in Emacs. It makes it easy to find the end of the sexps.
>
>> Adding a space after ( prevents this.
>
> I'm not sure I understand why overriding the standard indentation
> would be a good idea.
Sometimes the standard indentation makes the code harder to read, e.g.,
the sexp that the indentation in Visuwesh's patch took as an example is
this (starting at column 10):
(add-text-properties
segment-start (1- (point))
`( mouse-face highlight
help-echo "mouse-1: goto this directory"
keymap ,(let* ((current-dir dir)
(click (lambda ()
(interactive)
(cond
((assoc current-dir dired-subdir-alist)
(dired-goto-subdir current-dir))
;; If there is a wildcard chars
;; in the directory name, don't
;; use the alternate file machinery
;; which tries to keep only one
;; dired buffer open at once.
;;
;; FIXME: Is this code path reachable?
((insert-directory-wildcard-in-dir-p
current-dir)
(dired current-dir))
(t
(dired--find-possibly-alternative-file
current-dir))))))
(define-keymap
"<mouse-2>" click
"<follow-link>" 'mouse-face
"RET" click))))
Here is the indentation without the space (in dired.el several lines of
this code extend well beyond column 80):
(add-text-properties
segment-start (1- (point))
`(mouse-face highlight
help-echo "mouse-1: goto this directory"
keymap ,(let* ((current-dir dir)
(click (lambda ()
(interactive)
(cond
((assoc current-dir dired-subdir-alist)
(dired-goto-subdir current-dir))
;; If there is a wildcard chars
;; in the directory name, don't
;; use the alternate file machinery
;; which tries to keep only one
;; dired buffer open at once.
;;
;; FIXME: Is this code path reachable?
((insert-directory-wildcard-in-dir-p
current-dir)
(dired current-dir))
(t
(dired--find-possibly-alternative-file
current-dir))))))
(define-keymap
"<mouse-2>" click
"<follow-link>" 'mouse-face
"RET" click))))
Steve Berman
^ permalink raw reply [flat|nested] 14+ messages in thread
* bug#74700: [PATCH] Revert Dired buffer when clicking on last segment of directory name
2024-12-05 9:02 ` Visuwesh
2024-12-05 9:24 ` Eli Zaretskii
@ 2024-12-05 17:56 ` Juri Linkov
1 sibling, 0 replies; 14+ messages in thread
From: Juri Linkov @ 2024-12-05 17:56 UTC (permalink / raw)
To: Visuwesh; +Cc: Eli Zaretskii, 74700
> but I think clicking on 'emacs' to open the Dired buffer for
> ~/lib/ports/emacs is also a good option.
Indeed, opening the Dired buffer would be better
instead of directly refreshing the buffer.
To force the directory to refresh, you can call dired with:
(let ((dired-auto-revert-buffer t)) (dired "/..."))
^ permalink raw reply [flat|nested] 14+ messages in thread
* bug#74700: [PATCH] Revert Dired buffer when clicking on last segment of directory name
2024-12-05 8:26 ` Visuwesh
2024-12-05 8:41 ` Eli Zaretskii
@ 2024-12-12 10:31 ` Eli Zaretskii
2024-12-23 21:31 ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors
1 sibling, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2024-12-12 10:31 UTC (permalink / raw)
To: Visuwesh; +Cc: 74700-done
> From: Visuwesh <visuweshm@gmail.com>
> Cc: 74700@debbugs.gnu.org
> 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.
^ permalink raw reply [flat|nested] 14+ messages in thread
* bug#74700: [PATCH] Revert Dired buffer when clicking on last segment of directory name
2024-12-12 10:31 ` Eli Zaretskii
@ 2024-12-23 21:31 ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-24 3:22 ` Visuwesh
0 siblings, 1 reply; 14+ messages in thread
From: Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-12-23 21:31 UTC (permalink / raw)
To: 74700; +Cc: eliz, visuweshm, Dieter Faulbaum, michael_heerdegen
Hello,
a user on emacs-help (Dieter, CC'd) mentioned that in contrast to hitting g,
reverting with this new method loses the position of point, instead,
point is repositioned at the beginning of the buffer. And I agree that
this is not the optimal behavior. Can we maybe improve this?
Thx,
Michael.
^ permalink raw reply [flat|nested] 14+ messages in thread
* bug#74700: [PATCH] Revert Dired buffer when clicking on last segment of directory name
2024-12-23 21:31 ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-12-24 3:22 ` Visuwesh
2024-12-24 23:39 ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 14+ messages in thread
From: Visuwesh @ 2024-12-24 3:22 UTC (permalink / raw)
To: Michael Heerdegen; +Cc: eliz, 74700
[திங்கள் டிசம்பர் 23, 2024] Michael Heerdegen wrote:
> Hello,
>
> a user on emacs-help (Dieter, CC'd) mentioned that in contrast to hitting g,
> reverting with this new method loses the position of point, instead,
> point is repositioned at the beginning of the buffer. And I agree that
> this is not the optimal behavior. Can we maybe improve this?
>
I didn't notice this, thanks for bringing this to my attention. This
also caught another bug that I would not have noticed since I have
mouse-autoselect-window set non-nil. With the following patch, using
mouse-2 on the base name reverts the buffer without moving point.
However, using mouse-1 still moves the point to bob. I believe we could
fix it by directly binding mouse-1 but I would like to respect
mouse-1-click-follows-link like the rest of the code in the function.
I cannot tell how to prevent mouse-1 from moving point reading the Info
nodes (info "(elisp) Clickable Text") and (info "(emacs) Mouse
References"). I tried
(with-selected-window (posn-window (event-start e)) ...)
to no avail. This goes beyond my level of knowledge so someone else
will have to take care of this. But please install the following patch
because without it using mouse-2 on the base name tries to revert the
current-buffer instead of the dired buffer when the dired buffer is not
shown in the selected window.
diff -u --label /home/viz/lib/ports/emacs/lisp/dired.el --label \#\<buffer\ dired.el\> /home/viz/lib/ports/emacs/lisp/dired.el /tmp/buffer-content-C8kgcN
--- /home/viz/lib/ports/emacs/lisp/dired.el
+++ #<buffer dired.el>
@@ -2089,8 +2089,10 @@
`( mouse-face highlight
help-echo "mouse-1: revert this buffer"
keymap ,(define-keymap
- "<mouse-2>" #'revert-buffer
- "<follow-link>" 'follow-link
+ "<mouse-2>" (lambda (_)
+ (interactive "@e")
+ (revert-buffer))
+ "<follow-link>" 'mouse-face
"RET" #'revert-buffer))))))))
(defun dired--get-ellipsis-length ()
Diff finished. Tue Dec 24 08:40:30 2024
^ permalink raw reply [flat|nested] 14+ messages in thread
* bug#74700: [PATCH] Revert Dired buffer when clicking on last segment of directory name
2024-12-24 3:22 ` Visuwesh
@ 2024-12-24 23:39 ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-25 3:43 ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-25 4:47 ` Visuwesh
0 siblings, 2 replies; 14+ messages in thread
From: Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-12-24 23:39 UTC (permalink / raw)
To: Visuwesh; +Cc: eliz, 74700
Visuwesh <visuweshm@gmail.com> writes:
> [திங்கள் டிசம்பர் 23, 2024] Michael Heerdegen wrote:
>
> > Hello,
> >
> > a user on emacs-help (Dieter, CC'd) mentioned that in contrast to
> > hitting g,
> > reverting with this new method loses the position of point, instead,
> > point is repositioned at the beginning of the buffer. And I agree that
> > this is not the optimal behavior. Can we maybe improve this?
> >
>
> I didn't notice this, thanks for bringing this to my attention. This
> also caught another bug that I would not have noticed since I have
> mouse-autoselect-window set non-nil.
> With the following patch, using mouse-2 on the base name reverts the
> buffer without moving point.
Thank you.
> However, using mouse-1 still moves the point to bob. I believe we
> could fix it by directly binding mouse-1 but I would like to respect
> mouse-1-click-follows-link like the rest of the code in the function.
> I cannot tell how to prevent mouse-1 from moving point reading the
> Info nodes (info "(elisp) Clickable Text") and (info "(emacs) Mouse
> References"). I tried
>
> (with-selected-window (posn-window (event-start e)) ...)
>
> to no avail.
Was that code line the attempt to fix the problem that the buffer in the
wrong window was being reverted, or the attempt to fix the mouse-1
problem?
> This goes beyond my level of knowledge so someone else will have to
> take care of this. But please install the following patch because
> without it using mouse-2 on the base name tries to revert the
> current-buffer instead of the dired buffer when the dired buffer is
> not shown in the selected window.
> +++ #<buffer dired.el>
> @@ -2089,8 +2089,10 @@
> `( mouse-face highlight
> help-echo "mouse-1: revert this buffer"
> keymap ,(define-keymap
> - "<mouse-2>" #'revert-buffer
> - "<follow-link>" 'follow-link
> + "<mouse-2>" (lambda (_)
> + (interactive "@e")
> + (revert-buffer))
> + "<follow-link>" 'mouse-face
I don't know how to fix the mouse-1 problem in a sensible way either.
Does anyone?
(And I think in this version the "e" code in `interactive' isn't
significant - but let's first see if we can improve the behavior even
more.)
Thx,
Michael.
^ permalink raw reply [flat|nested] 14+ messages in thread
* bug#74700: [PATCH] Revert Dired buffer when clicking on last segment of directory name
2024-12-24 23:39 ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-12-25 3:43 ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-25 4:47 ` Visuwesh
1 sibling, 0 replies; 14+ messages in thread
From: Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-12-25 3:43 UTC (permalink / raw)
To: Michael Heerdegen, Visuwesh; +Cc: eliz@gnu.org, 74700@debbugs.gnu.org
> > `( mouse-face highlight
> > help-echo "mouse-1: revert this buffer"
> > keymap ,(define-keymap
> > - "<mouse-2>" #'revert-buffer
> > - "<follow-link>" 'follow-link
> > + "<mouse-2>" (lambda (_)
> > + (interactive "@e")
> > + (revert-buffer))
> > + "<follow-link>" 'mouse-face
>
> I don't know how to fix the mouse-1 problem in a sensible way either.
> Does anyone?
>
> (And I think in this version the "e" code in `interactive' isn't
> significant - but let's first see if we can improve the behavior even
> more.)
I don't understand the problem. Is it that you think
someone might want to have `mouse-1' on the leaf
breadcrumbs component (the default directory) just set
point there - on the header line? I can't imagine that.
I just bind both `mouse-1' and `mouse-2' to the same
command there, `revert-buffer'.
(On nonleaf breadcrumb components I bind `mouse-1' and
`mouse-2' to different commands, to invoke Dired on
the component's directory in the same, and in another,
window, respectively.)
^ permalink raw reply [flat|nested] 14+ messages in thread
* bug#74700: [PATCH] Revert Dired buffer when clicking on last segment of directory name
2024-12-24 23:39 ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-25 3:43 ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-12-25 4:47 ` Visuwesh
1 sibling, 0 replies; 14+ messages in thread
From: Visuwesh @ 2024-12-25 4:47 UTC (permalink / raw)
To: Michael Heerdegen; +Cc: eliz, 74700
[புதன் டிசம்பர் 25, 2024] Michael Heerdegen wrote:
>> However, using mouse-1 still moves the point to bob. I believe we
>> could fix it by directly binding mouse-1 but I would like to respect
>> mouse-1-click-follows-link like the rest of the code in the function.
>> I cannot tell how to prevent mouse-1 from moving point reading the
>> Info nodes (info "(elisp) Clickable Text") and (info "(emacs) Mouse
>> References"). I tried
>>
>> (with-selected-window (posn-window (event-start e)) ...)
>>
>> to no avail.
>
> Was that code line the attempt to fix the problem that the buffer in the
> wrong window was being reverted, or the attempt to fix the mouse-1
> problem?
It was an attempt to fix the mouse-1 problem. The former issue is fixed
with the following patch.
>> This goes beyond my level of knowledge so someone else will have to
>> take care of this. But please install the following patch because
>> without it using mouse-2 on the base name tries to revert the
>> current-buffer instead of the dired buffer when the dired buffer is
>> not shown in the selected window.
>
>> +++ #<buffer dired.el>
>> @@ -2089,8 +2089,10 @@
>> `( mouse-face highlight
>> help-echo "mouse-1: revert this buffer"
>> keymap ,(define-keymap
>> - "<mouse-2>" #'revert-buffer
>> - "<follow-link>" 'follow-link
>> + "<mouse-2>" (lambda (_)
>> + (interactive "@e")
>> + (revert-buffer))
>> + "<follow-link>" 'mouse-face
>
> I don't know how to fix the mouse-1 problem in a sensible way either.
> Does anyone?
>
> (And I think in this version the "e" code in `interactive' isn't
> significant - but let's first see if we can improve the behavior even
> more.)
Indeed, I thought @ had to go with e _always_.
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2024-12-25 4:47 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
2024-12-23 21:31 ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-24 3:22 ` Visuwesh
2024-12-24 23:39 ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-25 3:43 ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-25 4:47 ` Visuwesh
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).