From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.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, 21 Nov 2015 20:03:21 +0000 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11477b7e7f4ddc0525127cc4 X-Trace: ger.gmane.org 1448136256 5049 80.91.229.3 (21 Nov 2015 20:04:16 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 21 Nov 2015 20:04:16 +0000 (UTC) To: 21973@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Nov 21 21:04:10 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1a0EOG-0000DX-JR for geb-bug-gnu-emacs@m.gmane.org; Sat, 21 Nov 2015 21:04:09 +0100 Original-Received: from localhost ([::1]:53502 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a0EOG-0008AC-9r for geb-bug-gnu-emacs@m.gmane.org; Sat, 21 Nov 2015 15:04:08 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45990) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a0EOB-00089w-Q5 for bug-gnu-emacs@gnu.org; Sat, 21 Nov 2015 15:04:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a0EOA-0002y7-Lr for bug-gnu-emacs@gnu.org; Sat, 21 Nov 2015 15:04:03 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:57605) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a0EOA-0002y2-IJ for bug-gnu-emacs@gnu.org; Sat, 21 Nov 2015 15:04:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1a0EOA-0007Jh-6g for bug-gnu-emacs@gnu.org; Sat, 21 Nov 2015 15:04:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: William Xu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 21 Nov 2015 20:04:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 21973 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: "bug-gnu-emacs@gnu.org" Original-Received: via spool by submit@debbugs.gnu.org id=B.144813623828109 (code B ref -1); Sat, 21 Nov 2015 20:04:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 21 Nov 2015 20:03:58 +0000 Original-Received: from localhost ([127.0.0.1]:47313 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1a0EO5-0007JI-PP for submit@debbugs.gnu.org; Sat, 21 Nov 2015 15:03:58 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:35916) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1a0ENl-0007It-7W for submit@debbugs.gnu.org; Sat, 21 Nov 2015 15:03:55 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a0ENj-0002qR-NE for submit@debbugs.gnu.org; Sat, 21 Nov 2015 15:03:36 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:60106) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a0ENj-0002qN-KV for submit@debbugs.gnu.org; Sat, 21 Nov 2015 15:03:35 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45920) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a0ENi-00085d-Cl for bug-gnu-emacs@gnu.org; Sat, 21 Nov 2015 15:03:35 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a0ENh-0002oq-4w for bug-gnu-emacs@gnu.org; Sat, 21 Nov 2015 15:03:34 -0500 Original-Received: from mail-wm0-x233.google.com ([2a00:1450:400c:c09::233]:36547) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a0ENg-0002om-Rr for bug-gnu-emacs@gnu.org; Sat, 21 Nov 2015 15:03:33 -0500 Original-Received: by wmww144 with SMTP id w144so54973770wmw.1 for ; Sat, 21 Nov 2015 12:03:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=U6T8pzATAzW5q7PJ3flV0+iQDR6l5HKjc49FbnCH6TE=; b=UoBbRIY7YVCNrwsGnIGSgOPPXaTt7KjigRnXyE7GVCUXMZrlezSpl7FluordjLnw89 eXFsfCkY95bJKq8KqjExyJhAp9MlxGVtIjbmWP1jBjGYj6bxQSE66qOFdZNcjtef/pMQ o/+xKQFR1ZN9Bq8amtfbDy91+d5fCGTU6RdMVWpiNzC8Gqk2RnSroZU/Qa0zYMXRPAgF pjI2WQ59xsEiX7QhR77479ipd930tHwY3L4UeyitSjo1jLIJUBqQWiUVo1NKpMGfc7Ig k3CuSJ9e372IvwZhS5sZzcuR+qHKDDzy/52jHW05wCqFXA7vIO4OFhzD3a/Y4BV9hIXs ncsw== X-Received: by 10.28.234.200 with SMTP id g69mr9631121wmi.97.1448136211907; Sat, 21 Nov 2015 12:03:31 -0800 (PST) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:109030 Archived-At: --001a11477b7e7f4ddc0525127cc4 Content-Type: text/plain; charset=UTF-8 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 --001a11477b7e7f4ddc0525127cc4 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Sometimes when we are in some deep directory, it woul= d be really
convenient to be able to jump to an arbitrary parent = directory shown by
dired header. =C2=A0e.g., a dired header line = may be:

=C2=A0 /this/is/a/really/long/project/dir/= curr:

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

I have something l= ike below in my config file.=C2=A0 But it should be easy to
integ= rate it with `dired-insert-directory' in dired.el. =C2=A0
---------------------------------8<-------------------------= ------------=C2=A0
(defun xwl-dired-jump-to-parent (event)
<= div>=C2=A0 (interactive "e")
=C2=A0 (let (window pos fi= le)
=C2=A0 =C2=A0 (save-excursion
=C2=A0 =C2=A0 =C2=A0 = (setq window (posn-window (event-end event))
=C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 pos (posn-point (event-end event)))
=C2=A0 = =C2=A0 =C2=A0 (with-current-buffer (window-buffer window)
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 (goto-char pos)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = (when (search-forward "/" (line-end-position) t 1)
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (let ((beg 3)
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (end (point)))
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (dired (buffer-substring beg end))))))))

(defun xwl-dired-make-header-jumpable ()
= =C2=A0 "Click on dired header will jump to that directory directly.&qu= ot;
=C2=A0 (let ((inhibit-read-only t))
=C2=A0 =C2=A0 (= save-excursion
=C2=A0 =C2=A0 =C2=A0 (goto-char (point-min))
=
=C2=A0 =C2=A0 =C2=A0 (let ((bound (line-end-position))
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 start end)
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 (when (search-forward "/" bound t 1)
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq start (point))
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 (while (search-forward "/" bound t 1)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq end (1- (point)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (add-text-properties sta= rt end
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0`(mouse-face<= /div>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0highlight
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0help-echo "= mouse-1: goto here"
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0keymap ,(let ((map (make-sparse-keymap)))
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0(define-key map [down-mouse-1] 'xwl-dired-jump-to-parent)
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0map)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (se= tq 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 1= 57 AppKit 1404.13)
=C2=A0of 2015-11-08 on ULMMAC029
Rep= ository revision: 232183c1fbb3665a51cfb1e9dbd380127bb4a971
Window= ing system distributor `Apple Inc.', version 10.11.1
Configur= ed using:
=C2=A0`configure --with-mac'

- William

--001a11477b7e7f4ddc0525127cc4--