From mboxrd@z Thu Jan 1 00:00:00 1970 From: Steven Arntson Subject: Re: open file link in dired? Date: Tue, 09 Dec 2014 19:05:10 -0800 Message-ID: <87a92w8as9.fsf@stevenarntson.com> References: <87vcbdlz75.fsf@bzg.ath.cx> <87ehi0lxfy.fsf@bzg.ath.cx> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:33303) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XyXak-0007dA-Os for emacs-orgmode@gnu.org; Tue, 09 Dec 2014 22:05:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XyXaf-0002F6-1n for emacs-orgmode@gnu.org; Tue, 09 Dec 2014 22:05:30 -0500 Received: from plane.gmane.org ([80.91.229.3]:36843) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XyXae-0002F0-Pd for emacs-orgmode@gnu.org; Tue, 09 Dec 2014 22:05:24 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1XyXad-00011p-Q1 for emacs-orgmode@gnu.org; Wed, 10 Dec 2014 04:05:23 +0100 Received: from 71-35-100-196.tukw.qwest.net ([71.35.100.196]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 10 Dec 2014 04:05:23 +0100 Received: from steven by 71-35-100-196.tukw.qwest.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 10 Dec 2014 04:05:23 +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: emacs-orgmode@gnu.org Alan Schmitt writes: > 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 I've been searching many moons for this exact functionality! I'm very glad to run across this, but as a fairly new emacser, I'm not sure what to do with this code. I copied it into my init.el, marked it and ran 'eval-region', but what do I call to use the functions? If I can get this working, I will be using it every day. Thank you! steven arntson