From: harven <harven@free.fr>
To: help-gnu-emacs@gnu.org
Subject: Re: intern and faces
Date: Wed, 02 Dec 2009 21:22:00 +0100 [thread overview]
Message-ID: <m2fx7t6s9j.fsf@free.fr> (raw)
In-Reply-To: mailman.12034.1259772781.2239.help-gnu-emacs@gnu.org
"Drew Adams" <drew.adams@oracle.com> 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.
prev parent reply other threads:[~2009-12-02 20:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-02 11:48 intern and faces harven
2009-12-02 16:51 ` Drew Adams
[not found] ` <mailman.12034.1259772781.2239.help-gnu-emacs@gnu.org>
2009-12-02 20:22 ` harven [this message]
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=m2fx7t6s9j.fsf@free.fr \
--to=harven@free.fr \
--cc=help-gnu-emacs@gnu.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.
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).