From mboxrd@z Thu Jan 1 00:00:00 1970 From: Richard Hansen Subject: [PATCH v2] fix SETUPFILE pathname expansion with subdirectories Date: Sat, 19 Sep 2015 18:07:52 -0400 Message-ID: <1442700472-3845-1-git-send-email-rhansen@bbn.com> References: <87lhc2u8ln.fsf@nicolasgoaziou.fr> Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35139) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZdQJj-0000MG-Jz for emacs-orgmode@gnu.org; Sat, 19 Sep 2015 18:09:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZdQJf-0003dc-0O for emacs-orgmode@gnu.org; Sat, 19 Sep 2015 18:09:11 -0400 Received: from smtp.bbn.com ([128.33.1.81]:60757) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZdQJe-0003dY-T3 for emacs-orgmode@gnu.org; Sat, 19 Sep 2015 18:09:06 -0400 In-Reply-To: <87lhc2u8ln.fsf@nicolasgoaziou.fr> 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: emacs-orgmode@gnu.org, mail@nicolasgoaziou.fr Cc: Richard Hansen * lisp/org-macro.el (org-macro--collect-macros): cd to the directory containing the SETUPFILE before recursing so that relative pathnames in the SETUPFILE are expanded properly. * lisp/org.el (org--setup-collect-keywords): cd to the directory containing the SETUPFILE before recursing so that relative pathnames in the SETUPFILE are expanded properly. * lisp/ox.el (org-export--get-inbuffer-options, org-export--list-bound-variables): cd to the directory containing the SETUPFILE before recursing so that relative pathnames in the SETUPFILE are expanded properly. If /path/to/foo.org contains: #+SETUPFILE: settings/beamer.org and /path/to/settings/beamer.org contains: #+SETUPFILE: common.org then we want to read /path/to/settings/common.org, not /path/to/common.org. TINYCHANGE --- lisp/org-macro.el | 1 + lisp/org.el | 1 + lisp/ox.el | 2 ++ testing/examples/setupfile.org | 7 +------ testing/examples/setupfile3.org | 6 ++++++ testing/examples/subdir/setupfile2.org | 1 + 6 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 testing/examples/setupfile3.org create mode 100644 testing/examples/subdir/setupfile2.org diff --git a/lisp/org-macro.el b/lisp/org-macro.el index 65795f6..741c42c 100644 --- a/lisp/org-macro.el +++ b/lisp/org-macro.el @@ -106,6 +106,7 @@ Return an alist containing all macro templates found." (org-remove-double-quotes val)))) (unless (member file files) (with-temp-buffer + (cd (file-name-directory file)) (org-mode) (insert (org-file-contents file 'noerror)) (setq templates diff --git a/lisp/org.el b/lisp/org.el index 74fe4ae..ded3e13 100755 --- a/lisp/org.el +++ b/lisp/org.el @@ -5194,6 +5194,7 @@ Return value contains the following keys: `archive', `category', (org-remove-double-quotes value))))) (when (and f (file-readable-p f) (not (member f files))) (with-temp-buffer + (cd (file-name-directory f)) (insert-file-contents f) (setq alist ;; Fake Org mode to benefit from cache diff --git a/lisp/ox.el b/lisp/ox.el index bfdfeba..31e93e3 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -1455,6 +1455,7 @@ Assume buffer is in Org mode. Narrowing, if any, is ignored." ;; Avoid circular dependencies. (unless (member file files) (with-temp-buffer + (cd (file-name-directory file)) (insert (org-file-contents file 'noerror)) (let ((org-inhibit-startup t)) (org-mode)) (setq plist (funcall get-options @@ -1586,6 +1587,7 @@ an alist where associations are (VARIABLE-NAME VALUE)." (org-remove-double-quotes val)))) (unless (member file files) (with-temp-buffer + (cd (file-name-directory file)) (let ((org-inhibit-startup t)) (org-mode)) (insert (org-file-contents file 'noerror)) (setq alist diff --git a/testing/examples/setupfile.org b/testing/examples/setupfile.org index a85dbc0..71acfca 100644 --- a/testing/examples/setupfile.org +++ b/testing/examples/setupfile.org @@ -1,6 +1 @@ -#+BIND: variable value -#+DESCRIPTION: l2 -#+LANGUAGE: en -#+SELECT_TAGS: b -#+TITLE: b -#+PROPERTY: a 1 +#+SETUPFILE: subdir/setupfile2.org diff --git a/testing/examples/setupfile3.org b/testing/examples/setupfile3.org new file mode 100644 index 0000000..a85dbc0 --- /dev/null +++ b/testing/examples/setupfile3.org @@ -0,0 +1,6 @@ +#+BIND: variable value +#+DESCRIPTION: l2 +#+LANGUAGE: en +#+SELECT_TAGS: b +#+TITLE: b +#+PROPERTY: a 1 diff --git a/testing/examples/subdir/setupfile2.org b/testing/examples/subdir/setupfile2.org new file mode 100644 index 0000000..31586fa --- /dev/null +++ b/testing/examples/subdir/setupfile2.org @@ -0,0 +1 @@ +#+SETUPFILE: ../setupfile3.org -- 2.5.3