From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id KK+HMj1WuWMC3wAAbAwnHQ (envelope-from ) for ; Sat, 07 Jan 2023 12:23:41 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id yKS7MT1WuWNPEAAAG6o9tA (envelope-from ) for ; Sat, 07 Jan 2023 12:23:41 +0100 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 EF68413B9C for ; Sat, 7 Jan 2023 12:23:40 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pE7Hn-0000s7-HY; Sat, 07 Jan 2023 06:22:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pE7Hj-0000rK-NU for emacs-orgmode@gnu.org; Sat, 07 Jan 2023 06:22:47 -0500 Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pE7Hg-0002ua-AB for emacs-orgmode@gnu.org; Sat, 07 Jan 2023 06:22:47 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 172492403A4 for ; Sat, 7 Jan 2023 12:22:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1673090560; bh=yKNI1fm96UX9TvAAniTWCh/QXhohxWMvsOV4nvgW0qQ=; h=From:To:Cc:Subject:Date:From; b=Z2s9XIf+fGG7zxwRGmvh5SBzOIiiBNXO7zFRv5ryEUcNb/XLA2JjTNKu/JyByHz7R SL/ZpxdQdg6uH0yk6AmE7ko5R+ZQL77WI5/0J1nH0VGugJQcwDWqPdfVeZNAE7Qwlw zHoGe8zUdJxHOnIn9FnkzOdJWNGpQL00VHAlOJIDz6WXeiHozqCxWBc305dGOFPH+z u46NZ+FrMe+JqizkDuZ901pTQS3tiIir1XGEexYLiRX34TnqsmsRs7R7M48PiQnHci seeFmqxgN88FTqhhM58xs/NIDAe2rArHGjWgo6LeLMsB3IUhu54GCysHlI2tmkuMWe EXm5OPVqoxSww== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4NpyVQ2rb7z6tm6; Sat, 7 Jan 2023 12:22:38 +0100 (CET) From: Ihor Radchenko To: Daniel Fleischer Cc: Justin Silverman , emacs-orgmode@gnu.org Subject: Re: [BUG] issue with texmathp [9.6 (release_9.6-22-g78d283 @ /home/jds6696/.emacs.d/straight/build/org-mode/)] In-Reply-To: References: <87v8mktt38.fsf@gmail.com> <878rjfsj9o.fsf@localhost> <874jtzhypq.fsf@gmail.com> <87tu1yqu3l.fsf@localhost> Date: Sat, 07 Jan 2023 11:23:07 +0000 Message-ID: <87ilhimvvo.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1673090621; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=jBxLFqdui4fvc4FU7GKgUIZy9ZErdj2dqknY4/w7k38=; b=S2jE5ZIuiRpKJekupCI0FhUxQONyaaqAoNNjjWaQT+I1PHOGY9+U9ViQRilLzUzOvOcS66 LXACkGR6tO1MgCXPZdVbBGaVmEOIVXaQVzRnZLEVcuoW0nXG7N1CPF6ctevSPuVYmlc7sh yrzVOgK+vbn2WCTNTebIJrT51to4UyhhFx+zSFFb1X+G9tOD89UG4W6NYNN3/TFEduFTiy +Vrk3sOa3aTJIvLZXcyHNDo0tyHiS/AsM3EwIIl5r75TfzacEVT0rS8fV5i1Od6Qv1d/rY NK5A8M2PgRClOAveB1Fr1KMv/fpVNiZymHmrwlYe1PpDUdZw9KR7NHRl2pzAnQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=Z2s9XIf+; 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"; dmarc=pass (policy=none) header.from=posteo.net ARC-Seal: i=1; s=key1; d=yhetil.org; t=1673090621; a=rsa-sha256; cv=none; b=uLXmf5UG+3QDFuO89wFEllsunw2AT+bxiqVwXVGHBnk4+BWxKbRjAo0ccARncr7goMup81 1n1Z9LEGr1V3F/Wsjjk3NxCpw0RxstksVqBifw1klXo5OoBiVEcubXA5gojGXzSt9g1vuu EeY7jSJc+hQswq7h814J+k5iYTcEvNe/LK+Rg97d/zwuYPYJ0KPM6WIN7KVwBr+JLU5ZdX nMHegOGYZlK/7NCtGO5G6auZ2moe8TgykKM++yDVmVAJGevSTBoQmupOVl+M6nBn4hYFf9 BAlvafpsH2uxXMvEq3MMc8vTpcHKiY8pL36AAsl+6UrNV1/9snRWaA7tc+Zu6A== X-Spam-Score: -4.50 X-Migadu-Queue-Id: EF68413B9C Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=Z2s9XIf+; 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"; dmarc=pass (policy=none) header.from=posteo.net X-Migadu-Scanner: scn1.migadu.com X-Migadu-Spam-Score: -4.50 X-TUID: olf720Yn0bdz --=-=-= Content-Type: text/plain Daniel Fleischer writes: > I just found this thread after math-related things stopped working. I > have two use cases that don't work now: > > 1. Inserting a dollar pair $$ using `cdlatex-dollar` (it thinks we're > inside a math environment). > > 2. Inserting of cdlatex environments using their built-in completions, e.g. > ali > eqn > stopped working. Thanks for reporting! So, the docstring was erroneous at the end. Can you try to test the attached patch? --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-org-cdlatex-mode-Fix-regression-from-f01390cf05.patch >From bce44c75b73fa0b935a9f991624a292e061f5c73 Mon Sep 17 00:00:00 2001 Message-Id: From: Ihor Radchenko Date: Sat, 7 Jan 2023 14:17:26 +0300 Subject: [PATCH] org-cdlatex-mode: Fix regression from f01390cf05 * lisp/org.el (org--math-always-on): Rename to `org--math-p' and only override `texmathp' when current command is `cdlatex-math-symbol' or when we are inside Org LaTeX math fragment. Only these two scenarios are the places where `texmathp' may not work properly in Org files. We must not return t outside latex fragments as initially suggested by the docstring because it would break, for example, `cdlatex-dollar' command. (org-cdlatex-mode): Use the new function name for advice. * lisp/org-compat.el (org--math-always-on): Declare obsolete. Reported-by: Daniel Fleischer Link: https://orgmode.org/list/m2cz7sj5zt.fsf@gmail.com --- lisp/org-compat.el | 3 +++ lisp/org.el | 27 ++++++++++++++++----------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/lisp/org-compat.el b/lisp/org-compat.el index 6c5085255..0f6dc831a 100644 --- a/lisp/org-compat.el +++ b/lisp/org-compat.el @@ -568,6 +568,9 @@ (defun org-let2 (list1 list2 &rest body) ;FIXME: Where did our karma go? (make-obsolete 'org-let "to be removed" "9.6") (make-obsolete 'org-let2 "to be removed" "9.6") +(define-obsolete-function-alias 'org--math-always-on + 'org--math-p "9.7") + (defun org-compatible-face (inherits specs) "Make a compatible face specification. If INHERITS is an existing face and if the Emacs version supports diff --git a/lisp/org.el b/lisp/org.el index ae6250e52..44c41a729 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -15434,13 +15434,15 @@ (define-minor-mode org-cdlatex-mode (cdlatex-compute-tables)) (unless org-cdlatex-texmathp-advice-is-done (setq org-cdlatex-texmathp-advice-is-done t) - (advice-add 'texmathp :around #'org--math-always-on))) + (advice-add 'texmathp :around #'org--math-p))) -(defun org--math-always-on (orig-fun &rest args) - "Always return t in Org buffers. -This is because we want to insert math symbols without dollars even outside -the LaTeX math segments. If Org mode thinks that point is actually inside -an embedded LaTeX fragment, let `texmathp' do its job. +(defun org--math-p (orig-fun &rest args) + "Return t inside math fragments or running `cdlatex-math-symbol'. +This function is intended to be an :around advice for `texmathp'. + +If Org mode thinks that point is actually inside +an embedded LaTeX environment, return t when the environment is math +or let `texmathp' do its job otherwise. `\\[org-cdlatex-mode-map]'" (interactive) (cond @@ -15450,11 +15452,14 @@ (defun org--math-always-on (orig-fun &rest args) t) (t (let ((element (org-element-context))) - (or (not (org-inside-LaTeX-fragment-p element)) - (if (not (eq (org-element-type element) 'latex-fragment)) - (apply orig-fun args) - (setq texmathp-why '("Org mode embedded math" . 0)) - t)))))) + (when (org-inside-LaTeX-fragment-p element) + (pcase (substring-no-properties + (org-element-property :value element) + 0 2) + ((or "\\(" "\\[" (pred (string-match-p (rx string-start "$")))) + (setq texmathp-why '("Org mode embedded math" . 0)) + t) + (_ (apply orig-fun args)))))))) (defun turn-on-org-cdlatex () "Unconditionally turn on `org-cdlatex-mode'." -- 2.38.1 --=-=-= Content-Type: text/plain -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at --=-=-=--