fix SETUPFILE pathname expansion with subdirectories

* 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
This commit is contained in:
Richard Hansen 2015-09-20 01:28:53 -04:00 committed by Nicolas Goaziou
parent 2e1b93db41
commit 11bba63dc3
6 changed files with 15 additions and 6 deletions

View File

@ -106,6 +106,8 @@ Return an alist containing all macro templates found."
(org-remove-double-quotes val))))
(unless (member file files)
(with-temp-buffer
(setq default-directory
(file-name-directory file))
(org-mode)
(insert (org-file-contents file 'noerror))
(setq templates

View File

@ -5208,6 +5208,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
(setq default-directory (file-name-directory f))
(insert-file-contents f)
(setq alist
;; Fake Org mode to benefit from cache

View File

@ -1455,6 +1455,8 @@ Assume buffer is in Org mode. Narrowing, if any, is ignored."
;; Avoid circular dependencies.
(unless (member file files)
(with-temp-buffer
(setq default-directory
(file-name-directory file))
(insert (org-file-contents file 'noerror))
(let ((org-inhibit-startup t)) (org-mode))
(setq plist (funcall get-options
@ -1586,6 +1588,8 @@ an alist where associations are (VARIABLE-NAME VALUE)."
(org-remove-double-quotes val))))
(unless (member file files)
(with-temp-buffer
(setq default-directory
(file-name-directory file))
(let ((org-inhibit-startup t)) (org-mode))
(insert (org-file-contents file 'noerror))
(setq alist

View File

@ -1,6 +1 @@
#+BIND: variable value
#+DESCRIPTION: l2
#+LANGUAGE: en
#+SELECT_TAGS: b
#+TITLE: b
#+PROPERTY: a 1
#+SETUPFILE: subdir/setupfile2.org

View File

@ -0,0 +1,6 @@
#+BIND: variable value
#+DESCRIPTION: l2
#+LANGUAGE: en
#+SELECT_TAGS: b
#+TITLE: b
#+PROPERTY: a 1

View File

@ -0,0 +1 @@
#+SETUPFILE: ../setupfile3.org