emacs-devel
[Top][All Lists]
Advanced

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

Re: How to walk a Lisp_String?


From: Eli Zaretskii
Subject: Re: How to walk a Lisp_String?
Date: Fri, 02 Sep 2022 10:30:43 +0300

> From: Manuel Giraud <manuel@ledu-giraud.fr>
> Cc: emacs-devel@gnu.org
> Date: Fri, 02 Sep 2022 09:18:59 +0200
> 
> >> I'm working into lwlib only.  So I've made a function to get the frame
> >> of the menu widget (mw).  I'm also converting the char* display_string
> >> of each menu entry to a Lisp_String with make_string (note: I don't know
> >> if I should have done that but it seems the way to get a proper
> >> multi-byte string from a char*).
> >
> > make_multibyte_string is better, I think.
> 
> make_string seems to be a higher level interface: it calls
> make_unibyte_string or make_multibyte_string whether the string is uni-
> or multi-byte.

Why would you need to create a unibyte string?  More importantly, why
would you trust make_string to make the decision that is right for
your purposes?

> > And I don't think I understand how you get the Lisp string to have the
> > face information.  The original C char* string cannot have that
> > information as part of the string's data, so where will the face data
> > for the Lisp string come from?
> 
> I don't understand your question.  I thought it was the job of
> FACE_FOR_CHAR: you give it a char and a frame and it returns the face
> for this char in this frame.  What am I missing?

Before you could ask Emacs what is the face of a particular character
of a Lisp string, some code should place the face information on that
string.  In Lisp, you do that by calling 'propertize' or similar
APIs.  If you don't place the face information on a Lisp string, how
can you expect the string to have it?



reply via email to

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