summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2011-11-12 15:04:19 +0100
committerNicolas Goaziou <n.goaziou@gmail.com>2011-11-13 10:31:47 +0100
commitb13b3e30d75acbe4fd32ad5b4a88a967ba203868 (patch)
treebe45519afaf90f99bc3f2b1cf4259ae8744ac18e
parentc5081b8f14767b1c8d6d77e0ff67aa702560c286 (diff)
downloadorg-mode-b13b3e30d75acbe4fd32ad5b4a88a967ba203868.tar.gz
Allow cdlatex expansions at a list item or an headline
* lisp/org.el (org-try-cdlatex-tab): Don't try to expand a LaTeX environment when at an item or an headline, but allow LaTeX fragments. (org-cycle): Try to call `cdlatex-tab' before cycling item's or headline's visibility, in order to catch LaTeX fragments within. This patch is based on the report and work of Maik Beckmann.
-rw-r--r--lisp/org.el14
1 files changed, 8 insertions, 6 deletions
diff --git a/lisp/org.el b/lisp/org.el
index 9f5754d..8b33cf6 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -6144,6 +6144,8 @@ in special contexts.
(or (bolp) (not (eq org-cycle-emulate-tab 'exc-hl-bol))))
(org-inlinetask-toggle-visibility))
+ ((org-try-cdlatex-tab))
+
;; At an item/headline: delegate to `org-cycle-internal-local'.
((and (or (and org-cycle-include-plain-lists (org-at-item-p))
(save-excursion (beginning-of-line 1)
@@ -6159,8 +6161,6 @@ in special contexts.
((org-try-structure-completion))
- ((org-try-cdlatex-tab))
-
((run-hook-with-args-until-success
'org-tab-before-tab-emulation-hook))
@@ -16563,14 +16563,16 @@ It makes sense to do so if `org-cdlatex-mode' is active and if the cursor is
insert a LaTeX environment."
(when org-cdlatex-mode
(cond
+ ;; Before any word on the line: No expansion possible.
+ ((save-excursion (skip-chars-backward " \t") (bolp)) nil)
+ ;; Just after first word on the line: Expand it. Make sure it
+ ;; cannot happen on headlines, though.
((save-excursion
(skip-chars-backward "a-zA-Z0-9*")
(skip-chars-backward " \t")
- (bolp))
- (cdlatex-tab) t)
- ((org-inside-LaTeX-fragment-p)
+ (and (bolp) (not (org-at-heading-p))))
(cdlatex-tab) t)
- (t nil))))
+ ((org-inside-LaTeX-fragment-p) (cdlatex-tab) t))))
(defun org-cdlatex-underscore-caret (&optional arg)
"Execute `cdlatex-sub-superscript' in LaTeX fragments.