From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kyle Meyer Subject: Re: Parent path for links Date: Thu, 19 Feb 2015 00:17:04 -0500 Message-ID: <87a90a4h0v.fsf@kmlap.domain.org> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47110) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOJQE-0006WR-4f for emacs-orgmode@gnu.org; Thu, 19 Feb 2015 00:13:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YOJQA-00050x-3J for emacs-orgmode@gnu.org; Thu, 19 Feb 2015 00:13:10 -0500 Received: from mail-qc0-f170.google.com ([209.85.216.170]:33366) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOJQ9-00050r-VQ for emacs-orgmode@gnu.org; Thu, 19 Feb 2015 00:13:06 -0500 Received: by mail-qc0-f170.google.com with SMTP id c9so4701679qcz.1 for ; Wed, 18 Feb 2015 21:13:05 -0800 (PST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Giacomo M Cc: emacs-orgmode@gnu.org Giacomo M 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