help-gnu-emacs
[Top][All Lists]
Advanced

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

RE: intern and faces


From: Drew Adams
Subject: RE: intern and faces
Date: Wed, 2 Dec 2009 08:51:40 -0800

> I have built a small command to colorize a region
> 
> (defun put-color (start end color-name)
>    (interactive "r\nsColor ? ")
>      (let ((my-color (concat "color-" color-name)))
>        (unless (facep my-color)
>           (set-face-foreground
>              (make-face (intern my-color)) 
>              color-name))
>        (facemenu-set-face my-color start end)))
> 
> But I encounter a problem when trying to spool the result.
> 
> Starting with emacs -Q and executing the code above, I switch 
> to another buffer, type some text and colorize it with
> M-x put-color RET brown RET The result looks fine in the
> buffer, but when I try to execute
> M-x ps-spool-buffer-with-faces, I get the error 
> 
> Wrong type argument: listp, "color-brown"
> 
> The message was issued by ps-face-attribute-list and the 
> *Postscript* buffer
> is empty. I think that the problem comes from my command. If 
> I execute 
> (set-face-foreground (make-face 'color-brown) "brown")
> instead of my command, everything works.
> 
> Where does the error come from ?

I think the problem is (facemenu-set-face my-color start end). Use `intern' here
also, so that you pass the symbol, not the string.

Emacs used to always require (an internal face structure or) a symbol for its
face operations. Now, some operations let you use the name of that symbol (a
string) instead. Both `facep' and `facemenu-set-face' now respect a string, but
`ps-*' apparently does not. In general, I'd advise using a symbol.

You can see the difference by using `C-u C-x =' with the cursor on your colored
text. It will tell you that the face is "color-brown", not `color-brown'
(symbol). If you use instead (facemenu-set-face (intern my-color) start end), it
will show you the symbol. And I'm guessing that `ps-*' will act OK if it's a
symbol.

You might want to file a bug for `ps-print' for this, but I'm not sure it will
be considered a bug. I just filed doc-string bugs for `facep' and
`facemenu-set-face' - they should explicitly say that the FACE arg can be a
string or symbol.





reply via email to

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