GNU bug report logs - #21973
24.5; feature proposal: make dired header clickable

Previous Next

Package: emacs;

Reported by: William Xu <william.xwl <at> gmail.com>

Date: Sat, 21 Nov 2015 20:04:01 UTC

Severity: wishlist

Found in version 24.5

Fixed in version 29.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 21973 in the body.
You can then email your comments to 21973 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#21973; Package emacs. (Sat, 21 Nov 2015 20:04:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to William Xu <william.xwl <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 21 Nov 2015 20:04:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: William Xu <william.xwl <at> gmail.com>
To: "bug-gnu-emacs <at> gnu.org" <bug-gnu-emacs <at> gnu.org>
Subject: 24.5; feature proposal: make dired header clickable
Date: Sat, 21 Nov 2015 20:03:21 +0000
[Message part 1 (text/plain, inline)]
Sometimes when we are in some deep directory, it would be really
convenient to be able to jump to an arbitrary parent directory shown by
dired header.  e.g., a dired header line may be:

  /this/is/a/really/long/project/dir/curr:

If i want to open dired with `/this/is/a/really', i could simply click
at `really', without having to `^' a few times carefully.

I have something like below in my config file.  But it should be easy to
integrate it with `dired-insert-directory' in dired.el.

---------------------------------8<-------------------------------------
(defun xwl-dired-jump-to-parent (event)
  (interactive "e")
  (let (window pos file)
    (save-excursion
      (setq window (posn-window (event-end event))
            pos (posn-point (event-end event)))
      (with-current-buffer (window-buffer window)
        (goto-char pos)
        (when (search-forward "/" (line-end-position) t 1)
          (let ((beg 3)
                (end (point)))
            (dired (buffer-substring beg end))))))))

(defun xwl-dired-make-header-jumpable ()
  "Click on dired header will jump to that directory directly."
  (let ((inhibit-read-only t))
    (save-excursion
      (goto-char (point-min))
      (let ((bound (line-end-position))
            start end)
        (when (search-forward "/" bound t 1)
          (setq start (point))
          (while (search-forward "/" bound t 1)
            (setq end (1- (point)))
            (add-text-properties start end
                                 `(mouse-face
                                   highlight
                                   help-echo "mouse-1: goto here"
                                   keymap ,(let ((map (make-sparse-keymap)))
                                             (define-key map [down-mouse-1]
'xwl-dired-jump-to-parent)
                                             map)))
            (setq start (point))))))))

(add-hook 'dired-after-readin-hook 'xwl-dired-make-header-jumpable)
---------------------------------8<-------------------------------------

In GNU Emacs 24.5.2 (x86_64-apple-darwin14.5.0, Carbon Version 157 AppKit
1404.13)
 of 2015-11-08 on ULMMAC029
Repository revision: 232183c1fbb3665a51cfb1e9dbd380127bb4a971
Windowing system distributor `Apple Inc.', version 10.11.1
Configured using:
 `configure --with-mac'

- William
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21973; Package emacs. (Sat, 23 Oct 2021 00:01:02 GMT) Full text and rfc822 format available.

Message #8 received at 21973 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: William Xu <william.xwl <at> gmail.com>
Cc: 21973 <at> debbugs.gnu.org
Subject: Re: bug#21973: 24.5; feature proposal: make dired header clickable
Date: Fri, 22 Oct 2021 17:00:05 -0700
William Xu <william.xwl <at> gmail.com> writes:

> Sometimes when we are in some deep directory, it would be really
> convenient to be able to jump to an arbitrary parent directory shown by
> dired header.  e.g., a dired header line may be:
>
>   /this/is/a/really/long/project/dir/curr:
>
> If i want to open dired with `/this/is/a/really', i could simply click
> at `really', without having to `^' a few times carefully.
>
> I have something like below in my config file.  But it should be easy to
> integrate it with `dired-insert-directory' in dired.el.

I didn't read your patch in detail, but the feature sounds like a good
idea.  Could you perhaps write it up as a patch?

> ---------------------------------8<-------------------------------------
> (defun xwl-dired-jump-to-parent (event)
>   (interactive "e")
>   (let (window pos file)
>     (save-excursion
>       (setq window (posn-window (event-end event))
>             pos (posn-point (event-end event)))
>       (with-current-buffer (window-buffer window)
>         (goto-char pos)
>         (when (search-forward "/" (line-end-position) t 1)
>           (let ((beg 3)
>                 (end (point)))
>             (dired (buffer-substring beg end))))))))
>
> (defun xwl-dired-make-header-jumpable ()
>   "Click on dired header will jump to that directory directly."
>   (let ((inhibit-read-only t))
>     (save-excursion
>       (goto-char (point-min))
>       (let ((bound (line-end-position))
>             start end)
>         (when (search-forward "/" bound t 1)
>           (setq start (point))
>           (while (search-forward "/" bound t 1)
>             (setq end (1- (point)))
>             (add-text-properties start end
>                                  `(mouse-face
>                                    highlight
>                                    help-echo "mouse-1: goto here"
>                                    keymap ,(let ((map (make-sparse-keymap)))
>                                              (define-key map [down-mouse-1] 'xwl-dired-jump-to-parent)
>                                              map)))
>             (setq start (point))))))))
>
> (add-hook 'dired-after-readin-hook 'xwl-dired-make-header-jumpable)
> ---------------------------------8<-------------------------------------




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21973; Package emacs. (Sat, 23 Oct 2021 15:46:01 GMT) Full text and rfc822 format available.

Message #11 received at submit <at> debbugs.gnu.org (full text, mbox):

From: William Xu <william.xwl <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#21973: 24.5; feature proposal: make dired header clickable
Date: Sat, 23 Oct 2021 17:45:10 +0200
[Message part 1 (text/plain, inline)]
Stefan Kangas <stefan <at> marxist.se> writes:

> I didn't read your patch in detail, but the feature sounds like a good
> idea.  Could you perhaps write it up as a patch?

Done. 

-- 
William
[0001-Make-Dired-path-segments-jumpable-by-mouse-click-bug.patch (text/x-diff, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21973; Package emacs. (Sat, 23 Oct 2021 16:38:02 GMT) Full text and rfc822 format available.

Message #14 received at 21973 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: William Xu <william.xwl <at> gmail.com>, "21973 <at> debbugs.gnu.org"
 <21973 <at> debbugs.gnu.org>
Subject: RE: [External] : bug#21973: 24.5; feature proposal: make dired header
 clickable
Date: Sat, 23 Oct 2021 16:37:28 +0000
Looked at this only quickly.

+1.  It's a good idea to make dir-listing headers
into, essentially, clickable/RETable breadcrumbs.

I can't speak to whether the patch sent is the
best/right way to do it - don't have time now to
look into it.

But this should be done (maybe optionally, i.e.,
under user control) for each dir header in the
buffer.  That is, do it for inserted subdir
headers, as well as for the first (top-level)
dir header.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21973; Package emacs. (Sun, 24 Oct 2021 11:10:02 GMT) Full text and rfc822 format available.

Message #17 received at submit <at> debbugs.gnu.org (full text, mbox):

From: William Xu <william.xwl <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#21973: [External] : bug#21973: 24.5;
 feature proposal: make dired header clickable
Date: Sun, 24 Oct 2021 13:09:28 +0200
[Message part 1 (text/plain, inline)]
Drew Adams <drew.adams <at> oracle.com> writes:

> Looked at this only quickly.
>
> +1.  It's a good idea to make dir-listing headers
> into, essentially, clickable/RETable breadcrumbs.
>
> I can't speak to whether the patch sent is the
> best/right way to do it - don't have time now to
> look into it.
>
> But this should be done (maybe optionally, i.e.,
> under user control) for each dir header in the
> buffer.  That is, do it for inserted subdir
> headers, as well as for the first (top-level)
> dir header.

I've revised the patch to support also subdir headers in the buffer,
using dired-after-readin-hook. 

-- 
William
[0001-Make-Dired-path-segments-jumpable-by-mouse-click-bug.patch (text/x-diff, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21973; Package emacs. (Sun, 24 Oct 2021 14:08:01 GMT) Full text and rfc822 format available.

Message #20 received at 21973 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: William Xu <william.xwl <at> gmail.com>
Cc: 21973 <at> debbugs.gnu.org
Subject: Re: bug#21973: [External] : bug#21973: 24.5; feature proposal: make
 dired header clickable
Date: Sun, 24 Oct 2021 16:07:30 +0200
William Xu <william.xwl <at> gmail.com> writes:

> I've revised the patch to support also subdir headers in the buffer,
> using dired-after-readin-hook. 

Thanks; looks good to me.  I've now applied this to Emacs 29, but I
rewrote it somewhat so that it works hitting RET on the segments, too.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug marked as fixed in version 29.1, send any further explanations to 21973 <at> debbugs.gnu.org and William Xu <william.xwl <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 24 Oct 2021 14:16:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21973; Package emacs. (Sun, 24 Oct 2021 19:18:02 GMT) Full text and rfc822 format available.

Message #25 received at 21973 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: William Xu <william.xwl <at> gmail.com>, 21973 <at> debbugs.gnu.org
Subject: Re: bug#21973: [External] : bug#21973: 24.5; feature proposal: make
 dired header clickable
Date: Sun, 24 Oct 2021 22:05:23 +0300
>> I've revised the patch to support also subdir headers in the buffer,
>> using dired-after-readin-hook.
>
> Thanks; looks good to me.  I've now applied this to Emacs 29, but I
> rewrote it somewhat so that it works hitting RET on the segments, too.

I tried this out and see that it would be much better to bind it
to [mouse-1] instead of [down-mouse-1] because with [down-mouse-1]
releasing the mouse button moves point to wrong place in the new buffer.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21973; Package emacs. (Sun, 24 Oct 2021 19:21:02 GMT) Full text and rfc822 format available.

Message #28 received at 21973 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: William Xu <william.xwl <at> gmail.com>, 21973 <at> debbugs.gnu.org
Subject: Re: bug#21973: [External] : bug#21973: 24.5; feature proposal: make
 dired header clickable
Date: Sun, 24 Oct 2021 21:20:34 +0200
Juri Linkov <juri <at> linkov.net> writes:

> I tried this out and see that it would be much better to bind it
> to [mouse-1] instead of [down-mouse-1] because with [down-mouse-1]
> releasing the mouse button moves point to wrong place in the new buffer.

Yeah, it should probably be the mysterious incantation

                          [mouse-2] click
                          [follow-link] 'mouse-face

to make it work as it's supposed to for a clickable thing.  I've now
adjusted this.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21973; Package emacs. (Sun, 24 Oct 2021 21:32:01 GMT) Full text and rfc822 format available.

Message #31 received at 21973 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: William Xu <william.xwl <at> gmail.com>, "21973 <at> debbugs.gnu.org"
 <21973 <at> debbugs.gnu.org>
Subject: RE: bug#21973: [External] : bug#21973: 24.5; feature proposal: make
 dired header clickable
Date: Sun, 24 Oct 2021 21:31:34 +0000
> > Looked at this only quickly.
> >
> > +1.  It's a good idea to make dir-listing headers
> > into, essentially, clickable/RETable breadcrumbs.
> >
> > I can't speak to whether the patch sent is the
> > best/right way to do it - don't have time now to
> > look into it.
> >
> > But this should be done (maybe optionally, i.e.,
> > under user control) for each dir header in the
> > buffer.  That is, do it for inserted subdir
> > headers, as well as for the first (top-level)
> > dir header.
> 
> I've revised the patch to support also subdir headers
> in the buffer, using dired-after-readin-hook.

Sounds good.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 22 Nov 2021 12:24:10 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 127 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.