emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Alan Schmitt <alan.schmitt@polytechnique.org>
To: Bastien <bzg@altern.org>
Cc: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Re: open file link in dired?
Date: Mon, 28 Jul 2014 09:09:24 +0200	[thread overview]
Message-ID: <m2r416c63f.fsf@polytechnique.org> (raw)
In-Reply-To: <87ehi0lxfy.fsf@bzg.ath.cx> (Bastien's message of "Fri, 04 Jan 2013 17:33:53 +0100")

[-- Attachment #1: Type: text/plain, Size: 1497 bytes --]

Hi Bastien,

On 2013-01-04 17:33, Bastien <bzg@altern.org> writes:

> Hi Alan,
> Alan Schmitt <alan.schmitt@polytechnique.org> 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)

Thanks again (and thanks to Org for letting me remember this 18 months
old task),


OpenPGP Key ID : 040D0A3B4ED2E5C7

[-- Attachment #2: Type: application/pgp-signature, Size: 494 bytes --]

  reply	other threads:[~2014-07-28  9:11 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-04 14:36 Alan Schmitt
2013-01-04 15:55 ` Bastien
2013-01-04 16:12   ` Alan Schmitt
2013-01-04 16:33     ` Bastien
2014-07-28  7:09       ` Alan Schmitt [this message]
2014-07-28 13:57         ` Bastien
2014-12-10  3:05         ` Steven Arntson
2014-12-10  7:48           ` Alan Schmitt
2014-12-10  9:51             ` Marcin Borkowski
2014-12-10 10:25               ` Alan Schmitt
2014-12-10 19:07                 ` Steven Arntson
2014-12-11  7:36                   ` Alan Schmitt
2014-12-11 20:22                     ` Haider Rizvi
2014-12-12  8:02                       ` Alan Schmitt
2014-12-12 15:22                         ` Haider Rizvi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2r416c63f.fsf@polytechnique.org \
    --to=alan.schmitt@polytechnique.org \
    --cc=bzg@altern.org \
    --cc=emacs-orgmode@gnu.org \
    --subject='Re: open file link in dired?' \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Code repositories for project(s) associated with this inbox:


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).