[Top][All Lists]

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

bug#39624: 26.3; Inserting text in a specified face

From: Stephen Berman
Subject: bug#39624: 26.3; Inserting text in a specified face
Date: Sun, 16 Feb 2020 00:24:49 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

On Sat, 15 Feb 2020 13:20:01 -0800 Greg Hill <address@hidden> wrote:

> I'm just trying to figure out how to use the 'insert' function to insert
> one string in the currently active buffer in a specific face like
> 'custom-comment'). I'm sure it's easy to do, but I have spent
> several hours searching through all the Info documentation and haven't
> found a single clue.

Here's one way:

(insert (propertize "Test" 'face 'custom-comment))

And here's how you might have found that in the documentation: If you
look in the Elisp manual at the node Faces, it says: "One way to
represent a face is as a property list of attributes", and if you look
at the node Insertion, it says that most of the insertion functions
"copy text characters from strings and buffers along with their
properties".  So properties are a point of intersection between faces
and insertion.  In the Elisp node Text Properties there is a menu that
contains the entry Changing Properties with the description "Setting the
properties of a range of text", which seems to be what you're looking
for.  And indeed, the node Changing Properties describes the function
propertize, saying it is "the easiest way to make a string with text

Steve Berman

reply via email to

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