From: Rasmus <rasmus@gmx.us>
To: emacs-orgmode@gnu.org
Subject: [ox, patch] external compilation (was: External compilation)
Date: Fri, 20 Feb 2015 13:07:50 +0100 [thread overview]
Message-ID: <873860vl9l.fsf@gmx.us> (raw)
In-Reply-To: 87wq3e5e23.fsf@gmx.us
[-- Attachment #1: Type: text/plain, Size: 1007 bytes --]
Rasmus <rasmus@gmx.us> writes:
> I can move the call to Emacs as file variable s.t.
>
> # Local Variables:
> # eval: (unless (or user-init-file (window-system)) (load-file "conf.el"))
> # End:
A much better variable to check is `noninteractive', cf
(info "(elisp) Batch mode").
> Ideally, what I would like would be to specify a per-file/project init
> file. Sort of like org-export-async-init-file, but as part of
> org-export-options-alist to get the "init.el-dependency" inside the
> Org-file. It would be read when Org exports async or via batch.
This patch moves org-export-async-init-file to org-export-options-alist
and introduces #+INIT for setting it in a file.
It also automatically "switches" to async export if running Emacs in
batch. I don't know if this is a good idea! E.g. I guess it would starts
a new Emacs process from a Emacs batch process...
WDYT? Would something like this be appropriate?
—Rasmus
--
One thing that is clear: it's all down hill from here
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ox.el-Introduce-file-specific-init-files.patch --]
[-- Type: text/x-diff, Size: 6337 bytes --]
From 796c6a55e2ece026a17268bd9a021895fa1be273 Mon Sep 17 00:00:00 2001
From: rasmus <rasmus@gmx.us>
Date: Fri, 20 Feb 2015 12:56:06 +0100
Subject: [PATCH] ox.el: Introduce file-specific init-files.
* ox.el (org-export-options-alist): Add
:init-file. (org-export-async-start): Use :init-file.
* ox-publish.el (org-publish) (org-publish-all)
(org-publish-current-file): Use :init-file if noninteractive.
* ox-icalendar.el (org-icalendar-export-agenda-files),
(org-icalendar-combine-agenda-files): Use :init-file if
noninteractive.
Allows specifying a file-specific init-file via #+INIT.
---
lisp/ox-icalendar.el | 4 ++--
lisp/ox-odt.el | 2 +-
lisp/ox-publish.el | 6 +++---
lisp/ox.el | 18 +++++++++++-------
4 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/lisp/ox-icalendar.el b/lisp/ox-icalendar.el
index b473f11..3a489f7 100644
--- a/lisp/ox-icalendar.el
+++ b/lisp/ox-icalendar.el
@@ -832,7 +832,7 @@ Return ICS file name."
When optional argument ASYNC is non-nil, export happens in an
external process."
(interactive)
- (if async
+ (if (or async noninteractive)
;; Asynchronous export is not interactive, so we will not call
;; `org-check-agenda-file'. Instead we remove any non-existent
;; agenda file from the list.
@@ -870,7 +870,7 @@ the `org-export-stack' interface.
The file is stored under the name chosen in
`org-icalendar-combined-agenda-file'."
(interactive)
- (if async
+ (if (or async noninteractive)
(let ((files (org-remove-if-not 'file-exists-p (org-agenda-files t))))
(org-export-async-start
(lambda (dummy)
diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el
index 4a94de1..a3fd43b 100644
--- a/lisp/ox-odt.el
+++ b/lisp/ox-odt.el
@@ -4232,7 +4232,7 @@ file-local settings.
Return output file's name."
(interactive)
(let ((outfile (org-export-output-file-name ".odt" subtreep)))
- (if async
+ (if (or async noninteractive)
(org-export-async-start (lambda (f) (org-export-add-to-stack f 'odt))
`(expand-file-name
(org-odt--export-wrap
diff --git a/lisp/ox-publish.el b/lisp/ox-publish.el
index d450c0e..c5b0a76 100644
--- a/lisp/ox-publish.el
+++ b/lisp/ox-publish.el
@@ -884,7 +884,7 @@ publishing will be done asynchronously, in another process."
(assoc project org-publish-project-alist))))
(cond
((not project))
- (async
+ ((or async noninteractive)
(org-export-async-start (lambda (results) nil)
`(let ((org-publish-use-timestamps-flag
,(and (not force) org-publish-use-timestamps-flag)))
@@ -905,7 +905,7 @@ directory and force publishing all projects. With a non-nil
optional argument ASYNC, publishing will be done asynchronously,
in another process."
(interactive "P")
- (if async
+ (if (or async noninteractive)
(org-export-async-start (lambda (results) nil)
`(progn
(when ',force (org-publish-remove-all-timestamps))
@@ -927,7 +927,7 @@ optional argument ASYNC is non-nil, publishing will be done
asynchronously, in another process."
(interactive "P")
(let ((file (buffer-file-name (buffer-base-buffer))))
- (if async
+ (if (or async noninteractive)
(org-export-async-start (lambda (results) nil)
`(let ((org-publish-use-timestamps-flag
(if ',force nil ,org-publish-use-timestamps-flag)))
diff --git a/lisp/ox.el b/lisp/ox.el
index 6a16997..6cf728b 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -108,6 +108,7 @@
(:select-tags "SELECT_TAGS" nil org-export-select-tags split)
(:exclude-tags "EXCLUDE_TAGS" nil org-export-exclude-tags split)
(:creator "CREATOR" nil org-export-creator-string)
+ (:init-file "INIT" nil org-export-async-init-file t)
(:headline-levels nil "H" org-export-headline-levels)
(:preserve-breaks nil "\\n" org-export-preserve-breaks)
(:section-numbers nil "num" org-export-with-section-numbers)
@@ -859,7 +860,7 @@ automatically. But you can retrieve them with \\[org-export-stack]."
:type 'boolean)
(defcustom org-export-async-init-file nil
- "File used to initialize external export process.
+ "File used to initialize external and batch export processes.
Value must be either nil or an absolute file name. When nil, the
external process is launched like a regular Emacs session,
@@ -868,7 +869,9 @@ configuration. If a file is provided, it, and only it, is loaded
at start-up.
Therefore, using a specific configuration makes the process to
-load faster and the export more portable."
+load faster and the export more portable.
+
+In ox-publish projects the value :init-file takes precedence."
:group 'org-export-general
:version "24.4"
:package-version '(Org . "8.0")
@@ -5646,7 +5649,8 @@ and `org-export-to-file' for more specialized functions."
;; Sexp to evaluate in the buffer.
(print (progn ,,@body))))))
;; Start external process.
- (let* ((process-connection-type nil)
+ (let* ((init (plist-get :init (org-export--get-inbuffer-options)))
+ (process-connection-type nil)
(,proc-buffer (generate-new-buffer-name "*Org Export Process*"))
(,process
(apply
@@ -5656,8 +5660,8 @@ and `org-export-to-file' for more specialized functions."
,proc-buffer
(expand-file-name invocation-name invocation-directory)
"--batch")
- (if org-export-async-init-file
- (list "-Q" "-l" org-export-async-init-file)
+ (if init
+ (list "-Q" "-l" init)
(list "-l" user-init-file))
(list "-l" ,temp-file)))))
;; Register running process in stack.
@@ -5724,7 +5728,7 @@ use it to set a major mode there, e.g,
This function returns BUFFER."
(declare (indent 2))
- (if async
+ (if (or async noninteractive)
(org-export-async-start
`(lambda (output)
(with-current-buffer (get-buffer-create ,buffer)
@@ -5790,7 +5794,7 @@ or FILE."
(if (not (file-writable-p file)) (error "Output file not writable")
(let ((ext-plist (org-combine-plists `(:output-file ,file) ext-plist))
(encoding (or org-export-coding-system buffer-file-coding-system)))
- (if async
+ (if (or async noninteractive)
(org-export-async-start
`(lambda (file)
(org-export-add-to-stack (expand-file-name file) ',backend))
--
2.3.0
next prev parent reply other threads:[~2015-02-20 12:08 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-19 11:35 External compilation Rasmus
2015-02-19 14:16 ` Sebastien Vauban
2015-02-19 14:47 ` Rasmus
2015-02-19 14:50 ` Sebastien Vauban
2015-02-20 12:07 ` Rasmus [this message]
2015-02-20 16:10 ` [ox, patch] external compilation Nicolas Goaziou
2015-02-20 16:24 ` Rasmus
2015-02-20 17:34 ` Nicolas Goaziou
2015-02-20 18:21 ` Rasmus
2015-02-20 19:01 ` Nicolas Goaziou
2015-02-20 19:38 ` Rasmus
2015-02-21 9:35 ` Nicolas Goaziou
2015-02-21 11:35 ` Rasmus
2015-02-21 12:59 ` Nicolas Goaziou
2015-02-21 13:23 ` Rasmus
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=873860vl9l.fsf@gmx.us \
--to=rasmus@gmx.us \
--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).