emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] open file link in dired?


From: Steven Arntson
Subject: Re: [O] open file link in dired?
Date: Tue, 09 Dec 2014 19:05:10 -0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Alan Schmitt <address@hidden> writes:

> Hi Bastien,
>
> On 2013-01-04 17:33, Bastien <address@hidden> writes:
>
>> Hi Alan,
>>
>> Alan Schmitt <address@hidden> 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]