From mboxrd@z Thu Jan 1 00:00:00 1970 From: Aaron Ecay Subject: Re: [BUG][babel] Tangling into directories does not add directories to org file Date: Fri, 10 Oct 2014 12:55:37 -0400 Message-ID: <878uknx3sm.fsf@gmail.com> References: <87iojsk28y.fsf@gmail.com> <87iojrx4ry.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47074) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XcdU2-0004Bj-Ff for emacs-orgmode@gnu.org; Fri, 10 Oct 2014 12:56:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XcdTq-00087b-EL for emacs-orgmode@gnu.org; Fri, 10 Oct 2014 12:56:02 -0400 Received: from mail-wi0-x231.google.com ([2a00:1450:400c:c05::231]:35748) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XcdTq-00087V-7V for emacs-orgmode@gnu.org; Fri, 10 Oct 2014 12:55:50 -0400 Received: by mail-wi0-f177.google.com with SMTP id fb4so2682190wid.4 for ; Fri, 10 Oct 2014 09:55:49 -0700 (PDT) In-Reply-To: <87iojrx4ry.fsf@gmail.com> 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: Rainer M Krug , emacs-orgmode@gnu.org Hi Rainer, 2014ko urriak 10an, Aaron Ecay-ek idatzi zuen: [...] >> the function file-relative-name (file-relative-name FILENAME &optional >> DIRECTORY). If I am not mistaken, the optional argument DIRECTORY >> needs to be set to the directory of the tangled file. I assume it is >> not set at the moment.=20 >>=20 >> But I have no idea how to get this path and how to pass it to the >> function. > > Something like (file-name-directory (buffer-file-name)) should do the > trick, I think. I just (re)-read the =E2=80=9C...and pass it to the function=E2=80=9D part.= The lisp convention is that function calls look like: (FUNCTION ARG1 ARG2 ... ARGN) So you=E2=80=99d want something like: (file (if org-babel-tangle-use-relative-file-links (file-relative-name (nth 1 spec) (file-name-directory (buffer-fil= e-name))) ;;; <- addition here (nth 1 spec))) (link (let ((link (nth 2 spec))) (if org-babel-tangle-use-relative-file-links (when (string-match "^\\(file:\\|docview:\\)\\(.*\\)" link) (let* ((type (match-string 1 link)) (path (match-string 2 link)) (origpath path) (case-fold-search nil)) (setq path (file-relative-name path (file-name-directory (b= uffer-file-name)))) ;;; <- addition here (concat type path))) link))) Apologies if this is too basic an explanation, or otherwise unclear... --=20 Aaron Ecay