auctex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [AUCTeX] font-locking problem


From: Greg Bognar
Subject: Re: [AUCTeX] font-locking problem
Date: Sat, 09 Feb 2019 23:47:48 +0100

Hi Tassilo,

OK, I think I now understand what's going on.

`TeX-style-path' has the same value in both cases.  But *Messages* is
different.  In the bad version:

Automatic display of crossref information was turned on
Automatic recentering of TOC window was turned on
Starting new Ispell process aspell with en_US dictionary...
Applying style hooks...
Loading /home/greg/.emacs.d/elpa/auctex-12.1.1/style/article.elc...done
Loading /home/greg/.emacs.d/elpa/auctex-12.1.1/style/titlesec.elc...done
Loading /home/greg/.emacs.d/elpa/auctex-12.1.1/style/fontenc.elc...done
Loading /home/greg/.emacs.d/elpa/auctex-12.1.1/style/inputenc.elc...done
Loading /home/greg/.emacs.d/elpa/auctex-12.1.1/style/babel.elc...done
Loading /home/greg/.emacs.d/elpa/auctex-12.1.1/style/multicol.elc...done
Loading /home/greg/.emacs.d/elpa/auctex-12.1.1/style/mdframed.elc...done
Loading /home/greg/.emacs.d/elpa/auctex-12.1.1/style/geometry.elc...done
Loading /home/greg/.emacs.d/elpa/auctex-12.1.1/style/fancyhdr.elc...done
Loading /home/greg/.emacs.d/elpa/auctex-12.1.1/style/paralist.elc...done
Applying style hooks...done

And in the good version:

Automatic display of crossref information was turned on
Automatic recentering of TOC window was turned on
Starting new Ispell process aspell with en_US dictionary...
Applying style hooks...
Loading /home/greg/.emacs.d/elpa/auctex-12.1.1/style/beamer.elc...done
Loading /home/greg/.emacs.d/elpa/auctex-12.1.1/style/amsmath.elc...done
Loading /home/greg/.emacs.d/elpa/auctex-12.1.1/style/amstext.elc...done
Loading /home/greg/.emacs.d/elpa/auctex-12.1.1/style/amsbsy.elc...done
Loading /home/greg/.emacs.d/elpa/auctex-12.1.1/style/amsopn.elc...done
Loading /home/greg/.emacs.d/elpa/auctex-12.1.1/style/amssymb.elc...done
Loading /home/greg/.emacs.d/elpa/auctex-12.1.1/style/amsfonts.elc...done
Loading /home/greg/.emacs.d/elpa/auctex-12.1.1/style/amsthm.elc...done
Loading /home/greg/.emacs.d/elpa/auctex-12.1.1/style/color.elc...done
Loading /home/greg/.emacs.d/elpa/auctex-12.1.1/style/geometry.elc...done
Loading /home/greg/.emacs.d/elpa/auctex-12.1.1/style/hyperref.elc...done
Loading /home/greg/.emacs.d/elpa/auctex-12.1.1/style/url.elc...done
Loading /home/greg/.emacs.d/elpa/auctex-12.1.1/style/nameref.elc...done
Loading /home/greg/.emacs.d/elpa/auctex-12.1.1/style/inputenc.elc...done
Loading /home/greg/.emacs.d/elpa/auctex-12.1.1/style/xcolor.elc...done
Loading /home/greg/.emacs.d/elpa/auctex-12.1.1/style/fontenc.elc...done
Loading /home/greg/.emacs.d/elpa/auctex-12.1.1/style/babel.elc...done
Loading /home/greg/.emacs.d/elpa/auctex-12.1.1/style/multicol.elc...done
Loading /home/greg/.emacs.d/elpa/auctex-12.1.1/style/mdframed.elc...done
Loading /home/greg/.emacs.d/elpa/auctex-12.1.1/style/fancyhdr.elc...done
Loading /home/greg/.emacs.d/elpa/auctex-12.1.1/style/paralist.elc...done
Sorting xcolor-definecolor...done
Removing duplicates...done
Applying style hooks...done

So yes, beamer.el is loaded in the good version, but not in the bad version.  I
think the reason is because my preamble begins with:

%======8<======8<======8<======8<======8<======8<======8<======8<======%
%% SLIDES
% \documentclass[ignorenonframetext,t]{beamer} %

%% HANDOUT
% \documentclass[ignorenonframetext,t,handout]{beamer} %
% \usepackage{pgfpages} %
% \pgfpagesuselayout{4 on 1}[a4paper,landscape,border shrink=5mm] %

%% NOTES
% \documentclass[a4paper,twocolumn]{article} %
% \usepackage[tiny,noindentafter,compact]{titlesec} % must be loaded before
%                                                   % beamerarticle
% \usepackage{beamerarticle} %
%======8<======8<======8<======8<======8<======8<======8<======8<======%

I use this template to generate material for lectures.  When I want to generate
the slides, I uncomment the \documentclass...{beamer} block; when I want to make
handouts for students, I uncomment the \documentclass...handout]{beamer} block;
and for notes for myself, the \documentclass...{article} block.

The lines for the bad version from *Messages* above are from a file with the
\documentclass...{article} block uncommented; the lines for the good version are
from the same file, but with the \documentclass...{beamer} block uncommented.

So I think what happens is that AUCTeX loads style files depending on which
block it finds uncommented when the file is visited.  The fontification seemed
random to me because it depends on which block I happened to leave uncommented
last time I closed the file.

So the solution might be something like:

- Is there a way to tell AUCTeX to load style files for stuff it finds commented
out?  E.g., when I leave the \documentclass...{article} block uncommented, it
could still load beamer.el?  After all, if you have a commented out
\documentclass or \usepackage in your preamble, you might want to uncomment it
later and its style file could be loaded when the file is visited.

- If that would create problems, is there a command to tell AUCTeX explicitly to
re-scan the file and load the style files for document classes or packages it
finds?  So when I open a file with \documentclass...{article} uncommented, and
subsequently uncomment \documentclass...{beamer}, then I can tell AUCTeX to load
beamer.el?

- Or is there a reason \usepackage{beamerarticle} doesn't cause beamer.el to be
loaded?  It seems it should.

Finally, my preamble also has stuff like

\mode<presentation>{ %
  \usepackage{arevmath} %
  ...

and

\mode<article>{%
  \usepackage{fancyhdr} %
  ...

AUCTeX will load all the style files for the packages, regardless of the mode
they are used in, right?  That seems to be the case.

Any advice on how to fix this?

Thanks for the pointer,
All the best,
Greg

> Date: Sat, 09 Feb 2019 10:32:45 +0100
> From: Tassilo Horn <address@hidden>
> To: address@hidden
> Subject: Re: [AUCTeX] font-locking problem
> Message-ID: <address@hidden>
> Content-Type: text/plain
> 
> Greg Bognar <address@hidden> writes:
> 
> Hi Greg,
> 
> > I have an odd font-locking problem in AUCTeX.  When I work on Beamer
> > slides, sometimes the font-locking works as in the "good" version of
> > the screenshot attached.
> 
> Thanks for the good description!  In the "bad" version, the beamer.el
> style hasn't been loaded, or at least not the following snippet in it:
> 
>    ;; Fontification
>    (when (and (featurep 'font-latex)
>             (eq TeX-install-font-lock 'font-latex-setup))
>      (font-latex-add-keywords '(("title" "[{")
>                               ("subtitle" "[{")
>                               ("author" "[{")
>                               ("date" "[{")
>                               ("frametitle" "<[{")) 'slide-title)
> 
> That would have told font-latex how to highlight \frametitle.
> 
> The question is just, why it sometimes fails to load.  In the bad case,
> maybe there's something in *Messages*?  What's the value of
> `TeX-style-path' in the good and the bad case?
> 
> Bye,
> Tassilo
>
> > Date: Sat, 09 Feb 2019 01:22:09 +0100
> > From: Greg Bognar <address@hidden>
> > To: address@hidden
> > Subject: [AUCTeX] font-locking problem
> > Message-ID: <address@hidden>
> > Content-Type: text/plain; charset="us-ascii"
> > 
> > Hi,
> > 
> > I have an odd font-locking problem in AUCTeX.  When I work on Beamer slides,
> > sometimes the font-locking works as in the "good" version of the screenshot
> > attached.  The faces are:
> > 
> > Good version:
> > \begin (font-lock-keyword-face font-latex-sedate-face)
> > frame (font-lock-function-name-face)
> > \frametitle (font-lock-keyword-face font-latex-sedate-face)
> > < (font-latex-sedate-face)
> > presentation (font-lock-variable-name-face font-latex-sedate-face)
> > My Slide (font-latex-slide-title-face)
> > 
> > Other times, font-locking works as in the "bad" version of the screenshot
> > attached.  The faces are:
> > 
> > Bad version:
> > \begin (font-lock-keyword-face font-latex-sedate-face)
> > frame (font-lock-function-name-face)
> > \frametitle (font-latex-sedate-face)
> > < (font-latex-sedate-face)
> > presentation (font-latex-sedate-face)
> > My Slide No face
> > 
> > This seems completely random.  This is the same file, same Emacs session, 
> > same
> > customizations; sometimes the "good" version is turned on, sometimes the 
> > "bad"
> > version.  I can't tell what makes the difference (e.g., restarting Emacs 
> > seems
> > to make no difference).
> > 
> > How can I track down what the problem might be?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]