The attached patch what works for me.  It is however the result
of a short trail'n'error session, since I'm by no means an
experienced lisp/elisp programmer.

With the patch the behavior is slightly different than usual with
lists.  Before TAB cycles the list, the cursor jumps out of the
Latex fragment:

action:
 - $y = a_0 + a_{1[TAB]}$
  + foo

result:
 - $y = a_0 + a_1[CURSOR]$
  + foo

action:
 - $y = a_0 + a_1[TAB]$
  + foo

result:
 - $y = a_0 + a_1$[CURSOR]
  + foo

action:
 - $y = a_0 + a_1$[TAB]
  + foo

result: emacs mumbles "SUBTREE".

action:
 - $y = a_0 + a_1$[TAB]
  + foo

result:
 - $y = a_0 + a_1$...
From 43ae3ff0393d8a43c02938ae621ae7a1c1d67b61 Mon Sep 17 00:00:00 2001
From: Maik Beckmann <beckmann.m...@googlemail.com>
Date: Thu, 10 Nov 2011 11:51:07 +0100
Subject: [PATCH] When in a Latex fragment, try cdlatex-tab before the trying
 to cyle the list.

---
 lisp/org.el |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 92ced78..6f81981 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -6143,6 +6143,8 @@ in special contexts.
 	     (or (bolp) (not (eq org-cycle-emulate-tab 'exc-hl-bol))))
 	(org-inlinetask-toggle-visibility))
 
+       ((and (org-inside-LaTeX-fragment-p) (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)
@@ -6158,8 +6160,6 @@ in special contexts.
 
        ((org-try-structure-completion))
 
-       ((org-try-cdlatex-tab))
-
        ((run-hook-with-args-until-success
 	 'org-tab-before-tab-emulation-hook))
 
-- 
1.7.7.3

Reply via email to