emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Bug: cdlatex-tab in math-env isn't considered when inside of a list item. [7.7 (release_7.7.513.g2a5877)]
@ 2011-11-10 10:36 Maik Beckmann
  2011-11-10 11:09 ` Maik Beckmann
  0 siblings, 1 reply; 7+ messages in thread
From: Maik Beckmann @ 2011-11-10 10:36 UTC (permalink / raw)
  To: emacs-orgmode

* The observed behavior
Inside a list item cdlatex-tab isn't considered.  An example:

  To circumvent emacs' fill-paragrah issue with \[ \] I prefer using a
  inline math environment in a single item list.  Unfortunately cdlatex
  isn't considered when hitting TAB then
   - $y = a_0 + a_{1[TAB]}$ .
  Emacs echos "EMPTY ENTRY" instead.  The same line without the leading
  list item qualifier works fine.  This line
     $y = a_0 + a_{1[TAB]}$
  results in
     $y = a_0 + a_1$ .


* The reason
In org.el in org-cycle a `cond' statement dispatches is done when
TAB is pressed.  The call to `org-try-cdlatex-tab' is part of
this dispatch.  Before `cond' reaches this entry it reaches the
one which determines whether or not the current context is a list
item.  Since this is true here, `cond' is satified and never
considers `org-try-cdlatex-tab'.  The entry calls
`org-cycle-internal-local' which then emits the "EMPTY ENTRY"
message.


* What I expected
Lets considering the case that there is a sub-item.
 - $y = a_0 + a_{1}$
  + foo
I expect cdlatex-tab to be tried first.  If it's nothing cdlatex
can reason about, expand/collapse the list.  For
 - $y = a_0 + a_{1[TAB]}$
  + foo
turns into
 - $y = a_0 + a_1$
  + foo
Another TAB
 - $y = a_0 + a_1[TAB]$
  + foo
turns it into
 - $y = a_0 + a_1$...


* Org mode version info
Emacs  : GNU Emacs 24.0.91.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.7)
 of 2011-11-04 on myhost
Package: Org-mode version 7.7 (release_7.7.513.g2a5877)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Bug: cdlatex-tab in math-env isn't considered when inside of a list item. [7.7 (release_7.7.513.g2a5877)]
  2011-11-10 10:36 Bug: cdlatex-tab in math-env isn't considered when inside of a list item. [7.7 (release_7.7.513.g2a5877)] Maik Beckmann
@ 2011-11-10 11:09 ` Maik Beckmann
  2011-11-12 14:08   ` Nicolas Goaziou
  0 siblings, 1 reply; 7+ messages in thread
From: Maik Beckmann @ 2011-11-10 11:09 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 624 bytes --]

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$...

[-- Attachment #2: 0001-When-in-a-Latex-fragment-try-cdlatex-tab-before-the-.patch --]
[-- Type: text/x-patch, Size: 1064 bytes --]

From 43ae3ff0393d8a43c02938ae621ae7a1c1d67b61 Mon Sep 17 00:00:00 2001
From: Maik Beckmann <beckmann.maik@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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: Bug: cdlatex-tab in math-env isn't considered when inside of a list item. [7.7 (release_7.7.513.g2a5877)]
  2011-11-10 11:09 ` Maik Beckmann
@ 2011-11-12 14:08   ` Nicolas Goaziou
  2011-11-13  7:20     ` Maik Beckmann
  0 siblings, 1 reply; 7+ messages in thread
From: Nicolas Goaziou @ 2011-11-12 14:08 UTC (permalink / raw)
  To: Maik Beckmann; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 358 bytes --]

Hello,

Maik Beckmann <beckmann.maik@googlemail.com> writes:

> The attached patch what works for me.

Your patch prevents cdlatex expansion for LaTeX environments, since
point must be in a LaTeX fragment to trigger `cdlatex-tab'.

I've slightly modified your patch to repair that. Could you test it and
report back the result?

Thanks,

-- 
Nicolas Goaziou

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch for cdlatex expansion at an item --]
[-- Type: text/x-patch, Size: 1649 bytes --]

From fed598af22ac0ecb29285c02d0a10a5af7d91fef Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou <n.goaziou@gmail.com>
Date: Sat, 12 Nov 2011 15:04:19 +0100
Subject: [PATCH] Allow cdlatex expansions at a list item

* lisp/org.el (org-try-cdlatex-tab): Don't try to expand a LaTeX
  environment when at an item.
(org-cycle): Try to call `cdlatex-tab' before cycling item's
visibility, in order to catch LaTeX fragments at an item.

This patch is a slightly modified version of Maik Beckmann's work.
---
 lisp/org.el |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 9f5754d..0eb458f 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))
 
@@ -16566,7 +16566,8 @@ It makes sense to do so if `org-cdlatex-mode' is active and if the cursor is
      ((save-excursion
 	(skip-chars-backward "a-zA-Z0-9*")
 	(skip-chars-backward " \t")
-	(bolp))
+	;; An environment cannot be started at an item bullet.
+	(and (bolp) (not (org-at-item-p))))
       (cdlatex-tab) t)
      ((org-inside-LaTeX-fragment-p)
       (cdlatex-tab) t)
-- 
1.7.7.3


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: Bug: cdlatex-tab in math-env isn't considered when inside of a list item. [7.7 (release_7.7.513.g2a5877)]
  2011-11-12 14:08   ` Nicolas Goaziou
@ 2011-11-13  7:20     ` Maik Beckmann
  2011-11-13  9:40       ` Nicolas Goaziou
  0 siblings, 1 reply; 7+ messages in thread
From: Maik Beckmann @ 2011-11-13  7:20 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode

2011/11/12 Nicolas Goaziou <n.goaziou@gmail.com>:

> Your patch prevents cdlatex expansion for LaTeX environments, since
> point must be in a LaTeX fragment to trigger `cdlatex-tab'.

That actually bit me yesterday :P

> I've slightly modified your patch to repair that. Could you test it and
> report back the result?

From what i can tell it works flawlessly.


Thank you very much,
Maik

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Bug: cdlatex-tab in math-env isn't considered when inside of a list item. [7.7 (release_7.7.513.g2a5877)]
  2011-11-13  7:20     ` Maik Beckmann
@ 2011-11-13  9:40       ` Nicolas Goaziou
  2011-11-13 10:45         ` Maik Beckmann
  0 siblings, 1 reply; 7+ messages in thread
From: Nicolas Goaziou @ 2011-11-13  9:40 UTC (permalink / raw)
  To: Maik Beckmann; +Cc: emacs-orgmode

Maik Beckmann <beckmann.maik@googlemail.com> writes:

>> I've slightly modified your patch to repair that. Could you test it and
>> report back the result?
>
> From what i can tell it works flawlessly.

I've pushed a close patch into master (I had forgotten to take care of
headlines case).

Thank you for your work.


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Bug: cdlatex-tab in math-env isn't considered when inside of a list item. [7.7 (release_7.7.513.g2a5877)]
  2011-11-13  9:40       ` Nicolas Goaziou
@ 2011-11-13 10:45         ` Maik Beckmann
  2011-11-13 11:34           ` Maik Beckmann
  0 siblings, 1 reply; 7+ messages in thread
From: Maik Beckmann @ 2011-11-13 10:45 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode

2011/11/13 Nicolas Goaziou <n.goaziou@gmail.com>:

>>> I've slightly modified your patch to repair that. Could you test it and
>>> report back the result?
>>
>> From what i can tell it works flawlessly.

I'm sorry, but I just caught a flaw.  I actually remember it being the reason
why I chose to test if the point is inside a latex fragment, which then broke
cdlatex' environment completion outside of fragments. If the point is at the
beginning of a headline cdlatex-tab advances to the next word rather than
leaving it alone.


[TAB]* foo bar bazz
Some test

* [CURSOR]foo bar bazz
Some test

* [TAB]foo bar bazz
Some test

* foo bar bazz...


Regards,
Maik

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Bug: cdlatex-tab in math-env isn't considered when inside of a list item. [7.7 (release_7.7.513.g2a5877)]
  2011-11-13 10:45         ` Maik Beckmann
@ 2011-11-13 11:34           ` Maik Beckmann
  0 siblings, 0 replies; 7+ messages in thread
From: Maik Beckmann @ 2011-11-13 11:34 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode

My bad,  I wrote:

> if the point is at the beginning of a headline cdlatex-tab advances to the next word rather than leaving it alone.

because I evidently didn't read your email closely enough

2011/11/13 Nicolas Goaziou <n.goaziou@gmail.com>:
> ... (I had forgotten to take care of headlines case).


Sorry for the noise and thanks again.

Best,
Maik

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-11-13 11:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-10 10:36 Bug: cdlatex-tab in math-env isn't considered when inside of a list item. [7.7 (release_7.7.513.g2a5877)] Maik Beckmann
2011-11-10 11:09 ` Maik Beckmann
2011-11-12 14:08   ` Nicolas Goaziou
2011-11-13  7:20     ` Maik Beckmann
2011-11-13  9:40       ` Nicolas Goaziou
2011-11-13 10:45         ` Maik Beckmann
2011-11-13 11:34           ` Maik Beckmann

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).