[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] ox-odt: Prevent auto-formatting in export buffers
From: |
David Lukes |
Subject: |
[PATCH] ox-odt: Prevent auto-formatting in export buffers |
Date: |
Sun, 2 Oct 2022 05:59:31 +0200 |
* lisp/ox-odt.el (org-odt-template, org-odt--export-wrap):
`write-region' instead of `save-buffer'.
`write-file' and `save-buffer' trigger major mode changes, which leads
to various mode-related hooks being run. This is undesirable: running
these on generated files is wasted time and computation, and it can even
lead to hard to track data corruption when auto-formatting hooks are
involved. One such case is the 2006 version of the tidy program which
ships with stock macOS and can corrupt multi-byte UTF-8 codepoints in
HTML and ODT (via XML) exports. And even recent versions of tidy can
re-arrange whitespace in the exported documents in unwanted ways.
TINYCHANGE
---
lisp/ox-odt.el | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el
index 208a39d9d..c678f22e7 100644
--- a/lisp/ox-odt.el
+++ b/lisp/ox-odt.el
@@ -1414,7 +1414,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
@@ -4007,7 +4007,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))
--
2.37.1
- [PATCH] ox-odt: Prevent auto-formatting in export buffers,
David Lukes <=