emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Parent path for links
@ 2015-02-19  1:55 Giacomo M
  2015-02-19  5:17 ` Kyle Meyer
  2015-02-19 23:49 ` Christian Wittern
  0 siblings, 2 replies; 4+ messages in thread
From: Giacomo M @ 2015-02-19  1:55 UTC (permalink / raw)
  To: emacs-orgmode

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

Dear all,
I'm experimenting the following path structure:

1. ~/org/ is where I keep all my org files for organization purposes (e.g.
project.org contains all TODOs, notes, events, and links related to
"project") and is sync'd with a GIT server.

2. ~/working/project/ is where I keep all the non-organizational files
related to "project", which are potentially big and thus the folder is
saved on an external drive/Dropbox.

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.

I know there is an header arg (i.e. dir) for the path of code execution,
but I am not aware of anything similar for link referencing.

Would you have any suggestions for reducing the redundancy of a common
parent path for links in a subtree/file?

Thanks,

Giacomo

[-- Attachment #2: Type: text/html, Size: 1295 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Parent path for links
  2015-02-19  1:55 Parent path for links Giacomo M
@ 2015-02-19  5:17 ` Kyle Meyer
  2015-02-19 23:49 ` Christian Wittern
  1 sibling, 0 replies; 4+ messages in thread
From: Kyle Meyer @ 2015-02-19  5:17 UTC (permalink / raw)
  To: Giacomo M; +Cc: emacs-orgmode

Giacomo M <jackjackk@gmail.com> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Parent path for links
  2015-02-19  1:55 Parent path for links Giacomo M
  2015-02-19  5:17 ` Kyle Meyer
@ 2015-02-19 23:49 ` Christian Wittern
  2015-02-20  0:07   ` Kyle Meyer
  1 sibling, 1 reply; 4+ messages in thread
From: Christian Wittern @ 2015-02-19 23:49 UTC (permalink / raw)
  To: emacs-orgmode

On 2015-02-19 10:55, Giacomo M wrote:
> What happens is that in project.org <http://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.
> 
> I know there is an header arg (i.e. dir) for the path of code execution, but
> I am not aware of anything similar for link referencing.
Look at Section 4.6 Link Abbreviations in the manual.  What you would want
to do is having

#+LINK: wp ~/working/project

in your header, than you can reference it as [[wp:your-project.org]] instead
of [[~/working/project/your-project.org]].

Best, Christian

-- 
Christian Wittern, Kyoto

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Parent path for links
  2015-02-19 23:49 ` Christian Wittern
@ 2015-02-20  0:07   ` Kyle Meyer
  0 siblings, 0 replies; 4+ messages in thread
From: Kyle Meyer @ 2015-02-20  0:07 UTC (permalink / raw)
  To: Christian Wittern; +Cc: emacs-orgmode

Christian Wittern <cwittern@gmail.com> wrote:
[...]
> Look at Section 4.6 Link Abbreviations in the manual.  What you would want
> to do is having
>
> #+LINK: wp ~/working/project
>
> in your header, than you can reference it as [[wp:your-project.org]] instead
> of [[~/working/project/your-project.org]].

Ahh... neat.  I didn't know about that.  Ignore my answer.

-- 
Kyle

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-02-20  0:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-19  1:55 Parent path for links Giacomo M
2015-02-19  5:17 ` Kyle Meyer
2015-02-19 23:49 ` Christian Wittern
2015-02-20  0:07   ` Kyle Meyer

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

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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).