[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] open file link in dired?
From: |
Alan Schmitt |
Subject: |
Re: [O] open file link in dired? |
Date: |
Mon, 28 Jul 2014 09:09:24 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (darwin) |
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
--
OpenPGP Key ID : 040D0A3B4ED2E5C7
pgp3NRUeR9j46.pgp
Description: PGP signature
- Re: [O] open file link in dired?,
Alan Schmitt <=