From: David Lukes <dafydd.lukes@gmail.com>
To: emacs-orgmode@gnu.org
Cc: David Lukes <dafydd.lukes@gmail.com>
Subject: [PATCH] ox-odt: Prevent auto-formatting in export buffers
Date: Sun, 2 Oct 2022 05:59:31 +0200 [thread overview]
Message-ID: <20221002035931.12191-1-dafydd.lukes@gmail.com> (raw)
* 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
next reply other threads:[~2022-10-02 4:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-02 3:59 David Lukes [this message]
2022-10-02 7:25 ` [PATCH] ox-odt: Prevent auto-formatting in export buffers Ihor Radchenko
2022-10-03 12:10 ` David Lukeš
2023-03-18 11:42 ` Ihor Radchenko
2023-04-02 14:27 ` Ihor Radchenko
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=20221002035931.12191-1-dafydd.lukes@gmail.com \
--to=dafydd.lukes@gmail.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).