Re: [O] Exponents / subscripts

2014-10-23 Thread Nicolas Goaziou
Rasmus  writes:

> Bur surely the fact that $\beta$ is displayed $β$ is a consequence of
> org-entities.el?  Whether desirable or not.

That's the leak I'm talking about. You can also insert "\beta" in an
example block.

> Just out of curiosity, can you mention a couple of (org) function to
> look at to see how fontification works?

`org-set-font-lock-defaults', `org-do-emphasis-faces',
`org-raise-scripts'... and basically every function with a single LIMIT
argument.



Re: [O] Exponents / subscripts

2014-10-23 Thread Rasmus
Nicolas Goaziou  writes:

> Hello,
>
> Rasmus  writes:
>
>> An external library is ideal (had it existed), but where to stop?  Are
>> entities wrapped in math "supported syntax"?
>> E.g. "$\alpha\beta\gamma\delta$".
>
> No. What is inside a math snippet/environment is a black box for Org.
> Entities are a different beast that do not require a math environment
> (e.g., "\alpha" is not considered to be LaTeX code).

Bur surely the fact that $\beta$ is displayed $β$ is a consequence of
org-entities.el?  Whether desirable or not.

>> So your strategy would be to disable fontification within math (since
>> the syntax is not org), and delegate it to a separate library, say
>> tex-fold.el (which also doesn't work out-of-the-box in Org-buffers)?
>> In theory it's ideal, but consistency (e.g. supported entities) and
>> comparability is probably issues.
>
> I don't think so. No fontification at all on LaTeX code is a decent
> default in an Org buffer. Additional, exact, fontification for it is
> a nice bonus.

I would like to agree, but I get too much joy from the current
imprecise implementation.  From a practical perspective the current
state is OK and much preferable over the alternative.  IOW and IMO,
let's not touch it unless we've got something better!

>>> This doesn't solve the leak of Org's fontification on math snippets and
>>> environments.
>>
>> But it would if you can delegate parsing of math to a separate
>> library, no?
>
> No it wouldn't, because Org would still have to fontify sub/superscript
> outside math snippets. Of course, dedicated fontification could override
> leaked one, but I think this would be troublesome in some occasions.
>
> At some point, I hope to introduce the parser in the fontification
> process, which would some the problem.

Just out of curiosity, can you mention a couple of (org) function to
look at to see how fontification works?

—Rasmus

-- 
m-mm-mmm- bacon!



Re: [O] Exponents / subscripts

2014-10-23 Thread Nicolas Goaziou
Hello,

Rasmus  writes:

> An external library is ideal (had it existed), but where to stop?  Are
> entities wrapped in math "supported syntax"?
> E.g. "$\alpha\beta\gamma\delta$".

No. What is inside a math snippet/environment is a black box for Org.
Entities are a different beast that do not require a math environment
(e.g., "\alpha" is not considered to be LaTeX code).

> So your strategy would be to disable fontification within math (since
> the syntax is not org), and delegate it to a separate library, say
> tex-fold.el (which also doesn't work out-of-the-box in Org-buffers)?
> In theory it's ideal, but consistency (e.g. supported entities) and
> comparability is probably issues.

I don't think so. No fontification at all on LaTeX code is a decent
default in an Org buffer. Additional, exact, fontification for it is
a nice bonus.

>> This doesn't solve the leak of Org's fontification on math snippets and
>> environments.
>
> But it would if you can delegate parsing of math to a separate
> library, no?

No it wouldn't, because Org would still have to fontify sub/superscript
outside math snippets. Of course, dedicated fontification could override
leaked one, but I think this would be troublesome in some occasions.

At some point, I hope to introduce the parser in the fontification
process, which would some the problem.


Regards,

-- 
Nicolas Goaziou



Re: [O] Exponents / subscripts

2014-10-22 Thread Fabrice Popineau
2014-10-22 11:13 GMT+02:00
>
>
> Unfortunately, some users complain about the approximation. OTOH, I'm
> pretty sure that most LaTeX users can parse sub/superscript LaTeX code
> without any fontification at all.
>

If there is no easy way to fix it, I may prefer to disable this
fontification,
because it displays something which is wrong (also the superscript is too
small in my opinion,
sometimes the character is unreadable).

The current \(a^nb^n\) is actually displayed as \(a^{nbn}\) which is
misleading.

This is what bothered me first.

OTOH, I have set up preview of formulas (actually I did it for tikz
diagrams) and it works well.
It is slower, and I use it for complicated formulas only, but at least it
is exact.

Fabrice


Re: [O] Exponents / subscripts

2014-10-22 Thread Rasmus
Hi,

Nicolas Goaziou  writes:

> Rasmus  writes:
>
>> Had preview-latex supported Org I'd maybe agree, but I disagree
>> strongly at this time.
>
> Patch welcome.

Cf. a recent thread on emacs.devel it's pretty non-trivial to make
preview-latex work outside of AUCTeX.

>> sub/superscript works well with entities and makes it very easy to
>> edit math and get approximate live feedback.
>
> Unfortunately, some users complain about the approximation. OTOH, I'm
> pretty sure that most LaTeX users can parse sub/superscript LaTeX code
> without any fontification at all.

Of course they can, but it takes more effort.  Compare:

(1)   \beta E_{t}[\sum_{j=t}^{T} z_{j}^{e}]
(2)   βE_{t}[∑_{j=t}^{T} z_{j}^{e}]
(3)   βEₜ[∑ⱼ₌ₜᵀzⱼᵉ]

(3) takes no effort to read, whereas the barebone (1) and the
entities-only (2) still take considerable amount of effort to parse
IMO.

>> IOW and IMO, the "bug", if any, is the fontification of superscript in
>> math.
>
> This is not Org's job since you're talking about a non-compatible
> syntax. I think it should be done in a different library (i.e., not
> "org.el"), if at all.

An external library is ideal (had it existed), but where to stop?  Are
entities wrapped in math "supported syntax"?
E.g. "$\alpha\beta\gamma\delta$".

> You want to implement a subset of Auctex. Either you delegate it to that
> major mode (à la Babel), at the price of some slowdown, or you duplicate
> code from it (i.e., `font-latex-match-script').


> In both cases, you need to know when point is on a math snippet or
> environment, which should rely on `org-element-context' if you're
> serious about it.

So your strategy would be to disable fontification within math (since
the syntax is not org), and delegate it to a separate library, say
tex-fold.el (which also doesn't work out-of-the-box in Org-buffers)?
In theory it's ideal, but consistency (e.g. supported entities) and
comparability is probably issues.

I know nothing on the technical level of fortification so I'm not sure
I could work on this issue efficiently.

> This doesn't solve the leak of Org's fontification on math snippets and
> environments.

But it would if you can delegate parsing of math to a separate
library, no?

—Rasmus

-- 
To err is human. To screw up 10⁶ times per second, you need a computer











Re: [O] Exponents / subscripts

2014-10-22 Thread Nicolas Goaziou
Hello,

Rasmus  writes:

> Had preview-latex supported Org I'd maybe agree, but I disagree
> strongly at this time.

Patch welcome.

> sub/superscript works well with entities and makes it very easy to
> edit math and get approximate live feedback.

Unfortunately, some users complain about the approximation. OTOH, I'm
pretty sure that most LaTeX users can parse sub/superscript LaTeX code
without any fontification at all.

> IOW and IMO, the "bug", if any, is the fontification of superscript in
> math.

This is not Org's job since you're talking about a non-compatible
syntax. I think it should be done in a different library (i.e., not
"org.el"), if at all.

You want to implement a subset of Auctex. Either you delegate it to that
major mode (à la Babel), at the price of some slowdown, or you duplicate
code from it (i.e., `font-latex-match-script').

In both cases, you need to know when point is on a math snippet or
environment, which should rely on `org-element-context' if you're
serious about it.

This doesn't solve the leak of Org's fontification on math snippets and
environments.


Regards,

-- 
Nicolas Goaziou



Re: [O] Exponents / subscripts

2014-10-21 Thread Rasmus
Nicolas Goaziou  writes:

> Rasmus  writes:
>
>> Nicolas Goaziou  writes:
>>
>>> Fabrice Popineau  writes:
>>>
 Given that it is only a matter of presentation, does that mean it could be
 changed ?
 If yes, I can try to give it a shot.
>>>
>>> If you mean that a^bc should be equivalent to a^{b}c, then I think it is
>>> superior in its current state.
>>
>> As I understand Fabrice's mail, it's only about display of scripts in
>> Org buffers (when org-pretty-entities-include-sub-superscripts is
>> non-nil).  So rather than displaying
>>
>> (+)   \(a^nb^n\)
>>
>> as
>>
>>   \(aⁿᵇⁿ\)
>>
>> it would be displayed as
>>
>> (*)   \(aⁿbⁿ\)
>>
>> Of course, it /only/ makes sense to change how it is displayed in
>> math-mode, for which (*) is the more accurate depiction of (+).
>
> If we're talking about math mode, then I think no overlay should be
> added on them, and let `org-toggle-inline-images' display them
> correctly. IOW, \(a^nb^n\) should be displayed as \(a^nb^n\).
>
> It is, IMO, a bug in the current fontification, in which sub/superscript
> handling leaks over math snippets.

I disagree.

org-toggle-inline-images and fontification of *scripts is are
complements at best.

org-toggle-inline-images is slow and inconvenient for anything but
finished documents.  Had preview-latex supported Org I'd maybe agree,
but I disagree strongly at this time.

sub/superscript works well with entities and makes it very easy to
edit math and get approximate live feedback.

IOW and IMO, the "bug", if any, is the fontification of superscript in
math.

—Rasmus

-- 
To err is human. To screw up 10⁶ times per second, you need a computer



Re: [O] Exponents / subscripts

2014-10-21 Thread Nicolas Goaziou
Hello,

Rasmus  writes:

> Nicolas Goaziou  writes:
>
>> Fabrice Popineau  writes:
>>
>>> Given that it is only a matter of presentation, does that mean it could be
>>> changed ?
>>> If yes, I can try to give it a shot.
>>
>> If you mean that a^bc should be equivalent to a^{b}c, then I think it is
>> superior in its current state.
>
> As I understand Fabrice's mail, it's only about display of scripts in
> Org buffers (when org-pretty-entities-include-sub-superscripts is
> non-nil).  So rather than displaying
>
> (+)   \(a^nb^n\)
>
> as
>
>   \(aⁿᵇⁿ\)
>
> it would be displayed as
>
> (*)   \(aⁿbⁿ\)
>
> Of course, it /only/ makes sense to change how it is displayed in
> math-mode, for which (*) is the more accurate depiction of (+).

If we're talking about math mode, then I think no overlay should be
added on them, and let `org-toggle-inline-images' display them
correctly. IOW, \(a^nb^n\) should be displayed as \(a^nb^n\).

It is, IMO, a bug in the current fontification, in which sub/superscript
handling leaks over math snippets.


Regards,

-- 
Nicolas Goaziou



Re: [O] Exponents / subscripts

2014-10-20 Thread Rasmus
Hi,

Nicolas Goaziou  writes:

> Fabrice Popineau  writes:
>
>> Given that it is only a matter of presentation, does that mean it could be
>> changed ?
>> If yes, I can try to give it a shot.
>
> If you mean that a^bc should be equivalent to a^{b}c, then I think it is
> superior in its current state.

As I understand Fabrice's mail, it's only about display of scripts in
Org buffers (when org-pretty-entities-include-sub-superscripts is
non-nil).  So rather than displaying

(+)   \(a^nb^n\)

as

  \(aⁿᵇⁿ\)

it would be displayed as

(*)   \(aⁿbⁿ\)

Of course, it /only/ makes sense to change how it is displayed in
math-mode, for which (*) is the more accurate depiction of (+).

If what was indeed what Fabrice had in mind I think it makes sense.
But I also have been bothered by how (+) is displayed in the past. . .

—Rasmus

-- 
I hear there's rumors on the, uh, Internets. . .




Re: [O] Exponents / subscripts

2014-10-20 Thread Nicolas Goaziou
Hello,

Fabrice Popineau  writes:

> Given that it is only a matter of presentation, does that mean it could be
> changed ?
> If yes, I can try to give it a shot.

If you mean that a^bc should be equivalent to a^{b}c, then I think it is
superior in its current state.


Regards,

-- 
Nicolas Goaziou



Re: [O] Exponents / subscripts

2014-10-19 Thread Fabrice Popineau
2014-10-19 19:08 GMT+02:00 Nicolas Goaziou :

> Hello,
>
> Fabrice Popineau  writes:
>
> > A minor issue and I haven't check if it has already been raised in the
> past.
> > Currently something like \(a^nb^n\) is the org-mode buffer
> > as \(a^{nbn}\). IE it starts exponent mode and stops it at the next
> space.
> > Could it be made to behave more like LaTeX, i.e. only the next char
> > except if braces ? Or is it something beyond the Org parser / syntax ?
>
> This is not beyond anything. It is (historically) meant to be that way.
>
>
Given that it is only a matter of presentation, does that mean it could be
changed ?
If yes, I can try to give it a shot.

Fabrice


Re: [O] Exponents / subscripts

2014-10-19 Thread Nicolas Goaziou
Hello,

Fabrice Popineau  writes:

> A minor issue and I haven't check if it has already been raised in the past.
> Currently something like \(a^nb^n\) is the org-mode buffer
> as \(a^{nbn}\). IE it starts exponent mode and stops it at the next space.
> Could it be made to behave more like LaTeX, i.e. only the next char
> except if braces ? Or is it something beyond the Org parser / syntax ?

This is not beyond anything. It is (historically) meant to be that way.


Regards,

-- 
Nicolas Goaziou



[O] Exponents / subscripts

2014-10-19 Thread Fabrice Popineau
Hi,

A minor issue and I haven't check if it has already been raised in the past.
Currently something like \(a^nb^n\) is the org-mode buffer
as \(a^{nbn}\). IE it starts exponent mode and stops it at the next space.
Could it be made to behave more like LaTeX, i.e. only the next char
except if braces ? Or is it something beyond the Org parser / syntax ?

Regards,

-- 
Fabrice Popineau