[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] ox.el: Protect export from auto-formatting hooks
From: |
David Lukes |
Subject: |
[PATCH] ox.el: Protect export from auto-formatting hooks |
Date: |
Tue, 21 Jun 2022 14:36:06 +0200 |
* ox.el, ox-odt.el: Use `write-region' instead of `write-file' or
`save-buffer' to protect generated export buffers from auto-formatting
hooks.
In particular, `tidy' is often configured as the auto-formatter for HTML
and XML, and it can corrupt the exports.
TINYCHANGE
---
lisp/ox-odt.el | 4 ++--
lisp/ox.el | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el
index 9d47067..ec1c360 100644
--- a/lisp/ox-odt.el
+++ b/lisp/ox-odt.el
@@ -1411,7 +1411,7 @@ original parsed data. INFO is a plist holding export
options."
(level (string-to-number (match-string 2))))
(if (wholenump sec-num) (<= level sec-num) sec-num))
(replace-match replacement t nil))))
- (save-buffer 0)))
+ (write-region nil nil buffer-file-name)))
;; Update content.xml.
(let* ( ;; `org-display-custom-times' should be accessed right
@@ -4004,7 +4004,7 @@ contextual information."
;; Prettify output if needed.
(when org-odt-prettify-xml
(indent-region (point-min) (point-max)))
- (save-buffer 0)))))
+ (write-region nil nil buffer-file-name)))))
;; Run zip.
(let* ((target --out-file)
(target-name (file-name-nondirectory target))
diff --git a/lisp/ox.el b/lisp/ox.el
index c75357b..66d18c4 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -6553,14 +6553,14 @@ or FILE."
(with-temp-buffer
(insert output)
(let ((coding-system-for-write ',encoding))
- (write-file ,file)))
+ (write-region nil nil ,file)))
(or (ignore-errors (funcall ',post-process ,file)) ,file)))
(let ((output (org-export-as
backend subtreep visible-only body-only ext-plist)))
(with-temp-buffer
(insert output)
(let ((coding-system-for-write encoding))
- (write-file file)))
+ (write-region nil nil file)))
(when (and (org-export--copy-to-kill-ring-p) (org-string-nw-p
output))
(org-kill-new output))
;; Get proper return value.
--
2.36.1
- [PATCH] ox.el: Protect export from auto-formatting hooks,
David Lukes <=