[O] [PATCH 1/2] test INCLUDE pathname expansion with subdirectories

2015-09-24 Thread 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 000..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




[O] [PATCH 2/2] fix SETUPFILE pathname expansion from within an INCLUDE

2015-09-24 Thread 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




Re: [O] [PATCH v3] fix SETUPFILE pathname expansion with subdirectories

2015-09-24 Thread Richard Hansen
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

2015-09-22 Thread Richard Hansen
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

[O] [PATCH v3] fix SETUPFILE pathname expansion with subdirectories

2015-09-19 Thread 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 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




Re: [O] [PATCH v2] fix SETUPFILE pathname expansion with subdirectories

2015-09-19 Thread Richard Hansen
On 2015-09-19 18:43, Kyle Meyer wrote:
> Richard Hansen  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



[O] [PATCH v2] fix SETUPFILE pathname expansion with subdirectories

2015-09-19 Thread 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 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




Re: [O] [PATCH] fix SETUPFILE pathname expansion with subdirectories

2015-09-19 Thread Richard Hansen
On 2015-09-19 04:16, Nicolas Goaziou wrote:
> Hello,
> 
> Richard Hansen  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



[O] [PATCH] fix SETUPFILE pathname expansion with subdirectories

2015-09-18 Thread 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




Re: [O] Date format when exporting to LaTeX?

2013-07-01 Thread Richard Hansen
On 2013-07-01 17:46, Rasmus wrote:
> 
> Hi Richard,
> 
>> I recently upgraded from 7.8.03 to current master (actually
>> release_8.0.3-299-g1d606c0) and now when I export to LaTeX, the following:
>>
>>#+DATE: %Y-%m-%d
>>
>> no longer causes the date to be the current date in ISO 8601 format.  It
>> now simply prints "%Y-%m-%d".
>>
>> I tried:
>>
>>#+DATE: {{{date(%Y-%m-%d)}}}
> 
> This also doesn't work for, but I've never used it before.  But it
> should be {{{time(.)}}} cf.
>
> http://orgmode.org/cgit.cgi/org-mode.git/commit/?h=maint

I tried:

   #+DATE: {{{time(%Y-%m-%d)}}}

and that did work.  Thank you!

Unfortunately this does not work quite right with org-mode 7.8.03, so
I'll have to make sure everyone I collaborate with upgrades their
org-mode.  :(

> 
>> but got "Circular macro expansion: date".  I also tried:
>>
>>#+BIND: org-export-date-timestamp-format "%Y-%m-%d"
> 
> This works for me in Org-mode version 8.0.3
> (release_8.0.3-309-gabacff).  Is the problem still persistent after
> trying from emacs -q or after trying M-x org-reload?
> 
> 
> #+BIND: org-export-date-timestamp-format "%Y-%m-%d"
> #+DATE: <2013-07-01 Mon>
> 
> * test
> 
> #+begin_src emacs-lisp
> (setq org-export-date-timestamp-format "%B %e, %Y")
> (set (make-local-variable 'org-export-allow-bind-keywords) t)
> #+end_src

This works for me too, but:

  * I must provide a date.  If I don't have that #+DATE line then the
LaTeX exporter uses \today, and that ignores
org-export-date-timestamp-format.  I don't want to have to specify
a date; I want it to use today's date.  (The {{{time()}}} macro
works well for this, but I was unaware of its existence until now.)

  * org-export-allow-bind-keywords must be true.  Adding it as a
file-local variable is not an acceptable solution in my
circumstance.

I didn't have to set this variable when I was using 7.8.03 --
org-mode simply asked me (once) if it was OK to bind the
variables.  I miss that behavior.

Thanks again for letting me know about {{{time(.)}}}.

-Richard



[O] Date format when exporting to LaTeX?

2013-07-01 Thread Richard Hansen
Hi all,

I recently upgraded from 7.8.03 to current master (actually
release_8.0.3-299-g1d606c0) and now when I export to LaTeX, the following:

   #+DATE: %Y-%m-%d

no longer causes the date to be the current date in ISO 8601 format.  It
now simply prints "%Y-%m-%d".

I tried:

   #+DATE: {{{date(%Y-%m-%d)}}}

but got "Circular macro expansion: date".  I also tried:

   #+BIND: org-export-date-timestamp-format "%Y-%m-%d"

but that did nothing (no confirmation prompt, nothing).

Setting org-export-date-timestamp-format as a file-local variable didn't
work either.

Any hints?

Thanks,
Richard



[O] [PATCH] ob-core.el: fix confirm before eval when using a function

2013-07-01 Thread Richard Hansen
* lisp/ob-core.el: (org-babel-check-confirm-evaluate): Fix handling of
  `org-confirm-babel-evaluate' when it is a function.

When `org-confirm-babel-evaluate' is a function, this construct:

(or (when (functionp org-confirm-babel-evaluate)
  (funcall org-confirm-babel-evaluate lang block-body))
org-confirm-babel-evaluate)

will always be true -- if the function evaluates to nil, the `or' will
evaluate to the value of `org-confirm-babel-evaluate', which is
non-nil.

Change the `when' to an `if' and move a closing parenthesis so that
when `org-confirm-babel-evaluate' is a function its return value will
always be used, even if nil.

TINYCHANGE
---
 lisp/ob-core.el | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 16a122e..bde9553 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -301,10 +301,10 @@ name of the code block."
(noeval  (or ,eval-no ,eval-no-export))
(query   (or (equal ,eval "query")
 (and ,export (equal ,eval "query-export"))
-(when (functionp org-confirm-babel-evaluate)
-  (funcall org-confirm-babel-evaluate
-   ,lang ,block-body))
-org-confirm-babel-evaluate))
+(if (functionp org-confirm-babel-evaluate)
+(funcall org-confirm-babel-evaluate
+ ,lang ,block-body)
+  org-confirm-babel-evaluate)))
(code-block  (if ,info (format  " %s "  ,lang) " "))
(block-name  (if ,name (format " (%s) " ,name) " ")))
,@body)))
-- 
1.8.3.1