auctex-devel
[Top][All Lists]
Advanced

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

[AUCTeX-devel] font-latex.el [2/4]: Treat face argument consistently


From: Ikumi Keita
Subject: [AUCTeX-devel] font-latex.el [2/4]: Treat face argument consistently
Date: Thu, 16 Feb 2017 22:22:46 +0900

(Continued from the previous message)
If we customize `font-latex-user-keyword-classes' to add entries of
"Declaration inside TeX group" or "Command without arguments" type,
those entries are ignored.

[Observation]
1. Customize `font-latex-user-keyword-classes' according to the
following specification and save it.
----------------------------------------------------------------------
Hide Font Latex User Keyword Classes:
INS DEL List:
            Name: foo
            Choice: Value Menu Keywords:
            INS DEL Keyword: bar
            INS
            Choice: Value Menu Face name: (sample) underline
            Type: Value Menu Command without arguments
INS DEL List:
            Name: foo2
            Choice: Value Menu Keywords:
            INS DEL Keyword: baz
            INS
            Choice: Value Menu Face name: (sample) warning
            Type: Value Menu Declaration inside TeX group
----------------------------------------------------------------------
2. Open the following file with AUCTeX.
---- sample.tex ------------------------------------------------------
\documentclass{article}

\begin{document}
\bar
{\baz 123}
\end{document}
----------------------------------------------------------------------
The macro \bar and the text after \baz should be fontified according to
the customization.  However, they aren't.  Even if we restart emacs and
open sample.tex again, situation doesn't change.

[Analysis]
The reason is that the function `font-latex-keyword-matcher' does not
treat the argument `face' correctly.  Although it must quote the
argument unless it is a form returning a face symbol, it fails to do so
actually.

This is related to another minor problem that the doc string of
`font-latex-built-in-keyword-classes' has discrepancy against the
implementation.  The doc string states that the third element of each
item can be a symbol of face or a lisp form returning face symbol.  But
actually, if a face symbol is specified as the third element, that
doesn't take effect.  In addition, an error is raised during the load of
font-latex.elc in that case.

The reason of the former issue (face symbol is ineffective as the 3rd
element) is the defect in `font-latex-keyword-matcher' mentioned above.
The reason of the latter issue is in the defcustom of
`font-latex-deactivated-keyword-classes'.  The value of the :type
keyword of that variable presumes the 3rd element to be a lisp form.
Here is the relevant code:
----------------------------------------------------------------------
                                  ;; Name of the face
                                  (symbol-name (eval (nth 2 spec))) "'.\n"
----------------------------------------------------------------------
Here `(nth 2 spec)' returns "the 3rd element" we are talking of, so
if it is a face symbol, the `eval' raises error in most cases.

The attached patch fixes these problems.  The quotes on the face symbols
in `font-latex-built-in-keyword-classes' are also removed, taking
advantage of this bug fix.  This patch also simplifies the call to
`font-latex-make-match-defun' in `font-latex-make-user-keywords'.  (It
removes spurious `eval' and quoting.)

With this patch, sample.tex in the above example is fontified as
expected.

[Still another problem]
During the test of this patch, I noticed another problem in
`font-latex-user-keyword-classes'.  The story still continues to the
next message.

Regards,
Ikumi Keita

Attachment: unify_treatment_of_face_argument
Description: unify treatment of face argument


reply via email to

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