(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

>From ik...@ikumi.que.jp Mon Feb 13 01:01:06 2017
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: [PATCH] Unify treatment of face argument over the relevant functions
X-Mercurial-Node: 5de8c9d6dac4dd19c7270b1edb256819e42dffe0
X-Mercurial-Series-Index: 1
X-Mercurial-Series-Total: 1
Message-Id: <5de8c9d6dac4dd19c727.1486915...@localhost.my.domain>
X-Mercurial-Series-Id: <5de8c9d6dac4dd19c727.1486915...@localhost.my.domain>
User-Agent: Mercurial-patchbomb/4.0.1
Date: Mon, 13 Feb 2017 01:01:06 +0900
From: Ikumi Keita <ik...@ikumi.que.jp>
To: dummy

* font-latex.el (font-latex-keyword-matcher): Conform the face
argument correctly to the format `font-lock-keywords' requires.
(font-latex-make-user-keywords) : Call `font-latex-make-match-defun'
directly without `eval'.
(font-latex-deactivated-keyword-classes) : Accept a face symbol, as
well as a form returning a face symbol, for the third element for each
item of `font-latex-built-in-keyword-classes'.
(font-latex-built-in-keyword-classes) : Remove quoting from the face
names.  Contrary to the sentence of the doc string
"The third element is the symbol of a face to be used or a Lisp
form returning a face symbol.", symbol of a face was invalid due to
the above bugs.

diff --git a/font-latex.el b/font-latex.el
--- a/font-latex.el
+++ b/font-latex.el
@@ -286,7 +286,7 @@
      ("nopagebreak" "pagebreak" "newpage" "clearpage" "cleardoublepage"
       "enlargethispage" "nolinebreak" "linebreak" "newline" "-" "\\" "\\*"
       "appendix" "displaybreak" "allowdisplaybreaks" "include")
-     'font-latex-warning-face 1 noarg)
+     font-latex-warning-face 1 noarg)
     ("variable"
      (("setlength" "|{\\{") ("settowidth" "|{\\{") ("settoheight" "{{")
       ("settodepth" "{{") ("setcounter" "{|{\\")
@@ -294,10 +294,10 @@
       ("stepcounter" "{") ("refstepcounter" "{")
       ("arabic" "{") ("roman" "{") ("Roman" "{") ("alph" "{") ("Alph" "{")
       ("fnsymbol" "{"))
-     'font-lock-variable-name-face 2 command)
+     font-lock-variable-name-face 2 command)
     ("biblatexnoarg"
      ("newrefsegment" "mancite" "pno" "ppno" "nopp" "psq" "psqq")
-     'font-lock-variable-name-face 2 noarg)
+     font-lock-variable-name-face 2 noarg)
     ("biblatex"
      (("newrefsection" "[") ("ExecuteBibliographyOptions" "[{")
       ("printbibliography" "[") ("printshorthands" "[") ("printbibheading" "[")
@@ -322,13 +322,13 @@
       ("cites" "(([[{") ("Cites" "(([[{") ("parencites" "(([[{") ("Parencites" "(([[{")
       ("footcites" "(([[{") ("footcitetexts" "(([[{") ("smartcites" "(([[{")
       ("Smartcites" "(([[{") ("textcites" "(([[{") ("Textcites" "(([[{") ("supercites" "(([[{"))
-     'font-lock-constant-face 2 command)
+     font-lock-constant-face 2 command)
     ("reference"
      (("nocite" "*{") ("cite" "*[[{") ("label" "{") ("pageref" "{")
       ("vref" "*{") ("eqref" "{") ("ref" "{") ("include" "{")
       ("input" "{") ("bibliography" "{") ("index" "{") ("glossary" "{")
       ("footnote" "[{") ("footnotemark" "[") ("footnotetext" "[{"))
-     'font-lock-constant-face 2 command)
+     font-lock-constant-face 2 command)
     ("function"
      (("begin" "{") ("end" "{") ("pagenumbering" "{")
       ("thispagestyle" "{") ("pagestyle" "{") ("nofiles" "")
@@ -345,7 +345,7 @@
       ;; separate category with 'noarg instead of 'command handling?
       ("enspace" "") ("enskip" "") ("quad" "") ("qquad" "") ("nonumber" "")
       ("centering" "") ("TeX" "") ("LaTeX" ""))
-     'font-lock-function-name-face 2 command)
+     font-lock-function-name-face 2 command)
     ("sectioning-0"
      (("part" "*[{"))
      (if (eq font-latex-fontify-sectioning 'color)
@@ -383,36 +383,36 @@
 	 'font-lock-type-face
        'font-latex-sectioning-5-face)
      2 command)
-    ("slide-title" () 'font-latex-slide-title-face 2 command)
+    ("slide-title" () font-latex-slide-title-face 2 command)
     ("textual"
      (("item" "[") ("title" "{") ("author" "{") ("date" "{")
       ("thanks" "{") ("address" "{") ("caption" "[{")
       ("textsuperscript" "{") ("textsubscript" "{"))
-     'font-lock-type-face 2 command)
+     font-lock-type-face 2 command)
     ("bold-command"
      (("textbf" "{") ("textsc" "{") ("textup" "{") ("boldsymbol" "{")
       ("pmb" "{"))
-     'font-latex-bold-face 1 command)
+     font-latex-bold-face 1 command)
     ("italic-command"
      (("emph" "{") ("textit" "{") ("textsl" "{"))
-     'font-latex-italic-face 1 command)
+     font-latex-italic-face 1 command)
     ("math-command"
      (("ensuremath" "|{\\"))
-     'font-latex-math-face 1 command)
+     font-latex-math-face 1 command)
     ("type-command"
      (("texttt" "{") ("textsf" "{") ("textrm" "{") ("textmd" "{"))
-     'font-lock-type-face 1 command)
+     font-lock-type-face 1 command)
     ("bold-declaration"
      ("bf" "bfseries" "sc" "scshape" "upshape")
-     'font-latex-bold-face 1 declaration)
+     font-latex-bold-face 1 declaration)
     ("italic-declaration"
      ("em" "it" "itshape" "sl" "slshape")
-     'font-latex-italic-face 1 declaration)
+     font-latex-italic-face 1 declaration)
     ("type-declaration"
      ("tt" "ttfamily" "sf" "sffamily" "rm" "rmfamily" "mdseries"
       "tiny" "scriptsize" "footnotesize" "small" "normalsize"
       "large" "Large" "LARGE" "huge" "Huge")
-     'font-lock-type-face 1 declaration))
+     font-lock-type-face 1 declaration))
   "Built-in keywords and specifications for font locking.
 
 The first element of each item is the name of the keyword class.
@@ -457,7 +457,10 @@
 				    (mapconcat 'identity name " "))
 				  " keywords in `"
 				  ;; Name of the face
-				  (symbol-name (eval (nth 2 spec))) "'.\n"
+				  (symbol-name
+				   (let ((face (nth 2 spec)))
+				     (if (symbolp face) face (eval face))))
+				  "'.\n"
 				  ;; List of keywords
 				  (with-temp-buffer
 				    (insert "  Keywords: "
@@ -535,6 +538,11 @@
 This is a helper function for `font-latex-make-built-in-keywords'
 and `font-latex-make-user-keywords' and not intended for general
 use."
+  ;; Quote a list of face properties and a face symbol
+  ;; but do not quote a form returning such value.
+  (unless (and (listp face) (fboundp (car face)))
+    (setq face `',face))
+
   ;; In an earlier version of font-latex the type could be a list like
   ;; (command 1).  This indicated a macro with one argument.  Provide
   ;; a matcher in this case but don't actually support it.
@@ -550,10 +558,7 @@
 	   (7 (font-latex-matched-face 7) append t)))
 	((eq type 'noarg)
 	 `(,(intern (concat prefix name))
-	   ;; Quote a list of face properties but do not to quote a face symbol.
-	   (0 ,(if (and (listp face) (not (fboundp (car face))))
-		   `',face
-		 face))))
+	   (0 ,face)))
 	((eq type 'declaration)
 	 `(,(intern (concat prefix name))
 	   (0 'font-latex-warning-face t t)
@@ -789,7 +794,7 @@
 Generated by `font-latex-make-user-keywords'.")))
 
 	;; defun font-latex-match-*
-	(eval `(font-latex-make-match-defun prefix name '',face type))
+	(font-latex-make-match-defun prefix name face type)
 
 	;; Add the matcher to `font-latex-keywords-2'.
 	(add-to-list 'font-latex-keywords-2


_______________________________________________
auctex-devel mailing list
auctex-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex-devel

Reply via email to