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

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

Re: intern and faces


From: harven
Subject: Re: intern and faces
Date: Wed, 02 Dec 2009 21:22:00 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (darwin)

"Drew Adams" <address@hidden> writes:

>> 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"
>
> 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.

Yes, you guessed right, that works if I replace my-color by (intern my-color)
in the function facemenu-set-face. I will report it.
Thanks a lot.


reply via email to

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