emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] Parent path for links


From: Kyle Meyer
Subject: Re: [O] Parent path for links
Date: Thu, 19 Feb 2015 00:17:04 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Giacomo M <address@hidden> wrote:
[...]
> What happens is that in project.org I end up specifying a lot of links all
> starting with ~/working/project/. This is useful as I can directly jump
> from "organization" to "action", or just to switch in a quicker way across
> project files.
[...]
> Would you have any suggestions for reducing the redundancy of a common
> parent path for links in a subtree/file?

Is the reason this redundancy bothers you visual?  (I'm guessing it is
because it shouldn't be any extra work to insert the link if you're
using org-store-link.)  In that case, you could make a command that adds
a link description with the file base name (assuming these file links
tend to not have descriptions).

Another possibility (which I haven't really thought through or tested)
is to use a custom link type that grabs the project directory from
somewhere (below I use a property value) and then uses that as the
default directory.

#+begin_src elisp
  (org-add-link-type "project" 'km/org-project-open)

  (defun km/org-project-open (path)
    "Open PATH with `default-directory' set to PROJECT property."
    (let ((project (org-entry-get nil "PROJECT" 'inherit)))
      (if project
          (let ((default-directory project))
            (org-open-link-from-string (concat "file:" path)))
        (user-error "Project property not defined"))))
#+end_src

(Notice that km/org-project-open is actually making an ordinary file
link to support things like "::*heading"... definitely a hack).

You could specify the property value at the top of the project file

    #+PROPERTY: project /path/to/project

or as a project property on a heading

    * heading
    :PROPERTIES:
    :PROJECT:  /path/to/project
    :END:

This would then allow for links to a file name relative to the project
directory, like

    project:file-name.org

and

    project:file-name.org::*Heading

--
Kyle



reply via email to

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