GNU bug report logs - #17956
24.3.92; Calling highlight-regexp non-interactively causes errors from face-name

Previous Next

Package: emacs;

Reported by: Mat Smiglarski <penthief <at> SDF.ORG>

Date: Sun, 6 Jul 2014 14:57:02 UTC

Severity: normal

Fixed in version 24.3.92

Done: Juri Linkov <juri <at> jurta.org>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 17956 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Mat Smiglarski <penthief <at> SDF.ORG>
Cc: 17956 <at> debbugs.gnu.org
Subject: Re: bug#17956: 24.3.92;
 Calling highlight-regexp non-interactively causes errors from
 face-name
Date: Mon, 07 Jul 2014 02:38:18 +0300
> 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






This bug report was last modified 10 years and 326 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.