emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [bug?] org-inside-latex-fragment-p broken?
@ 2017-06-23 10:26 Rasmus
  2017-06-23 11:55 ` Nicolas Goaziou
  0 siblings, 1 reply; 8+ messages in thread
From: Rasmus @ 2017-06-23 10:26 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

org-inside-LaTeX-fragment-p seems to assume that a latex-fragment only
exists beyond the first paragraph.  It does fails to predict the fragment
in this simple file

#+begin_src org
foo $x$ bar
test `org-inside-LaTeX-fragment-p' on the "$x$" above.
#+end_src

It seems to be fixed if we replace,

    (lim (progn
		 (re-search-backward (concat "^\\(" paragraph-start "\\)") nil t)
		 (point)))

With

    (lim (save-excursion (backward-paragraph) (point)))

Should I push this?

Thanks,
Rasmus

-- 
You people at the NSA are becoming my new best friends!

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

* Re: [bug?] org-inside-latex-fragment-p broken?
  2017-06-23 10:26 [bug?] org-inside-latex-fragment-p broken? Rasmus
@ 2017-06-23 11:55 ` Nicolas Goaziou
  2017-06-23 12:43   ` Rasmus
  0 siblings, 1 reply; 8+ messages in thread
From: Nicolas Goaziou @ 2017-06-23 11:55 UTC (permalink / raw)
  To: Rasmus; +Cc: emacs-orgmode

Hello,

Rasmus <rasmus@gmx.us> writes:

> org-inside-LaTeX-fragment-p seems to assume that a latex-fragment only
> exists beyond the first paragraph.  It does fails to predict the fragment
> in this simple file
>
> #+begin_src org
> foo $x$ bar
> test `org-inside-LaTeX-fragment-p' on the "$x$" above.
> #+end_src
>
> It seems to be fixed if we replace,
>
>     (lim (progn
> 		 (re-search-backward (concat "^\\(" paragraph-start "\\)") nil t)
> 		 (point)))
>
> With
>
>     (lim (save-excursion (backward-paragraph) (point)))
>
> Should I push this?

`backward-paragraph' may be a bit heavy.

Anyway we shouldn't use this function at all. Why do you need it?

Regards,

-- 
Nicolas Goaziou

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

* Re: [bug?] org-inside-latex-fragment-p broken?
  2017-06-23 11:55 ` Nicolas Goaziou
@ 2017-06-23 12:43   ` Rasmus
  2017-06-23 13:45     ` Nicolas Goaziou
  0 siblings, 1 reply; 8+ messages in thread
From: Rasmus @ 2017-06-23 12:43 UTC (permalink / raw)
  To: mail; +Cc: emacs-orgmode

Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> `backward-paragraph' may be a bit heavy.
>
> Anyway we shouldn't use this function at all. Why do you need it?

It's used by a couple of org-cdlatex-* functions,
e.g. org-cdlatex-math-modify.

Rasmus

-- 
Vote for proprietary math!

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

* Re: [bug?] org-inside-latex-fragment-p broken?
  2017-06-23 12:43   ` Rasmus
@ 2017-06-23 13:45     ` Nicolas Goaziou
  2017-06-23 16:43       ` Carsten Dominik
  0 siblings, 1 reply; 8+ messages in thread
From: Nicolas Goaziou @ 2017-06-23 13:45 UTC (permalink / raw)
  To: Rasmus; +Cc: emacs-orgmode

Rasmus <rasmus@gmx.us> writes:

> Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:
>
>> `backward-paragraph' may be a bit heavy.
>>
>> Anyway we shouldn't use this function at all. Why do you need it?
>
> It's used by a couple of org-cdlatex-* functions,
> e.g. org-cdlatex-math-modify.

Then these calls should be replaced with `org-element-context', unless
the callers may be used in partially written LaTeX snippets.

Regards,

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

* Re: [bug?] org-inside-latex-fragment-p broken?
  2017-06-23 13:45     ` Nicolas Goaziou
@ 2017-06-23 16:43       ` Carsten Dominik
  2017-06-23 17:06         ` Nicolas Goaziou
  0 siblings, 1 reply; 8+ messages in thread
From: Carsten Dominik @ 2017-06-23 16:43 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: org-mode list, Rasmus

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

On Fri, Jun 23, 2017 at 9:45 AM, Nicolas Goaziou <mail@nicolasgoaziou.fr>
wrote:

> Rasmus <rasmus@gmx.us> writes:
>
> > Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:
> >
> >> `backward-paragraph' may be a bit heavy.
> >>
> >> Anyway we shouldn't use this function at all. Why do you need it?
> >
> > It's used by a couple of org-cdlatex-* functions,
> > e.g. org-cdlatex-math-modify.
>
> Then these calls should be replaced with `org-element-context', unless
> the callers may be used in partially written LaTeX snippets.
>

Yes, these can be used in partially written fragments.

Carsten

[-- Attachment #2: Type: text/html, Size: 1139 bytes --]

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

* Re: [bug?] org-inside-latex-fragment-p broken?
  2017-06-23 16:43       ` Carsten Dominik
@ 2017-06-23 17:06         ` Nicolas Goaziou
  2017-06-24 11:13           ` Rasmus
  0 siblings, 1 reply; 8+ messages in thread
From: Nicolas Goaziou @ 2017-06-23 17:06 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: org-mode list, Rasmus

Hello,

Carsten Dominik <dominik@uva.nl> writes:

> Yes, these can be used in partially written fragments.

OK. Does it make sense to use them outside of any fragment? For example,
you don't need to be in a LaTeX fragment to insert \alpha.

Regards,

-- 
Nicolas Goaziou                                                0x80A93738

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

* Re: [bug?] org-inside-latex-fragment-p broken?
  2017-06-23 17:06         ` Nicolas Goaziou
@ 2017-06-24 11:13           ` Rasmus
  2017-06-29 13:17             ` Nicolas Goaziou
  0 siblings, 1 reply; 8+ messages in thread
From: Rasmus @ 2017-06-24 11:13 UTC (permalink / raw)
  To: mail; +Cc: dominik, emacs-orgmode

Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> Hello,
>
> Carsten Dominik <dominik@uva.nl> writes:
>
>> Yes, these can be used in partially written fragments.
>
> OK. Does it make sense to use them outside of any fragment? For example,
> you don't need to be in a LaTeX fragment to insert \alpha.

First, we have to be careful because the cdlatex keys occupy a precious
key.

Second, it depends on the cdlatex function in question.
cdlatex-math-symbol-alist already works outside of fragments and it
probably should as it can be used to insert entities, such as "β".

On the other hand, cdlatex-math-modify probably only makes sense inside
fragments.  It is used to change characteristics of already inserted
entity, e.g. make a character bold.  That typically only makes sense
inside a math environment of some sort.  Add to this, that something like
"\mathbf{x}" isn’t "correctly" exported via ox, (it should then produce
"$\mathbf{x}$").  So cdlatex-math-modify should only work inside latex
fragments IMO.

-- 
m-mm-mmm-mmmm bacon!

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

* Re: [bug?] org-inside-latex-fragment-p broken?
  2017-06-24 11:13           ` Rasmus
@ 2017-06-29 13:17             ` Nicolas Goaziou
  0 siblings, 0 replies; 8+ messages in thread
From: Nicolas Goaziou @ 2017-06-29 13:17 UTC (permalink / raw)
  To: Rasmus; +Cc: dominik, emacs-orgmode

Hello,

Rasmus <rasmus@gmx.us> writes:

> First, we have to be careful because the cdlatex keys occupy a precious
> key.
>
> Second, it depends on the cdlatex function in question.
> cdlatex-math-symbol-alist already works outside of fragments and it
> probably should as it can be used to insert entities, such as "β".
>
> On the other hand, cdlatex-math-modify probably only makes sense inside
> fragments.  It is used to change characteristics of already inserted
> entity, e.g. make a character bold.  That typically only makes sense
> inside a math environment of some sort.

Well. Then, could your patch uses `org-backward-paragraph' instead of
plain `backward-paragraph'?

> Add to this, that something like "\mathbf{x}" isn’t "correctly"
> exported via ox, (it should then produce "$\mathbf{x}$").

Of course it is "correctly" exported. When you write raw LaTeX, Org
assumes you know what you are doing.

Regards,

-- 
Nicolas Goaziou

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

end of thread, other threads:[~2017-06-29 13:17 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-23 10:26 [bug?] org-inside-latex-fragment-p broken? Rasmus
2017-06-23 11:55 ` Nicolas Goaziou
2017-06-23 12:43   ` Rasmus
2017-06-23 13:45     ` Nicolas Goaziou
2017-06-23 16:43       ` Carsten Dominik
2017-06-23 17:06         ` Nicolas Goaziou
2017-06-24 11:13           ` Rasmus
2017-06-29 13:17             ` Nicolas Goaziou

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