all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] ox-odt: Prevent auto-formatting in export buffers
@ 2022-10-02  3:59 David Lukes
  2022-10-02  7:25 ` Ihor Radchenko
  2023-03-18 11:42 ` Ihor Radchenko
  0 siblings, 2 replies; 5+ messages in thread
From: David Lukes @ 2022-10-02  3:59 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: David Lukes

* 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



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-04-02 14:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-02  3:59 [PATCH] ox-odt: Prevent auto-formatting in export buffers David Lukes
2022-10-02  7:25 ` Ihor Radchenko
2022-10-03 12:10   ` David Lukeš
2023-03-18 11:42 ` Ihor Radchenko
2023-04-02 14:27   ` Ihor Radchenko

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.