From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: How to walk a Lisp_String? Date: Fri, 02 Sep 2022 10:30:43 +0300 Message-ID: <831qsuqllo.fsf@gnu.org> References: <87a67jw1kw.fsf@elite.giraud> <83o7vzqey8.fsf@gnu.org> <83mtbjqemd.fsf@gnu.org> <87ler2963r.fsf@elite.giraud> <838rn2qnsf.fsf@gnu.org> <87wnam6y70.fsf@elite.giraud> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38630"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Manuel Giraud Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Sep 02 09:33:53 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oU1BX-0009jO-JV for ged-emacs-devel@m.gmane-mx.org; Fri, 02 Sep 2022 09:33:51 +0200 Original-Received: from localhost ([::1]:35728 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oU1BW-0001wt-BG for ged-emacs-devel@m.gmane-mx.org; Fri, 02 Sep 2022 03:33:50 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38798) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oU18G-00086P-Go for emacs-devel@gnu.org; Fri, 02 Sep 2022 03:30:33 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:50718) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oU18G-0001SB-5P; Fri, 02 Sep 2022 03:30:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=p8LM4nDhbA32BIm5iNN2Ejo64xyGxL4HFpSus3REwR0=; b=BHZGdqZJOJp8 GB6JBeNy3fePrC5Bh9gyzWZsKeHlFQi02LH8Q2e8+AUVna4EIUuZBuFOOuL9dq+lzIfO9EG5RfwwW MbebTvszwPmcIf27redPxOySYXLlOoePdLuZU9/WsnAIzcbkLIuXpf8bDHYJWFXqu4BruB0JGtbUa yh/5CDrDP6ERkKs24KGxv0CrUGUBOCJS6RQAS722i0eZbTsNDnG5H4pNkvTudarVuXLgtuUCMENYv XtIKfZoGEuKtHP603676t1npoHwtL7cAL3pB46OySxY7Leu2MZChDeb4+1SPUDCj4AVstFxi4IQrg Ps0ezjx4bYgLjucxfCpANw==; Original-Received: from [87.69.77.57] (port=1996 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oU181-0002GU-Jd; Fri, 02 Sep 2022 03:30:27 -0400 In-Reply-To: <87wnam6y70.fsf@elite.giraud> (message from Manuel Giraud on Fri, 02 Sep 2022 09:18:59 +0200) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:294520 Archived-At: > From: Manuel Giraud > 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?