Re: [O] [PATCH v3] fix SETUPFILE pathname expansion with subdirectories
Hello, Richard Hansen writes: > The intended meanings of #+INCLUDE and #+SETUPFILE have never been clear > to me, so I have a couple of questions: INCLUDE is only expanded during export. SETUPFILE are parsed when refreshing document properties (e.g., when using C-c C-c on a keyword). > * What is supposed to happen if you have a #+SETUPFILE that has > an #+INCLUDE? Org will SETUPFILE when refreshing document properties, but will parse it when exporting the document. > * What is supposed to happen if you have an #+INCLUDE file that > has a #+SETUPFILE line? Nothing. Contents of a SETUPFILE are not inserted in the current document. INCLUDE keywords are not read when refreshing properties. Regards,
Re: [O] [PATCH v3] fix SETUPFILE pathname expansion with subdirectories
On 2015-09-24 04:22, Nicolas Goaziou wrote: > Applied. Thank you. Thank you! > > Would it make sense to do the same for INCLUDE? If so, would you want to > have a look at it? A chain of #+INCLUDEs already works OK. I'll send a patch that tweaks the test-org-export/expand-include test case to ensure that it continues to work. The intended meanings of #+INCLUDE and #+SETUPFILE have never been clear to me, so I have a couple of questions: * What is supposed to happen if you have a #+SETUPFILE that has an #+INCLUDE? * What is supposed to happen if you have an #+INCLUDE file that has a #+SETUPFILE line? -Richard
Re: [O] [PATCH v3] fix SETUPFILE pathname expansion with subdirectories
Hello, Richard Hansen writes: > Any other feedback on this patch? Apparently, no. Applied. Thank you. Would it make sense to do the same for INCLUDE? If so, would you want to have a look at it? Regards, -- Nicolas Goaziou
Re: [O] [PATCH v3] fix SETUPFILE pathname expansion with subdirectories
Any other feedback on this patch? Thanks, Richard On 2015-09-20 01:28, Richard Hansen wrote: > * 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 > --- > Patch changelog: > v3: use (setq default-directory ...) instead of (cd ...) > v2: fix a couple more cases; add some tests > > lisp/org-macro.el | 2 ++ > lisp/org.el| 1 + > lisp/ox.el | 4 > testing/examples/setupfile.org | 7 +-- > testing/examples/setupfile3.org| 6 ++ > testing/examples/subdir/setupfile2.org | 1 + > 6 files changed, 15 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..e808972 100644 > --- a/lisp/org-macro.el > +++ b/lisp/org-macro.el > @@ -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 > diff --git a/lisp/org.el b/lisp/org.el > index 74fe4ae..bd5a183 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 > +(setq default-directory (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..477fc06 100644 > --- a/lisp/ox.el > +++ b/lisp/ox.el > @@ -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 > 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 000..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 000..31586fa > --- /dev/null > +++ b/testing/examples/subdir/setupfile2.org > @@ -0,0 +1 @
[O] [PATCH v3] 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 --- Patch changelog: v3: use (setq default-directory ...) instead of (cd ...) v2: fix a couple more cases; add some tests lisp/org-macro.el | 2 ++ lisp/org.el| 1 + lisp/ox.el | 4 testing/examples/setupfile.org | 7 +-- testing/examples/setupfile3.org| 6 ++ testing/examples/subdir/setupfile2.org | 1 + 6 files changed, 15 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..e808972 100644 --- a/lisp/org-macro.el +++ b/lisp/org-macro.el @@ -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 diff --git a/lisp/org.el b/lisp/org.el index 74fe4ae..bd5a183 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 + (setq default-directory (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..477fc06 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -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 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 000..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 000..31586fa --- /dev/null +++ b/testing/examples/subdir/setupfile2.org @@ -0,0 +1 @@ +#+SETUPFILE: ../setupfile3.org -- 2.5.3