From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: William Xu Newsgroups: gmane.emacs.bugs Subject: bug#21973: 24.5; feature proposal: make dired header clickable Date: Sat, 23 Oct 2021 17:45:10 +0200 Organization: the Church of Emacs Message-ID: <87fssr68zd.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16277"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) To: 21973@debbugs.gnu.org Cancel-Lock: sha1:bwQd6/lFn16U3uAdzcbEDJ0+SN0= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Oct 23 17:46:14 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1meJDp-0003w2-97 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 23 Oct 2021 17:46:13 +0200 Original-Received: from localhost ([::1]:55272 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1meJDn-00066Z-NN for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 23 Oct 2021 11:46:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33446) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1meJDe-00065Y-DY for bug-gnu-emacs@gnu.org; Sat, 23 Oct 2021 11:46:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:53667) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1meJDd-0003ze-RD for bug-gnu-emacs@gnu.org; Sat, 23 Oct 2021 11:46:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1meJDd-0007rK-Of for bug-gnu-emacs@gnu.org; Sat, 23 Oct 2021 11:46:01 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: Resent-From: William Xu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 23 Oct 2021 15:46:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21973 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.163500393030155 (code B ref -1); Sat, 23 Oct 2021 15:46:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 23 Oct 2021 15:45:30 +0000 Original-Received: from localhost ([127.0.0.1]:36980 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1meJD7-0007qJ-DE for submit@debbugs.gnu.org; Sat, 23 Oct 2021 11:45:29 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:58598) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1meJD6-0007q6-8Q for submit@debbugs.gnu.org; Sat, 23 Oct 2021 11:45:28 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33292) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1meJD5-0005uG-QT for bug-gnu-emacs@gnu.org; Sat, 23 Oct 2021 11:45:28 -0400 Original-Received: from ciao.gmane.io ([116.202.254.214]:49502) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1meJCz-0003a1-IU for bug-gnu-emacs@gnu.org; Sat, 23 Oct 2021 11:45:24 -0400 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1meJCw-0002qK-2p for bug-gnu-emacs@gnu.org; Sat, 23 Oct 2021 17:45:18 +0200 X-Injected-Via-Gmane: http://gmane.org/ Received-SPF: pass client-ip=116.202.254.214; envelope-from=geb-bug-gnu-emacs@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_ADSP_CUSTOM_MED=0.001, FORGED_GMAIL_RCVD=1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, NML_ADSP_CUSTOM_MED=0.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:217998 Archived-At: --=-=-= Content-Type: text/plain Stefan Kangas 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 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Make-Dired-path-segments-jumpable-by-mouse-click-bug.patch >From 7a6ddf62541b65876cbc210fe7e49197ab8908a3 Mon Sep 17 00:00:00 2001 From: William Xu Date: Sat, 23 Oct 2021 17:07:21 +0200 Subject: [PATCH] Make Dired path segments jumpable by mouse click (bug#21973) * lisp/dired.el (dired-readin): Call dired-make-path-jumpable. (dired-make-path-jumpable, dired-jump-to-path-segment): New functions. --- lisp/dired.el | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/lisp/dired.el b/lisp/dired.el index 4652589122..ba9fa21f89 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -1317,10 +1317,11 @@ dired-readin (erase-buffer) (dired-readin-insert)) (goto-char (point-min)) - ;; Must first make alist buffer local and set it to nil because + ;; Must first make alist buffer local and set it to nil because ;; dired-build-subdir-alist will call dired-clear-alist first (setq-local dired-subdir-alist nil) (dired-build-subdir-alist)) + (dired-make-path-jumpable) (let ((attributes (file-attributes dirname))) (if (eq (car attributes) t) (set-visited-file-modtime (file-attribute-modification-time @@ -1643,6 +1644,43 @@ dired-insert-set-properties 'invisible 'dired-hide-details-link)))) (forward-line 1)))) +(defun dired-make-path-jumpable () + "Make dired path line at top jumpable." + (let ((inhibit-read-only t)) + (save-excursion + (goto-char (point-min)) + (let ((bound (line-end-position)) + segment-start segment-end) + (when (search-forward "/" bound t 1) + (setq segment-start (point)) + (while (search-forward "/" bound t 1) + (setq segment-end (1- (point))) + (add-text-properties segment-start segment-end + `(mouse-face + highlight + help-echo "mouse-1: goto here" + keymap ,(let ((map (make-sparse-keymap))) + (define-key map [down-mouse-1] 'dired-jump-to-path-segment) + map))) + (setq segment-start (point)))))))) + +(defun dired-jump-to-path-segment (event) + "Jump to the directory from a segment of the dired path." + (interactive "e") + (let* ((ev (event-end event)) + (window (posn-window ev)) + (pos (posn-point ev))) + (with-current-buffer (window-buffer window) + (save-excursion + (goto-char pos) + (when (search-forward "/" (line-end-position) t 1) + (let ((end (point)) + beg) + (while (search-backward "/" (line-beginning-position) t 1) + (setq beg (point))) + (when beg + (dired (buffer-substring-no-properties beg end))))))))) + ;;; Reverting a dired buffer -- 2.25.1 --=-=-=--