Discussion:
[AUCTeX] How to use tex--prettify-symbols-alist?
Marcin Borkowski
2016-02-27 18:18:11 UTC
Permalink
Hi folks,

I did (setq prettify-symbols-alist tex--prettify-symbols-alist), and
enabled prettify-symbols-mode. However, things do not look as well as
I would like them to.

1. Math between $...$ doesn't get prettified; \(...\) and other
constructs work. Also, symbols outside math mode /do/ work! Why?

2. \(\infty\) does not get prettified; \( \infty\) does. Why? Is that
because prettify-symbols-mode surrounds the regex with the "symbol"
delimiters?

3. I tried adding this to prettify-symbols-alist:
("\\mathbb{R}" . 8477). It didn't work, though. Why is that so?

If nobody of you knows exactly the answer, and would need to dig into
the source code, I'd be happy to actually do it myself and report back
about what I found there; but in case someone already has that figured,
I'd prefer not to spend too much time on this.

TIA,
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University
Marcin Borkowski
2016-02-27 18:22:40 UTC
Permalink
Post by Marcin Borkowski
Hi folks,
I did (setq prettify-symbols-alist tex--prettify-symbols-alist), and
enabled prettify-symbols-mode. However, things do not look as well as
I would like them to.
1. Math between $...$ doesn't get prettified; \(...\) and other
constructs work. Also, symbols outside math mode /do/ work! Why?
2. \(\infty\) does not get prettified; \( \infty\) does. Why? Is that
because prettify-symbols-mode surrounds the regex with the "symbol"
delimiters?
("\\mathbb{R}" . 8477). It didn't work, though. Why is that so?
OK, this one /did/ work; I was a bit impatient and had a glance into the
code, and it turns out that disabling and enabling the mode helped.

The other questions are still a bit of a mystery for me, though.

Best,
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University
Marcin Borkowski
2016-02-27 18:42:31 UTC
Permalink
Post by Marcin Borkowski
Hi folks,
I did (setq prettify-symbols-alist tex--prettify-symbols-alist), and
enabled prettify-symbols-mode. However, things do not look as well as
I would like them to.
1. Math between $...$ doesn't get prettified; \(...\) and other
constructs work. Also, symbols outside math mode /do/ work! Why?
2. \(\infty\) does not get prettified; \( \infty\) does. Why? Is that
because prettify-symbols-mode surrounds the regex with the "symbol"
delimiters?
OK, so it turns out that I'm really impatient (or just
procrastinating). The suspect is `prettify-symbols-default-compose-p',
which is probably unsuitable for (La)TeX.

[a few minutes later]

So I've just found out about `tex--prettify-symbols-compose-p'. And
I cloned the AUCTeX git repo and learned that (contrary to 11.89)
prettifying symbols should Just Work, without any handiwork. I'll have
to convert to using the development version of AUCTeX...

Man, I *am* stupid and impatient. Please consider my questions
nonexistent.

Best,
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University
Marcin Borkowski
2016-03-02 09:54:04 UTC
Permalink
Post by Marcin Borkowski
Man, I *am* stupid and impatient. Please consider my questions
nonexistent.
Hi,

so it seems not that simple.

Here's what tex.el contains:

--8<---------------cut here---------------start------------->8---
(when (and (boundp 'tex--prettify-symbols-alist)
(boundp 'prettify-symbols-compose-predicate))
(defun TeX--prettify-symbols-compose-p (start end match)
(and (tex--prettify-symbols-compose-p start end match)
(not (let ((face (get-text-property end 'face)))
(if (consp face)
(memq 'font-latex-verbatim-face face)
(eq face 'font-latex-verbatim-face)))))))
--8<---------------cut here---------------end--------------->8---

However, `tex--prettify-symbols-alist' is defined in tex-mode.el, which
seems not to be loaded at the time tex.el is loaded. IOW, the defun
form is not evaluated.

What should I do? I can (require 'tex-mode) manually in my init.el (and
this is what I do now), but this I consider an ugly workaround. I'm
tempted to think this issue is a bug.

(AUCTeX version: auctex-11.89.1, from Elpa.)

Best,
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University
Tassilo Horn
2016-03-09 17:49:59 UTC
Permalink
Marcin Borkowski <***@mbork.pl> writes:

Hi Marcin,
Post by Marcin Borkowski
(when (and (boundp 'tex--prettify-symbols-alist)
(boundp 'prettify-symbols-compose-predicate))
(defun TeX--prettify-symbols-compose-p (start end match)
(and (tex--prettify-symbols-compose-p start end match)
(not (let ((face (get-text-property end 'face)))
(if (consp face)
(memq 'font-latex-verbatim-face face)
(eq face 'font-latex-verbatim-face)))))))
However, `tex--prettify-symbols-alist' is defined in tex-mode.el,
which seems not to be loaded at the time tex.el is loaded. IOW, the
defun form is not evaluated.
What should I do? I can (require 'tex-mode) manually in my init.el
(and this is what I do now), but this I consider an ugly workaround.
I'm tempted to think this issue is a bug.
I just tested with Emacs 25 as of today and the current AUCTeX ELPA
package. My ~/.emacs for testing was either empty or just contained
(package-initialize). In both cases, finding a TeX file and enabling
`prettify-symbols-mode' has the result of using the above function as
override for the default `tex--prettify-symbols-compose-p'.

Do you somehow load AUCTeX manually?

Bye,
Tassilo
g***@gmail.com
2016-03-12 15:23:58 UTC
Permalink
Dear All,

I have Emacs 24.5.1 (2015-04-11, Windows port) and AUCTeX
11.89.1 (2016-01-31), and prettify-mode does not work on a
tex buffer. Even if I start Emacs with an empty init file.

Now, there have been several posts in the past (started by
Uwe and Marcin) about prettify & AUCTeX. I've been
re-reading them but am still a bit confused. Init-file-wise
I tried some suggestions by Tassilo from those past posts,
but they don't work; nor does disabling & reenabling
prettify-mode and font-lock-fontify-buffer several times, as
was also suggested.

Did I understand correctly that the problem should disappear
with later AUCTeX versions? Or with later Emacs versions?

Thank you very much for any info!
J

PS: In case my motivation interests you: I happily use
AUCTeX's Preview, so have never worried about Prettify so
far. Recently some people tried to force me to use Lyx, and
I'm resisting as much as I can. One of their points is that
Lyx can show "pretty" mathematics on the fly, without the
need to partially run latex on the file, unlike Preview.
That's why I wanted to give a shot at Prettify.
Tassilo Horn
2016-03-13 19:12:34 UTC
Permalink
***@gmail.com writes:

Hi!
Did I understand correctly that the problem should disappear with
later AUCTeX versions? Or with later Emacs versions?
AUCTeX is ready but the prettify support in Emacs 24.x was only quite
rudimentary and not flexible enough for the needs of prettification of
(La)TeX. But it should work just fine with Emacs 25.1 which will be
released anytime soon now (in Emacs terms).

Bye,
Tassilo
g***@gmail.com
2016-03-13 21:32:40 UTC
Permalink
Hi Tassilo,

I don't know how to thank you. Your info prompted me to
un-hopefully search for some snapshot of Emacs 25
pre-compiled for Windows – and there is one!:

https://sourceforge.net/projects/emacs-bin/

I'm really happy with Emacs 25.0.91 and a working prettify.

Cheers!
J
Post by Tassilo Horn
AUCTeX is ready but the prettify support in Emacs 24.x was only quite
rudimentary and not flexible enough for the needs of prettification of
(La)TeX. But it should work just fine with Emacs 25.1 which will be
released anytime soon now (in Emacs terms).
Bye,
Tassilo
Tassilo Horn
2016-03-17 06:51:53 UTC
Permalink
***@gmail.com writes:

Hi J,
I don't know how to thank you. Your info prompted me to un-hopefully
search for some snapshot of Emacs 25 pre-compiled for Windows – and
https://sourceforge.net/projects/emacs-bin/
I'm really happy with Emacs 25.0.91 and a working prettify.
That's great to hear!

Bye,
Tassilo
g***@gmail.com
2016-03-17 10:34:20 UTC
Permalink
Post by Tassilo Horn
Post by g***@gmail.com
I'm really happy with Emacs 25.0.91 and a working prettify.
That's great to hear!
I spoke too soon, actually: I was seeing the effects of
"latex-pretty-symbols", not of prettify :) As you said, I'll
have to wait till 25.1. Looking forward to it!

J
Tassilo Horn
2016-03-18 21:01:43 UTC
Permalink
Post by g***@gmail.com
Post by Tassilo Horn
Post by g***@gmail.com
I'm really happy with Emacs 25.0.91 and a working prettify.
That's great to hear!
I spoke too soon, actually: I was seeing the effects of
"latex-pretty-symbols", not of prettify :)
Ah, I didn't even know that.
Post by g***@gmail.com
As you said, I'll have to wait till 25.1. Looking forward to it!
Your snapshot version 25.0.91 might be new enough but I can't tell for
sure.

Bye,
Tassilo

Loading...