From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id IO0dFrHzVWH8xgAAgWs5BA (envelope-from ) for ; Thu, 30 Sep 2021 19:28:17 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id YKDKEbHzVWH+AgAAB5/wlQ (envelope-from ) for ; Thu, 30 Sep 2021 17:28:17 +0000 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 B001C31523 for ; Thu, 30 Sep 2021 19:28:16 +0200 (CEST) Received: from localhost ([::1]:33938 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVzqw-0004go-Jt for larch@yhetil.org; Thu, 30 Sep 2021 13:28:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39360) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVzqT-0004gI-JO for emacs-orgmode@gnu.org; Thu, 30 Sep 2021 13:27:45 -0400 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]:43833) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVzqR-00082C-Uh for emacs-orgmode@gnu.org; Thu, 30 Sep 2021 13:27:45 -0400 Received: by mail-pl1-x62f.google.com with SMTP id y1so4528251plk.10 for ; Thu, 30 Sep 2021 10:27:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:user-agent:message-id:mime-version; bh=Oxj3IEWh5YiMxeTVRn6EV0ZA0G33NvQeGMtdx9GoCwA=; b=QafhavqOlWvibI+oYTD3RIQEag01Jp3PN2EHgvKlNUCMJ//cz5nMrCqgxOClgJ89B2 Ra4zBfCt9zNv6I7DS22VKjReC4ySEpRxez3oqwixn6U74SmOvX3wgCJyAxTjBZf23W3k dlx7tpo9aiFJTlb/NFrP3nzOmEIpy5J9tYDuOIssUcIzD21hq4RHlz4CvNPpSo4CwNGp +n8JnjPeQVBZ+57MPgLrvvCZVvEYckx3tUMhLD2KpESSvc7D4SprA5G6HGgDX4dKkVvY 4KWLdukDuPwwwosJG62pOLf0AyhfRA0tlC+mLJlBCJKq2MyqPj20AlO1Dkscw4FgzmXD b1kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:user-agent:message-id :mime-version; bh=Oxj3IEWh5YiMxeTVRn6EV0ZA0G33NvQeGMtdx9GoCwA=; b=YT/xR+9aUWZQRJXrrdk7F7hC1c+bjUofQ8dY7RKV6EWtqZ3Y+10c287ZVhuaOPVl8l ohYrmF7YBzkImKa8qxEp4302YunW+D2BTKteW0PkRb4x5cGmpbfLNdYkJbPLzumxqnfY lgvAlcTQIHxHW0efmIfPX/1HdqFb2yWGH6GD88U0rMHjILcc6F8N8Fw1vNv4dAIvQyag nltNvNm7HhSAU6ysBrcCRlIcIGZPWlSlA3WqoqK5vM2dmyZXPXF67D7NBUj413hvSytm REgB9t1lYVoeudjq1qXC1X6GNeko3g83Tf39b0rIsw3bHVGcl4/1n+r7h3GfS2iQrQhE queg== X-Gm-Message-State: AOAM531zqEn4ST5FpUAm8vwbiZc5bFjzwCHaFczLFprJJ+hEtymaVHav 8c4q9xSVDOpwhmhKGl3ApFDRkTLegXA= X-Google-Smtp-Source: ABdhPJyWoGa8fQwutjq4l4QYAZFAGCzghHNwcFZL03ThCcRLod83F1elRF/SK4XSy88NZ/nK1FotYQ== X-Received: by 2002:a17:902:8495:b0:13e:6a01:f5fb with SMTP id c21-20020a170902849500b0013e6a01f5fbmr4828385plo.61.1633022862048; Thu, 30 Sep 2021 10:27:42 -0700 (PDT) Received: from localhost (61-245-128-160.3df580.per.nbn.aussiebb.net. [61.245.128.160]) by smtp.gmail.com with ESMTPSA id f24sm3657419pfk.198.2021.09.30.10.27.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Sep 2021 10:27:41 -0700 (PDT) From: Timothy To: Org Mode List Subject: [PATCH] Don't fill displayed equations Date: Fri, 01 Oct 2021 01:20:05 +0800 User-agent: mu4e 1.6.5; emacs 28.0.50 Message-ID: <87czoq7z3p.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=tecosaur@gmail.com; helo=mail-pl1-x62f.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.23 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1633022896; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=Oxj3IEWh5YiMxeTVRn6EV0ZA0G33NvQeGMtdx9GoCwA=; b=MiKoqiKHUuMnFdzcEn1zrzdHawwXp4JCN8By1J6+FMBULIhFI+86/wzbGHGApFwFwhZcIl D3aUj569dc4SteHryblj2iJqpBLFYjfdNaV9gb0wpY/VJbtIMoTQ8VRhbroTBvhumadfH7 stEFBYFfqpP0ZVCYELTTGN+g9IY0BThw6s/FX7b4WSnvYoXSTKykPJP6ewlbdZesIhaiGR Xkm1wYif+sF4fJbEWMIpQulUVf3JBJT1wvAsjVugYrgGY0B3S/1tGdZn08GvS/mtEayYKH lsMWQgx6EfvLaJQVTffzdZQWKhbwtmh3h1YOWaK/qXyuHZzEnQZM5W1789RWeg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1633022896; a=rsa-sha256; cv=none; b=NtrmZ3BPougTaeU6t17mqnc+CZz4coeI3C4eAW3d0H68T8x4QDcn6o8M9PA8QIZeefMNyt y/5hwXZlouVxGakfwXULAMSIT9PtaZZ8RwoHWZToWi9eSfHYbbQT4ZnlxRdzTIIJPmroeT ZKEx8UOmDkQSC7hsMLi87RoEhpDLCuyjX/xwKwiL4LAvwCl7cJPi5kT/JMumHE8Jxe8xxb Amm2uSNrs6fGwG89UQY3ZIosMztL3u792vmk3EA4Pom9KIw0H5VjUxunniEuyHGIVsY2Ui hJE+3EXYqWABoesrLXPu1ugcIC6mAllbC7gBSWVwSHTz9nWRLdTubBQOBELeXg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=QafhavqO; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -3.10 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=QafhavqO; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: B001C31523 X-Spam-Score: -3.10 X-Migadu-Scanner: scn0.migadu.com X-TUID: Hpe2sSVj5Iec --=-=-= Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi All, If a displayed equation (`\[ ... \]') starts on its own line, I don=E2=80= =99t think it should be filled into the rest of the text. I.e., =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80 =E2=94=82 some nice text =E2=94=82 \[ =E2=94=82 1+1=3D2 =E2=94=82 \] =E2=94=82 more text. =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80 should not become, =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80 =E2=94=82 some nice text \[ 1+1=3D3 \] more text. =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80 While the above example may not look bad, with non-trivial equations this can become quite messy. As such, I have attached a patch which adds fill =E2=80=9Ccuts=E2=80=9D aro= und `\[' and `\]', when `\[' occurs at the start of a line. This leaves the display equa= tion delimiters on their own line. I think this motivation for this change is fairly clear, and so without fee= dback I intend to push this in a few days, however I if anybody has comments on t= he way I=E2=80=99m currently implementing this, I=E2=80=99d like to hear your thou= ghts. All the best, Timothy --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-org-Don-t-fill-displayed-equations-into-text.patch >From d008ff3c2218e19bb501137715b05e06a0c511e3 Mon Sep 17 00:00:00 2001 From: TEC Date: Fri, 1 Oct 2021 01:14:21 +0800 Subject: [PATCH] org: Don't fill displayed equations into text * list/org.el (org-fill-element): If a displayed equation (\[ ... \]) starts on its own line, it should not be filled into the rest of the text. I.e., some nice text \[ 1+1=2 \] more text. should not become, some nice text \[ 1+1=3 \] more text. While the above example may not look bad, with non-trivial equations this can become quite messy. --- lisp/org.el | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lisp/org.el b/lisp/org.el index 405f0f0f9..daf1d91b4 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -19551,10 +19551,10 @@ (defun org-fill-element (&optional justify) (org-element-property :contents-end element)))) ;; Do nothing if point is at an affiliated keyword. (if (< (line-end-position) beg) t - ;; Fill paragraph, taking line breaks into account. (save-excursion (goto-char beg) (let ((cuts (list beg))) + ;; Cut fill on line breaks. (while (re-search-forward "\\\\\\\\[ \t]*\n" end t) (when (eq 'line-break (org-element-type @@ -19562,6 +19562,16 @@ (defun org-fill-element (&optional justify) (org-element-context)))) (push (point) cuts))) (dolist (c (delq end cuts)) + ;; Cut fill on displayed equations. + (while (re-search-forward "^[ \t]*\\\\\\[" end t) + (let ((el (org-element-context))) + (when (eq 'latex-fragment (org-element-type el)) + (setf cuts (append + (list (org-element-property :end el) + (- (org-element-property :end el) 2) + (+ (org-element-property :begin el) 2) + (org-element-property :begin el)) + cuts))))) (fill-region-as-paragraph c end justify) (setq end c)))) t))) -- 2.33.0 --=-=-=--