From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alan Schmitt Subject: Re: open file link in dired? Date: Mon, 28 Jul 2014 09:09:24 +0200 Message-ID: References: <87vcbdlz75.fsf@bzg.ath.cx> <87ehi0lxfy.fsf@bzg.ath.cx> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:37742) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XBgy6-0002vk-QV for emacs-orgmode@gnu.org; Mon, 28 Jul 2014 05:11:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XBgy0-0003OY-Q5 for emacs-orgmode@gnu.org; Mon, 28 Jul 2014 05:11:42 -0400 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:37814) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XBgy0-0003JO-JR for emacs-orgmode@gnu.org; Mon, 28 Jul 2014 05:11:36 -0400 In-Reply-To: <87ehi0lxfy.fsf@bzg.ath.cx> (Bastien's message of "Fri, 04 Jan 2013 17:33:53 +0100") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Bastien Cc: "emacs-orgmode@gnu.org" --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hi Bastien, On 2013-01-04 17:33, Bastien writes: > Hi Alan, > > Alan Schmitt writes: > >> Thank you, this would work nicely. However I don't know how to specify, >> when I open the file, which link-type to use. Would I need to modify the >> link itself from "file" to "file+emacs+dired" before opening it? > > Trying loading the attached .el file to get a new "dired" type. > Very crude but should work. I finally got around to test this, and here is a slightly improved version that handles filenames with spaces. #+begin_src emacs-lisp (org-add-link-type "file+emacs+dired" 'org-open-file-with-emacs-dired) (add-hook 'org-store-link-functions 'org-dired-store-link) (defun org-open-file-with-emacs-dired (path) "Open in dired." (let ((d (file-name-directory path)) (f (file-name-nondirectory path))) (dired d) (goto-char (point-min)) (search-forward f nil t))) (defun org-dired-store-link () "Store link to files/directories from dired." (require 'dired+) (when (eq major-mode 'dired-mode) (let ((f (dired-get-filename))) (setq link (concat "file+emacs+dired" ":" f) desc (concat f " (dired)")) (org-add-link-props :link link :description desc) link))) #+end_src Thanks again (and thanks to Org for letting me remember this 18 months old task), Alan =2D-=20 OpenPGP Key ID : 040D0A3B4ED2E5C7 --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.22 (Darwin) iQEcBAEBCgAGBQJT1fcqAAoJEAQNCjtO0uXHr6QH/A+qrNkOWep+aO7BzFRbPG+s pJGrmNhuIDRFxLnQKdl7VtZF5umJKYx2HkQOIjXK7bJLb3wKQfPHo2uy6jsDwSAY Fmb6S6SebsxhXNG3QzHLri/ufpWMUPGpXLOI11X0dFxppgODYTeBvyqlDg/JyubT QVkoxQ+ze8/hwSqzwWPVE1PZKkk5qVEVq5GvWbay1xE4XjFX/l8ErHmTrFbRhdBm FMjnJCxQNkshm5jrE9nxb8USdFisqTi8vthA3YNF2s74gH4hvF6nT0J6Ocb5LemI Q4T4rkwWyp/gM/Vb2U+KDT+MnnO/bIsp1UYLxSBcr9fQ/1vxX2YEcRh4FkwZY/I= =WoVE -----END PGP SIGNATURE----- --=-=-=--