From: Richard Hansen <rhansen@bbn.com>
To: emacs-orgmode@gnu.org
Cc: Richard Hansen <rhansen@bbn.com>
Subject: [PATCH 2/2] fix SETUPFILE pathname expansion from within an INCLUDE
Date: Thu, 24 Sep 2015 18:20:41 -0400 [thread overview]
Message-ID: <1443133241-501-2-git-send-email-rhansen@bbn.com> (raw)
In-Reply-To: <1443133241-501-1-git-send-email-rhansen@bbn.com>
* 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
next prev parent reply other threads:[~2015-09-24 22:21 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Richard Hansen [this message]
2015-09-25 11:58 ` [PATCH 2/2] fix SETUPFILE pathname expansion from within an INCLUDE Nicolas Goaziou
2015-09-25 11:51 ` [PATCH v3] fix SETUPFILE pathname expansion with subdirectories Nicolas Goaziou
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1443133241-501-2-git-send-email-rhansen@bbn.com \
--to=rhansen@bbn.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).