[Top][All Lists]

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

bug#17956: 24.3.92; Calling highlight-regexp non-interactively causes er

From: Juri Linkov
Subject: bug#17956: 24.3.92; Calling highlight-regexp non-interactively causes errors from face-name
Date: Mon, 07 Jul 2014 02:38:18 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu)

> M-: (highlight-regexp "1" "hi-green")
> [...]
> The following error is encountered:
> face-name: Wrong type argument: symbolp, "hi-green"

The reason why `highlight-regexp' fails is because
`face-name' rejects non-symbol faces whereas `facep'
accepts them.  This contradiction might cause similar
bugs in other places that naively expect a face always
to be a symbol.  For instance, grepping for `face-name'
shows such code as in `x-resolve-font-name'

  (or (symbolp face)
      (setq face (face-name face)))

that didn't fail only because was never called with
a non-nil non-symbol `face'.

So it would be safer not to assume that a face can be only a symbol:

=== modified file 'lisp/faces.el'
--- lisp/faces.el       2014-04-30 18:01:36 +0000
+++ lisp/faces.el       2014-07-06 23:38:01 +0000
@@ -359,7 +359,10 @@ (defun make-face-x-resource-internal (fa
 (defun face-name (face)
   "Return the name of face FACE."
-  (symbol-name (check-face face)))
+  (check-face face)
+  (if (symbolp face)
+      (symbol-name face)
+    face))
 (defun face-all-attributes (face &optional frame)
@@ -2731,8 +2734,8 @@ (defun x-resolve-font-name (pattern &opt
 contains wildcards.
 Given optional arguments FACE and FRAME, return a font which is
 also the same size as FACE on FRAME, or fail."
-  (or (symbolp face)
-      (setq face (face-name face)))
+  (when face
+    (setq face (face-name face)))
   (and (eq frame t)
        (setq frame nil))
   (if pattern

reply via email to

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