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: Question: add-face-text-property for 'font-lock-face? Date: Sun, 29 Aug 2021 10:49:15 +0300 Message-ID: <835yvon11g.fsf@gnu.org> References: <83a6l0n32e.fsf@gnu.org> <3272782D-2308-447C-B94B-A65E561C4D18@MIT.EDU> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34627"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Qiantan Hong Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Aug 29 09:50:45 2021 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 1mKFaX-0008r0-BQ for ged-emacs-devel@m.gmane-mx.org; Sun, 29 Aug 2021 09:50:45 +0200 Original-Received: from localhost ([::1]:59434 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mKFaV-0003y5-Ow for ged-emacs-devel@m.gmane-mx.org; Sun, 29 Aug 2021 03:50:43 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51382) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mKFZJ-0003Gz-2L for emacs-devel@gnu.org; Sun, 29 Aug 2021 03:49:29 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:59710) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mKFZI-0005mZ-9y; Sun, 29 Aug 2021 03:49:28 -0400 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:3902 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 1mKFZH-00062l-S4; Sun, 29 Aug 2021 03:49:28 -0400 In-Reply-To: <3272782D-2308-447C-B94B-A65E561C4D18@MIT.EDU> (message from Qiantan Hong on Sun, 29 Aug 2021 07:19:03 +0000) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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:273382 Archived-At: > From: Qiantan Hong > CC: "emacs-devel@gnu.org" > Date: Sun, 29 Aug 2021 07:19:03 +0000 > > I need to add some face attribute to a range of text. > And in case that font-lock-mode is active, the attribute needs to be > added to ‘font-lock-face instead of ‘face text property. > > > I don't think I understand well enough what you want to do, but in > > general, you change a face's attribute by using set-face-attribute. > That doesn’t seem to work for anonymous faces. > I don’t want to globally modify other modes’ faces, > I want to add some attribute over some range of text. > > add-face-text-property seems to exactly do this, > but it’s hardcoded for ‘face property in C code A face property is just a list of keyword-value pairs, so adding an attribute to the list should be trivial, no? Or what am I missing? > textprop.c L1355: > > AUTO_LIST2 (properties, Qface, face); > > add_text_properties_1 (start, end, properties, object, > > (NILP (append) > > ? TEXT_PROPERTY_PREPEND > > : TEXT_PROPERTY_APPEND), > > false); > > return Qnil; > > > It’s a trivial modification to support attributes other than face. > However it requires a patch to C code. > For now I think I’ll just workaround it by reinventing > the same functionality in Elisp. Adding something to a list is so simple you don't need to invent anything, I think.