From 67a9573f0de2f2cf10408c646cb5ff8781b51ce8 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 3 Jan 2022 16:41:37 +0100 Subject: [PATCH] fix(org): tab not invoking cdlatex-tab in headings In org-mode, if one writes a math expression in a section (i.e. heading) while using cdlatex, pressing tab indents the section instead of performing a cdlatex-tab. This fix takes care of this issue to have the wanted behavior: if in math environment and hit tab while in section, execute cdlatex-tab. Close: #5926 Co-authored-by: roiholtzman --- modules/lang/org/autoload/org.el | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/lang/org/autoload/org.el b/modules/lang/org/autoload/org.el index 8dfb0e88a..2125b3fbd 100644 --- a/modules/lang/org/autoload/org.el +++ b/modules/lang/org/autoload/org.el @@ -375,6 +375,10 @@ Made for `org-tab-first-hook' in evil-mode." (cond ((not (and (bound-and-true-p evil-local-mode) (evil-insert-state-p))) nil) + ((and (bound-and-true-p org-cdlatex-mode) + (or (org-inside-LaTeX-fragment-p) + (org-inside-latex-macro-p))) + nil) ((org-at-item-p) (if (eq this-command 'org-shifttab) (org-outdent-item-tree) @@ -441,7 +445,10 @@ of the time I just want to peek into the current subtree -- at most, expand All my (performant) foldings needs are met between this and `org-show-subtree' (on zO for evil users), and `org-cycle' on shift-TAB if I need it." (interactive "P") - (unless (eq this-command 'org-shifttab) + (unless (or (eq this-command 'org-shifttab) + (and (bound-and-true-p org-cdlatex-mode) + (or (org-inside-LaTeX-fragment-p) + (org-inside-latex-macro-p)))) (save-excursion (org-beginning-of-line) (let (invisible-p)