* [PATCH] fix SETUPFILE pathname expansion with subdirectories
@ 2015-09-19 0:22 Richard Hansen
2015-09-19 8:16 ` Nicolas Goaziou
0 siblings, 1 reply; 15+ messages in thread
From: Richard Hansen @ 2015-09-19 0:22 UTC (permalink / raw)
To: emacs-orgmode; +Cc: Richard Hansen
* 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): 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.el | 1 +
lisp/ox.el | 1 +
2 files changed, 2 insertions(+)
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..07e5ef3 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
--
2.5.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH] fix SETUPFILE pathname expansion with subdirectories
2015-09-19 0:22 [PATCH] fix SETUPFILE pathname expansion with subdirectories Richard Hansen
@ 2015-09-19 8:16 ` Nicolas Goaziou
2015-09-19 20:18 ` Richard Hansen
2015-09-19 22:07 ` [PATCH v2] " Richard Hansen
0 siblings, 2 replies; 15+ messages in thread
From: Nicolas Goaziou @ 2015-09-19 8:16 UTC (permalink / raw)
To: Richard Hansen; +Cc: emacs-orgmode
Hello,
Richard Hansen <rhansen@bbn.com> writes:
> * 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): 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
Thank you.
Could you also provide add a test for it in "test-org.el"
(test-org/set-regexps-and-options)?
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] fix SETUPFILE pathname expansion with subdirectories
2015-09-19 8:16 ` Nicolas Goaziou
@ 2015-09-19 20:18 ` Richard Hansen
2015-09-19 22:07 ` [PATCH v2] " Richard Hansen
1 sibling, 0 replies; 15+ messages in thread
From: Richard Hansen @ 2015-09-19 20:18 UTC (permalink / raw)
To: Nicolas Goaziou; +Cc: emacs-orgmode
On 2015-09-19 04:16, Nicolas Goaziou wrote:
> Hello,
>
> Richard Hansen <rhansen@bbn.com> writes:
>
>> * 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): 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
>
> Thank you.
>
> Could you also provide add a test for it in "test-org.el"
> (test-org/set-regexps-and-options)?
I'm having trouble running the test suite. 'make test' freezes at:
test-ob-shell/dont-insert-spaces-on-expanded-bodies
If I comment out that test, it hangs at:
test-ob-shell/dont-error-on-empty-results
If I comment out that test, it gets stuck at:
test-ob-python/colnames-yes-header-argument-again
I haven't yet tried commenting out that test because I feel like I'm
doing something wrong. Any hints? (Emacs 24.4.1 from Ubuntu 15.04)
Thanks,
Richard
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v2] fix SETUPFILE pathname expansion with subdirectories
2015-09-19 8:16 ` Nicolas Goaziou
2015-09-19 20:18 ` Richard Hansen
@ 2015-09-19 22:07 ` Richard Hansen
2015-09-19 22:43 ` Kyle Meyer
1 sibling, 1 reply; 15+ messages in thread
From: Richard Hansen @ 2015-09-19 22:07 UTC (permalink / raw)
To: emacs-orgmode, mail; +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
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH v2] fix SETUPFILE pathname expansion with subdirectories
2015-09-19 22:07 ` [PATCH v2] " Richard Hansen
@ 2015-09-19 22:43 ` Kyle Meyer
2015-09-19 23:14 ` Richard Hansen
0 siblings, 1 reply; 15+ messages in thread
From: Kyle Meyer @ 2015-09-19 22:43 UTC (permalink / raw)
To: Richard Hansen; +Cc: emacs-orgmode
Richard Hansen <rhansen@bbn.com> writes:
> (with-temp-buffer
> + (cd (file-name-directory file))
> (org-mode)
> (insert (org-file-contents file 'noerror))
Why not just set default-directory instead of calling cd? Does it make
sense to support CDPATH here?
--
Kyle
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2] fix SETUPFILE pathname expansion with subdirectories
2015-09-19 22:43 ` Kyle Meyer
@ 2015-09-19 23:14 ` Richard Hansen
2015-09-20 5:07 ` Kyle Meyer
0 siblings, 1 reply; 15+ messages in thread
From: Richard Hansen @ 2015-09-19 23:14 UTC (permalink / raw)
To: Kyle Meyer; +Cc: emacs-orgmode
On 2015-09-19 18:43, Kyle Meyer wrote:
> Richard Hansen <rhansen@bbn.com> writes:
>
>> (with-temp-buffer
>> + (cd (file-name-directory file))
>> (org-mode)
>> (insert (org-file-contents file 'noerror))
>
> Why not just set default-directory instead of calling cd? Does it make
> sense to support CDPATH here?
I wasn't aware of CDPATH and its interaction with cd. Should I use
cd-absolute instead of setting default-directory directly? It does some
sanity checks (among other things) that seem worthwhile.
Thanks,
Richard
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2] fix SETUPFILE pathname expansion with subdirectories
2015-09-19 23:14 ` Richard Hansen
@ 2015-09-20 5:07 ` Kyle Meyer
2015-09-20 5:28 ` [PATCH v3] " Richard Hansen
0 siblings, 1 reply; 15+ messages in thread
From: Kyle Meyer @ 2015-09-20 5:07 UTC (permalink / raw)
To: Richard Hansen; +Cc: emacs-orgmode
Richard Hansen <rhansen@bbn.com> writes:
> Should I use cd-absolute instead of setting default-directory
> directly? It does some sanity checks (among other things) that seem
> worthwhile.
Looking at these checks, I don't think they are useful in this context,
and some change the intended behavior.
* One check makes sure the directory ends in a slash, but this will
already be the case because your changes call file-name-directory.
* Another calls expand-file-name, but all these functions already expand
the original file name upstream.
* Another signals an error if the directory doesn't exist, is not a
directory, or isn't accessible. All but one of these functions call
org-file-contents with a non-nil NOERROR, so the intent is to message
rather than raise an error when a file doesn't exist.
(org--setup-collect-keywords is the one function that doesn't use
org-file-contents, but it does check that the file is readable before
calling insert-file-contents.)
--
Kyle
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v3] fix SETUPFILE pathname expansion with subdirectories
2015-09-20 5:07 ` Kyle Meyer
@ 2015-09-20 5:28 ` Richard Hansen
2015-09-22 22:28 ` Richard Hansen
0 siblings, 1 reply; 15+ messages in thread
From: Richard Hansen @ 2015-09-20 5:28 UTC (permalink / raw)
To: kyle, mail, emacs-orgmode; +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
---
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 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
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH v3] fix SETUPFILE pathname expansion with subdirectories
2015-09-20 5:28 ` [PATCH v3] " Richard Hansen
@ 2015-09-22 22:28 ` Richard Hansen
2015-09-24 8:22 ` Nicolas Goaziou
0 siblings, 1 reply; 15+ messages in thread
From: Richard Hansen @ 2015-09-22 22:28 UTC (permalink / raw)
To: emacs-orgmode
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 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
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v3] fix SETUPFILE pathname expansion with subdirectories
2015-09-22 22:28 ` Richard Hansen
@ 2015-09-24 8:22 ` Nicolas Goaziou
2015-09-24 21:55 ` Richard Hansen
0 siblings, 1 reply; 15+ messages in thread
From: Nicolas Goaziou @ 2015-09-24 8:22 UTC (permalink / raw)
To: Richard Hansen; +Cc: emacs-orgmode
Hello,
Richard Hansen <rhansen@bbn.com> 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
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v3] fix SETUPFILE pathname expansion with subdirectories
2015-09-24 8:22 ` Nicolas Goaziou
@ 2015-09-24 21:55 ` Richard Hansen
2015-09-24 22:20 ` [PATCH 1/2] test INCLUDE " Richard Hansen
2015-09-25 11:51 ` [PATCH v3] fix SETUPFILE pathname expansion with subdirectories Nicolas Goaziou
0 siblings, 2 replies; 15+ messages in thread
From: Richard Hansen @ 2015-09-24 21:55 UTC (permalink / raw)
To: emacs-orgmode
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
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 1/2] test INCLUDE pathname expansion with subdirectories
2015-09-24 21:55 ` Richard Hansen
@ 2015-09-24 22:20 ` Richard Hansen
2015-09-24 22:20 ` [PATCH 2/2] fix SETUPFILE pathname expansion from within an INCLUDE Richard Hansen
2015-09-25 11:51 ` [PATCH v3] fix SETUPFILE pathname expansion with subdirectories Nicolas Goaziou
1 sibling, 1 reply; 15+ messages in thread
From: Richard Hansen @ 2015-09-24 22:20 UTC (permalink / raw)
To: emacs-orgmode; +Cc: Richard Hansen
* lisp/test-ox.el (test-org-export/expand-include): Modify the
INCLUDE test to ensure that a.org including subdir/b.org including
c.org causes subdir/c.org to be read, not c.org.
TINYCHANGE
---
testing/examples/include.org | 2 +-
testing/examples/{include2.org => include3.org} | 0
testing/examples/subdir/include2.org | 1 +
testing/lisp/test-ox.el | 8 ++++----
4 files changed, 6 insertions(+), 5 deletions(-)
rename testing/examples/{include2.org => include3.org} (100%)
create mode 100644 testing/examples/subdir/include2.org
diff --git a/testing/examples/include.org b/testing/examples/include.org
index f4dcc20..7122716 100644
--- a/testing/examples/include.org
+++ b/testing/examples/include.org
@@ -4,7 +4,7 @@ Small Org file with an include keyword.
(+ 2 1)
#+END_SRC
-#+INCLUDE: "include2.org"
+#+INCLUDE: "subdir/include2.org"
* Heading
body
diff --git a/testing/examples/include2.org b/testing/examples/include3.org
similarity index 100%
rename from testing/examples/include2.org
rename to testing/examples/include3.org
diff --git a/testing/examples/subdir/include2.org b/testing/examples/subdir/include2.org
new file mode 100644
index 0000000..68df86e
--- /dev/null
+++ b/testing/examples/subdir/include2.org
@@ -0,0 +1 @@
+#+INCLUDE: "../include3.org"
diff --git a/testing/lisp/test-ox.el b/testing/lisp/test-ox.el
index ccffa89..1af5c21 100644
--- a/testing/lisp/test-ox.el
+++ b/testing/lisp/test-ox.el
@@ -925,7 +925,7 @@ text
(insert-file
(expand-file-name "examples/include.org" org-test-dir))
(replace-regexp-in-string
- (regexp-quote "#+INCLUDE: \"include2.org\"")
+ (regexp-quote "#+INCLUDE: \"subdir/include2.org\"")
"Success!" (buffer-string)))
(org-test-with-temp-text
(format "#+INCLUDE: \"%s/examples/include.org\"" org-test-dir)
@@ -992,7 +992,7 @@ text
"#+BEGIN_CENTER\nSuccess!\n#+END_CENTER\n"
(org-test-with-temp-text
(format
- "#+INCLUDE: \"%s/examples/include2.org\" CENTER"
+ "#+INCLUDE: \"%s/examples/include3.org\" CENTER"
org-test-dir)
(org-export-expand-include-keyword)
(buffer-string))))
@@ -1132,11 +1132,11 @@ Footnotes[fn:2], foot[fn:test], digit only[3], and [fn:inline:anonymous footnote
(should-not
(equal
(org-test-with-temp-text
- (format "#+INCLUDE: \"%s/examples/include2.org\" src emacs-lisp" org-test-dir)
+ (format "#+INCLUDE: \"%s/examples/include3.org\" src emacs-lisp" org-test-dir)
(org-export-expand-include-keyword)
(buffer-string))
(org-test-with-temp-text
- (format "#+INCLUDE: \"%s/examples/include2.org\" src emacs-lisp :minlevel 1" org-test-dir)
+ (format "#+INCLUDE: \"%s/examples/include3.org\" src emacs-lisp :minlevel 1" org-test-dir)
(org-export-expand-include-keyword)
(buffer-string))))
;; INCLUDE assigns the relative :minlevel conditional on narrowing.
--
2.5.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 2/2] fix SETUPFILE pathname expansion from within an INCLUDE
2015-09-24 22:20 ` [PATCH 1/2] test INCLUDE " Richard Hansen
@ 2015-09-24 22:20 ` Richard Hansen
2015-09-25 11:58 ` Nicolas Goaziou
0 siblings, 1 reply; 15+ messages in thread
From: Richard Hansen @ 2015-09-24 22:20 UTC (permalink / raw)
To: emacs-orgmode; +Cc: Richard Hansen
* lisp/ox.el (defun org-export-expand-include-keyword): cd instead of
passing DIR to expand-file-name so that if the INCLUDE file has a
SETUPFILE line with a relative pathname the full pathname to the
SETUPFILE will be expanded properly.
Assume the following files:
/home/foo/a.org:
#+INCLUDE: subdir/b.org
/home/foo/subdir/b.org:
#+SETUPFILE: c.org
/home/foo/subdir/c.org:
stuff
Before, if /home/foo/a.org was opened and exported, org-mode would try
(and fail) to read /home/foo/c.org. With this change, org-mode reads
/home/foo/subdir/c.org as expected.
!!! TEST CASE NEEDED !!!
TINYCHANGE
---
lisp/ox.el | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/lisp/ox.el b/lisp/ox.el
index 0adbdf2..186a378 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -3149,14 +3149,13 @@ locally for the subtree through node properties."
(car key)
(if (org-string-nw-p val) (format " %s" val) ""))))))))
-(defun org-export-expand-include-keyword (&optional included dir footnotes)
+(defun org-export-expand-include-keyword (&optional included footnotes)
"Expand every include keyword in buffer.
Optional argument INCLUDED is a list of included file names along
with their line restriction, when appropriate. It is used to
-avoid infinite recursion. Optional argument DIR is the current
-working directory. It is used to properly resolve relative
-paths. Optional argument FOOTNOTES is a hash-table used for
-storing and resolving footnotes. It is created automatically."
+avoid infinite recursion. Optional argument FOOTNOTES is a
+hash-table used for storing and resolving footnotes. It is
+created automatically."
(let ((case-fold-search t)
(file-prefix (make-hash-table :test #'equal))
(current-prefix 0)
@@ -3194,8 +3193,7 @@ storing and resolving footnotes. It is created automatically."
(replace-match "" nil nil matched 1)))
(expand-file-name
(org-remove-double-quotes
- matched)
- dir)))
+ matched))))
(setq value (replace-match "" nil nil value)))))
(only-contents
(and (string-match ":only-contents *\\([^: \r\t\n]\\S-*\\)?"
@@ -3261,6 +3259,8 @@ storing and resolving footnotes. It is created automatically."
(t
(insert
(with-temp-buffer
+ (setq default-directory
+ (file-name-directory file))
(let ((org-inhibit-startup t)
(lines
(if location
@@ -3276,7 +3276,6 @@ storing and resolving footnotes. It is created automatically."
footnotes)))
(org-export-expand-include-keyword
(cons (list file lines) included)
- (file-name-directory file)
footnotes)
(buffer-string)))))
;; Expand footnotes after all files have been included.
--
2.5.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH v3] fix SETUPFILE pathname expansion with subdirectories
2015-09-24 21:55 ` Richard Hansen
2015-09-24 22:20 ` [PATCH 1/2] test INCLUDE " Richard Hansen
@ 2015-09-25 11:51 ` Nicolas Goaziou
1 sibling, 0 replies; 15+ messages in thread
From: Nicolas Goaziou @ 2015-09-25 11:51 UTC (permalink / raw)
To: Richard Hansen; +Cc: emacs-orgmode
Hello,
Richard Hansen <rhansen@bbn.com> 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,
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 2/2] fix SETUPFILE pathname expansion from within an INCLUDE
2015-09-24 22:20 ` [PATCH 2/2] fix SETUPFILE pathname expansion from within an INCLUDE Richard Hansen
@ 2015-09-25 11:58 ` Nicolas Goaziou
0 siblings, 0 replies; 15+ messages in thread
From: Nicolas Goaziou @ 2015-09-25 11:58 UTC (permalink / raw)
To: Richard Hansen; +Cc: emacs-orgmode
Hello,
Richard Hansen <rhansen@bbn.com> writes:
> * lisp/ox.el (defun org-export-expand-include-keyword): cd instead of
> passing DIR to expand-file-name so that if the INCLUDE file has a
> SETUPFILE line with a relative pathname the full pathname to the
> SETUPFILE will be expanded properly.
SETUPFILE within INCLUDE doesn't do what you think.
Org first includes contents from all INCLUDE keyword, then reads read
SETUPFILE keywords.
>
> Assume the following files:
>
> /home/foo/a.org:
> #+INCLUDE: subdir/b.org
>
> /home/foo/subdir/b.org:
> #+SETUPFILE: c.org
>
> /home/foo/subdir/c.org:
> stuff
In your example, a.org becomes
#+SETUPFILE: c.org
So, it is meant to look after /home/foo/c.org.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2015-09-25 11:56 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-19 0:22 [PATCH] fix SETUPFILE pathname expansion with subdirectories Richard Hansen
2015-09-19 8:16 ` Nicolas Goaziou
2015-09-19 20:18 ` Richard Hansen
2015-09-19 22:07 ` [PATCH v2] " Richard Hansen
2015-09-19 22:43 ` Kyle Meyer
2015-09-19 23:14 ` Richard Hansen
2015-09-20 5:07 ` Kyle Meyer
2015-09-20 5:28 ` [PATCH v3] " Richard Hansen
2015-09-22 22:28 ` Richard Hansen
2015-09-24 8:22 ` Nicolas Goaziou
2015-09-24 21:55 ` Richard Hansen
2015-09-24 22:20 ` [PATCH 1/2] test INCLUDE " Richard Hansen
2015-09-24 22:20 ` [PATCH 2/2] fix SETUPFILE pathname expansion from within an INCLUDE Richard Hansen
2015-09-25 11:58 ` Nicolas Goaziou
2015-09-25 11:51 ` [PATCH v3] fix SETUPFILE pathname expansion with subdirectories Nicolas Goaziou
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).