unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: Mat Smiglarski <penthief@SDF.ORG>
Cc: 17956@debbugs.gnu.org
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	[thread overview]
Message-ID: <87r41y59v6.fsf@mail.jurta.org> (raw)
In-Reply-To: <fbe80f2fcb4030e5cbe2e0014e9f7046@SDF.ORG> (Mat Smiglarski's message of "Sun, 06 Jul 2014 15:17:22 +0100")

> 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	other threads:[~2014-07-06 23:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-06 14:17 bug#17956: 24.3.92; Calling highlight-regexp non-interactively causes errors from face-name Mat Smiglarski
2014-07-06 23:38 ` Juri Linkov [this message]
2014-07-08  9:03   ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r41y59v6.fsf@mail.jurta.org \
    --to=juri@jurta.org \
    --cc=17956@debbugs.gnu.org \
    --cc=penthief@SDF.ORG \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).