From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id QIjLOSwNOWOMQgEAbAwnHQ (envelope-from ) for ; Sun, 02 Oct 2022 06:01:49 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id +CHeOSwNOWMubgAAauVa8A (envelope-from ) for ; Sun, 02 Oct 2022 06:01:48 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 94F323CF96 for ; Sun, 2 Oct 2022 06:01:48 +0200 (CEST) Received: from localhost ([::1]:54492 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oeqAk-0001N3-Vn for larch@yhetil.org; Sun, 02 Oct 2022 00:01:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49644) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oeq8t-0001Mc-45 for emacs-orgmode@gnu.org; Sat, 01 Oct 2022 23:59:51 -0400 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]:37628) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oeq8r-000407-B5 for emacs-orgmode@gnu.org; Sat, 01 Oct 2022 23:59:50 -0400 Received: by mail-ed1-x535.google.com with SMTP id a41so10569288edf.4 for ; Sat, 01 Oct 2022 20:59:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=2hqzzFH2uy41YuzT8c0gh2X/YBWLp8bjd6xGcu4sKfY=; b=ps/zBK1Km5Hw4uIdBPnAZa+XnXc3hArht61SSoIU4j0GklHBQlNjW8JadlSwm6jzsS JrW8wc+/JB2rfT+NU1WOoZikBQ3poXTUN/9C9GjFznxjU5EmBa4ovfprG5Gv0QL44hVc pcH5XVw9gyi1JgVQcw/0Gy0wyT2lqYXgwkQYHrWeABjnvqkmgdWVc/p10sO6Pv5LJS9v eQ1p2PfFW4xkiYoXjHpTO2RYcesi4AdmcZJHXenAJlOMFXbk5tPN1t9Fhf7HDZ8MITIg 6hGqZKYHMawdqThRotmVwz692pbPjDoybSJkMKHk/xtGLpDyCMSFyNkxNiKkJNjtjDsT Ck4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=2hqzzFH2uy41YuzT8c0gh2X/YBWLp8bjd6xGcu4sKfY=; b=V38r/07E8LsjFDLzmw9jWeyQwKOa7BP/FHwS0GOpXDwS2fLrl1c9oOPwbc7DGq0e2k IXINmVYINe29yzvieijLPjGBtG8b1JmCtLP80E0pWz/VbhHZ0CHr4X/Lud4jHbPzOQ/k EackKNgJB7t0ajuLSznbuAPtNmu6KRFeCWeSvmjes1nTjlAu0aKyFrOsJzN395KggebM a5UVgd9NbpLbTXFL2VRPZQSqMRt/RrA9Ix5uOxFb282kaIHBvHPiJKwXjKsBqdcJhYoZ cEcu8a2UPayVRBK2diJ/mRSUYhXu3QGfti1xtHPh4MjcjQ4Gld4NecTU1yv67HRzhDVQ grOw== X-Gm-Message-State: ACrzQf0QNMQ3iAZXZk7Y0fX+1RViP4YeiX4fEFnaIsvVyhWdQxrkl09Y xwVR58NEddAbRbCn8u5hlJXelvXVBC0= X-Google-Smtp-Source: AMsMyM604KOa74iLHOJd4GhjzMGnOs2mDnrS6wVLTIntf1h3L1C0MdBy9wH1DzlvMCadafDjGUtNSg== X-Received: by 2002:a05:6402:524a:b0:450:bab6:cd5f with SMTP id t10-20020a056402524a00b00450bab6cd5fmr13615387edd.233.1664683185805; Sat, 01 Oct 2022 20:59:45 -0700 (PDT) Received: from localhost.localdomain (ip-89-177-119-171.bb.vodafone.cz. [89.177.119.171]) by smtp.gmail.com with ESMTPSA id r2-20020a17090609c200b00782ee6b34f2sm3423506eje.183.2022.10.01.20.59.45 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 01 Oct 2022 20:59:45 -0700 (PDT) From: David Lukes To: emacs-orgmode@gnu.org Cc: David Lukes Subject: [PATCH] ox-odt: Prevent auto-formatting in export buffers Date: Sun, 2 Oct 2022 05:59:31 +0200 Message-Id: <20221002035931.12191-1-dafydd.lukes@gmail.com> X-Mailer: git-send-email 2.37.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1450:4864:20::535; envelope-from=dafydd.lukes@gmail.com; helo=mail-ed1-x535.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1664683308; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=2hqzzFH2uy41YuzT8c0gh2X/YBWLp8bjd6xGcu4sKfY=; b=E+SWLO9T7OZkd3Cg4ylBaObneglrPa5LjoslxnpUHYoa+JKrlpKHJXoVXYJa8yjKFXy9xz EHUf3gZa3YOczxYd3kMMtPQQIApgWJvb6vIcrNEfiLyBi1G5DvepBx+60Nh2m3mvw2ff/r XWPHxAsskzgqM6fHqbdpE/0n/LxrQyIx85jnkc+m2aeEIbbo9teNkorwIVpZ3qlzsHkPLt 9k3xcIPWuwvNnjKH1OxWao+oQAJy1VK9peC6qIcn3aSjAAmDYbKHU5aQVgDzQTYgCJGsNY jxRi+boNtyeC0OpowF7P7bXgO7V/nlnpf5YBf0P8ARmGRAxPEVkCxb/lY/NNWg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1664683308; a=rsa-sha256; cv=none; b=tUSlY2XSmMYjLykjrSrh1Lth5AofP63VA6D0KnjTZDqNdxIdTGNnKJH07yIpaYbmasj5OX +ojEL2KLFoXRldHKQM3RVRs05bLNFjSPPKz5p/dn8LrSkvZnVCcKhX8gfr/E7RhpVe0tan cIaP6LydROMYNE+7D9lRSZFZ8m+aA8dup2yjNUjf30HGBT8sDjTAnnw9+Xaof6bvkKMarf 7cPC5ltCjC5Xa+vAo13Gy5CwGHhdiiGCiQ4VJObQPQMENMnG0R+r/YNChZfNjZVQ+RGQe5 iKGI2jzx2cS9QFJP3OBCQYjdchuXL5vj0biuHEsqRxQZO6xNkDo3FQqMd01reA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="ps/zBK1K"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.34 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="ps/zBK1K"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 94F323CF96 X-Spam-Score: -3.34 X-Migadu-Scanner: scn0.migadu.com X-TUID: jaVRTFuPLPeT * 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