emacs-diffs
[Top][All Lists]
Advanced

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

master 1e1be54156: Test face name variables are bound before using them


From: Alan Mackenzie
Subject: master 1e1be54156: Test face name variables are bound before using them in cc-fonts.el
Date: Tue, 25 Oct 2022 09:31:05 -0400 (EDT)

branch: master
commit 1e1be54156108a25ba78ca4268af3113945d574e
Author: Alan Mackenzie <acm@muc.de>
Commit: Alan Mackenzie <acm@muc.de>

    Test face name variables are bound before using them in cc-fonts.el
    
    This fixes bug #58641.
    
    Also, set c-reference-face-name to font-lock-constant face in preference to
    c-label-face-name.
    
    * lisp/progmodes/cc-fonts.el (c-preprocessor-face-name, c-label-face-name)
    (c-constant-face-name, c-reference-face-name): Test variables with the same
    name as font-lock faces are bound before accessing their values.
    (c-reference-face-name): Use font-lock-constant face in preference to
    c-label-face-name.
---
 lisp/progmodes/cc-fonts.el | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el
index aa16da7070..5bb3e2e0b4 100644
--- a/lisp/progmodes/cc-fonts.el
+++ b/lisp/progmodes/cc-fonts.el
@@ -1,4 +1,4 @@
-;;; cc-fonts.el --- font lock support for CC Mode -*- lexical-binding: t -*-
+;; cc-fonts.el --- font lock support for CC Mode -*- lexical-binding: t -*-
 
 ;; Copyright (C) 2002-2022 Free Software Foundation, Inc.
 
@@ -115,6 +115,7 @@
         ;; used for preprocessor directives.
         'font-lock-builtin-face)
        ((and (c-face-name-p 'font-lock-reference-face)
+             (boundp 'font-lock-reference-face)
              (eq font-lock-reference-face 'font-lock-reference-face))
         'font-lock-reference-face)
        (t 'font-lock-constant-face)))
@@ -128,6 +129,7 @@
         ;; suite.)
         'font-lock-label-face)
        ((and (c-face-name-p 'font-lock-constant-face)
+             (boundp 'font-lock-constant-face)
              (eq font-lock-constant-face 'font-lock-constant-face))
         ;; Test both if font-lock-constant-face exists and that it's
         ;; not an alias for something else.  This is important since
@@ -138,20 +140,24 @@
 
 (defconst c-constant-face-name
   (if (and (c-face-name-p 'font-lock-constant-face)
+          (boundp 'font-lock-constant-face)
           (eq font-lock-constant-face 'font-lock-constant-face))
       ;; This doesn't exist in some earlier versions of XEmacs 21.
       'font-lock-constant-face
     c-label-face-name))
 
 (defconst c-reference-face-name
-  (with-no-warnings
-   (if (and (c-face-name-p 'font-lock-reference-face)
-           (eq font-lock-reference-face 'font-lock-reference-face))
-       ;; This is considered obsolete in Emacs, but it still maps well
-       ;; to this use.  (Another reason to do this is to get unique
-       ;; faces for the test suite.)
-       'font-lock-reference-face
-     c-label-face-name)))
+  (cond
+   ((and (c-face-name-p 'font-lock-reference-face)
+          (boundp 'font-lock-reference-face)
+          (eq font-lock-reference-face 'font-lock-reference-face))
+    ;; This is considered obsolete in Emacs, but it still maps well
+    ;; to this use.  (Another reason to do this is to get unique
+    ;; faces for the test suite.)
+    'font-lock-reference-face)
+   ((c-face-name-p 'font-lock-constant-face)
+    'font-lock-constant-face)
+   (t c-label-face-name)))
 
 ;; This should not mapped to a face that also is used to fontify things
 ;; that aren't comments or string literals.
@@ -586,7 +592,8 @@ stuff.  Used on level 1 and higher."
                        (c-lang-const c-opt-cpp-macro-define)
                        (c-lang-const c-nonempty-syntactic-ws)
                        "\\(" (c-lang-const ; 1 + ncle + nsws
-                              c-symbol-key) "\\)"
+                              c-symbol-key)
+                       "\\)"
                        (concat "\\("   ; 2 + ncle + nsws + c-sym-key
                                ;; Macro with arguments - a "function".
                                "\\((\\)" ; 3 + ncle + nsws + c-sym-key



reply via email to

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