From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id Vy9OKET4VWFa1wAAgWs5BA (envelope-from ) for ; Thu, 30 Sep 2021 19:47:48 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id aKBCI0T4VWGFawAAbx9fmQ (envelope-from ) for ; Thu, 30 Sep 2021 17:47:48 +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 4248E319FE for ; Thu, 30 Sep 2021 19:47:48 +0200 (CEST) Received: from localhost ([::1]:44830 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mW09o-0004UP-Fw for larch@yhetil.org; Thu, 30 Sep 2021 13:47:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43084) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mW07Z-0004Si-Px for emacs-orgmode@gnu.org; Thu, 30 Sep 2021 13:45:27 -0400 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]:39473) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mW07W-0006DD-JW for emacs-orgmode@gnu.org; Thu, 30 Sep 2021 13:45:25 -0400 Received: by mail-pf1-x42a.google.com with SMTP id g2so5662599pfc.6 for ; Thu, 30 Sep 2021 10:45:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=references:user-agent:from:to:subject:date:in-reply-to:message-id :mime-version; bh=oMkXpMFbm2JS9175a80GXkeBgMBMChqHarOKUVv2JUM=; b=fx6yIN8pnhqUi3eJTZzwzrLyp3HhpmBOlzfQb6OQMzsKerXICSf27BoyDrKMn18NRn 2DCFCfo6hEMwFigVpVYx8chWAzR1/Hd3Gon/jn47KDAsUlpOFVjvnqceKUk9f5Q4SFjw 68P5/HmrHG4lXLE7PMGzBuFGR6bLtxzJXbMGb6sHCGMSU1m5ekqRIbRqwJz0idzGrJZ2 kftfxMjp7d23qmMDIH+861HyEC4+8j3CRNkxSkWywyR3BzLYDZPDsff+jlhZsJY0SSsk UF1iU1Q0k3+ro9E7zmR33Ck/Q321AYriYIr5Tv+xmMhS7FIPclLLe3Tma0FpzfTxddfY S+iQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:references:user-agent:from:to:subject:date :in-reply-to:message-id:mime-version; bh=oMkXpMFbm2JS9175a80GXkeBgMBMChqHarOKUVv2JUM=; b=XWE6O+1yDx2l15XkuaJfyrBTFr0i24wstbauMX18tfJzf5+3Cbxau01AudPA7gVYqB +SnBAwUt9Wu4CE6G3Nm98ghXGyGeTU6o69iNiAhp4/eRzLj8UMP/+EMAsnQ7Dm/Kn2Fg tul8uzvXxQE/j69ullhLLRiU4uxEEPXGsKZuYHbL/7BIMn7u5w4Eu7RarIqGYyMSlk2V kgPsR5nTwyBxf/yQzX+Mi3XXavRH3+e6k/jcUpRqeoVYVsIn6ygSEPEWJLdkPulU5hP0 arPafmm6mpGHQO7GZR0Aa9FvFYDup2UUKKyNPnxJkuwjbPlWRK/fWHt9Qwk1fIcbENug 6xJw== X-Gm-Message-State: AOAM531cvMyihxvjmL2Aezi47a157oH1KCbV7fKFdALzttohlP6c1JUk Wsx52dUQvObVVZ4bpgK8B1w8v5VSSgU= X-Google-Smtp-Source: ABdhPJylj9pR8Hb5MAOpzDNzhrBOZnFauDEZTFiuzoYnKk1wlS1QuFD6CKfU/rXh/iL6oSkNsEV/YQ== X-Received: by 2002:a62:d11e:0:b0:446:d705:7175 with SMTP id z30-20020a62d11e000000b00446d7057175mr5570399pfg.74.1633023918669; Thu, 30 Sep 2021 10:45:18 -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 b129sm3614063pfg.157.2021.09.30.10.45.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Sep 2021 10:45:18 -0700 (PDT) References: <87czoq7z3p.fsf@gmail.com> User-agent: mu4e 1.6.5; emacs 28.0.50 From: Timothy To: Org Mode List Subject: Re: [PATCH] Don't fill displayed equations Date: Fri, 01 Oct 2021 01:44:11 +0800 In-reply-to: <87czoq7z3p.fsf@gmail.com> Message-ID: <878rze7yac.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::42a; envelope-from=tecosaur@gmail.com; helo=mail-pf1-x42a.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=1633024068; 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:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=oMkXpMFbm2JS9175a80GXkeBgMBMChqHarOKUVv2JUM=; b=U4qiX25D6lmRIBaozSNJ/HWxZSFxgUJ4gE0ocgB8Fh458Wdl0NKxJOY6vy5wT8X7l0/VOu 9e0x0t9j6Busf1jsBf4itQM4PId5VefqiUOrrpGwNEPmDdg87Of/tvuk+4YUwPc/YkNsjm kc3doL2BbeEnnKRxva0NfwoXSMevvaOO8D19IsU0x1x19HBhV9gY/HW5vLNSTx6Rvn5g79 E789ZRAUp6+WNcbcTCfqDf+PZ5O93HUPyQWMQkliIl3rZKaPfaxwa82dXrX33VbLZEJ6xP Xe+Sy+77gBbri40tt7F7rEZEFk9+IoiJ79VTyqs09I0mh5PADu8cMjWUdW8dnw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1633024068; a=rsa-sha256; cv=none; b=uAvCQ44oPiy6QZHjOkUSVaPWBOrLX/p151amcLcyo3Hg7qQ+9y0jmyfEIsz2dMwnYrtuXE srrPn154qh5Wu0pSQIdfvWte5nxCmcx0YSHokuB91WeXyMbvcZAs3krsGkK9pqNdxKrxFQ PWw3UKK36CkklFJ8enIJnXydU9hIh+c7PrqNApfIu3e4hU1d4hiWe+CXIm6pAVSnNOi6Kq P5O9g9JJdV8uJueDpVeO0GwWKmfEems/KRTsDVDVmmtydp9+PqVafIh40FZXqCCeEJs4rC u2oZ//C7gpHTfuDw2d49igquxotljWkGyiNqvIWiGhJXCbcmfunV9jeYhv722Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=fx6yIN8p; 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: -4.00 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=fx6yIN8p; 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: 4248E319FE X-Spam-Score: -4.00 X-Migadu-Scanner: scn1.migadu.com X-TUID: 4vOYs8VzrhFH --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable The initial patch was just slightly off. Here's a correct version. Timothy writes: > As such, I have attached a patch which adds fill =E2=80=9Ccuts=E2=80=9D a= round `\[' and > `\]', when `\[' occurs at the start of a line. This leaves the display eq= uation > delimiters on their own line. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-org-Don-t-fill-displayed-equations-into-text.patch >From d6d2221a7a9bf5e3cf93265c13cb643bcfe46929 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..ff86a9dd0 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -19551,16 +19551,26 @@ (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 (save-excursion (backward-char) (org-element-context)))) (push (point) 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))))) (dolist (c (delq end cuts)) (fill-region-as-paragraph c end justify) (setq end c)))) -- 2.33.0 --=-=-=--