emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/org dfcf500df5: org-cdlatex-mode: Fix regression from f


From: ELPA Syncer
Subject: [elpa] externals/org dfcf500df5: org-cdlatex-mode: Fix regression from f01390cf05
Date: Wed, 11 Jan 2023 06:57:56 -0500 (EST)

branch: externals/org
commit dfcf500df5bbd9d2293cc7e1efd8acb41b8f0f65
Author: Ihor Radchenko <yantar92@posteo.net>
Commit: Ihor Radchenko <yantar92@posteo.net>

    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 <danflscr@gmail.com>
    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 6c50852553..0f6dc831a6 100644
--- a/lisp/org-compat.el
+++ b/lisp/org-compat.el
@@ -568,6 +568,9 @@ Counting starts at 1."
 (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 ae6250e522..44c41a729d 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -15434,13 +15434,15 @@ in Org 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 @@ an embedded LaTeX fragment, let `texmathp' do its job.
     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'."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]