* Elisp: How to set multiple text properties.
@ 2011-01-14 19:19 Neil Baylis
2011-01-14 22:49 ` Stefan Monnier
0 siblings, 1 reply; 5+ messages in thread
From: Neil Baylis @ 2011-01-14 19:19 UTC (permalink / raw)
To: help-gnu-emacs
I want to make a pair of elisp functions that can be called
interactively, and possibly bound to function keys.
Call them foo and bar.
When foo is called, it should cause subsequent text entered into the
buffer to be colored dark blue and bold.
When bar is called, it should cause subsequent text entered into the
buffer to be colored green, and italic.
I've only been able to find out how to set a single property of the
region. E.g., if I set it to be italic, then it stops being green. I'm
using (facemenu-set-italic) to set italic mode. I'm using (facemenu-
set-face-from-menu) to set the color.
I think I'm missing something obvious. What's the correct way to set
multiple properties on text from within an elisp function?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Elisp: How to set multiple text properties.
2011-01-14 19:19 Elisp: How to set multiple text properties Neil Baylis
@ 2011-01-14 22:49 ` Stefan Monnier
2011-01-15 16:19 ` Neil Baylis
0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2011-01-14 22:49 UTC (permalink / raw)
To: help-gnu-emacs
> I think I'm missing something obvious. What's the correct way to set
> multiple properties on text from within an elisp function?
The `face' text-property can be a list of faces rather than
a single face.
Stefan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Elisp: How to set multiple text properties.
2011-01-14 22:49 ` Stefan Monnier
@ 2011-01-15 16:19 ` Neil Baylis
2011-01-15 18:53 ` Neil Baylis
0 siblings, 1 reply; 5+ messages in thread
From: Neil Baylis @ 2011-01-15 16:19 UTC (permalink / raw)
To: help-gnu-emacs
On Jan 14, 2:49 pm, Stefan Monnier <monn...@iro.umontreal.ca> wrote:
> > I think I'm missing something obvious. What's the correct way to set
> > multiple properties on text from within an elisp function?
>
> The `face' text-property can be a list of faces rather than
> a single face.
>
> Stefan
OK, cool. That lets me specify bold and italic at the same time. Is
there a way to use the 'face property to specify colors?
Neil
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Elisp: How to set multiple text properties.
2011-01-15 16:19 ` Neil Baylis
@ 2011-01-15 18:53 ` Neil Baylis
2011-01-15 19:45 ` Mirko
0 siblings, 1 reply; 5+ messages in thread
From: Neil Baylis @ 2011-01-15 18:53 UTC (permalink / raw)
To: help-gnu-emacs
Thanks, Stefan. I seem to have it figured out now.
For those interested, here are some calls that work (Emacs 23.2.1):
(These calls set properties on the entire line containing point.)
Set the text to italic only:
(put-text-property (line-beginning-position) (line-end-position)
'face 'italic)
Set the text to blue only:
(put-text-property (line-beginning-position) (line-end-position)
'face '(:foreground "blue"))
Set the text to blue and bold:
(put-text-property (line-beginning-position) (line-end-position)
'face '((:foreground "blue") bold))
Set the text to blue and italic:
(put-text-property (line-beginning-position) (line-end-position)
'face '((:foreground "blue") italic))
Set the text to bold, italic, and red:
(put-text-property (line-beginning-position) (line-end-position)
'face '(bold italic (:foreground "red")))
Neil
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Elisp: How to set multiple text properties.
2011-01-15 18:53 ` Neil Baylis
@ 2011-01-15 19:45 ` Mirko
0 siblings, 0 replies; 5+ messages in thread
From: Mirko @ 2011-01-15 19:45 UTC (permalink / raw)
To: help-gnu-emacs
On Saturday, January 15, 2011 1:53:52 PM UTC-5, Neil Baylis wrote:
> Thanks, Stefan. I seem to have it figured out now.
>
> For those interested, here are some calls that work (Emacs 23.2.1):
>
> (These calls set properties on the entire line containing point.)
>
> Set the text to italic only:
> (put-text-property (line-beginning-position) (line-end-position)
> 'face 'italic)
>
> Set the text to blue only:
> (put-text-property (line-beginning-position) (line-end-position)
> 'face '(:foreground "blue"))
>
> Set the text to blue and bold:
> (put-text-property (line-beginning-position) (line-end-position)
> 'face '((:foreground "blue") bold))
>
> Set the text to blue and italic:
> (put-text-property (line-beginning-position) (line-end-position)
> 'face '((:foreground "blue") italic))
>
> Set the text to bold, italic, and red:
> (put-text-property (line-beginning-position) (line-end-position)
> 'face '(bold italic (:foreground "red")))
>
> Neil
Thank you for the examples
Mirko
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-01-15 19:45 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-14 19:19 Elisp: How to set multiple text properties Neil Baylis
2011-01-14 22:49 ` Stefan Monnier
2011-01-15 16:19 ` Neil Baylis
2011-01-15 18:53 ` Neil Baylis
2011-01-15 19:45 ` Mirko
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.