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: Local face remapping Date: Thu, 05 Oct 2023 08:32:54 +0300 Message-ID: <83y1gh4os9.fsf@gnu.org> References: <1AB6E9C8-1BCB-4C0A-A4AF-45F5C64D9B4C@gmail.com> <838r8i5nwe.fsf@gnu.org> <5E16BC09-3063-4509-9DF6-7C8EC25E1285@gmail.com> 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="5788"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: JD Smith Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Oct 05 07:33:49 2023 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 1qoGzd-0001Cf-7R for ged-emacs-devel@m.gmane-mx.org; Thu, 05 Oct 2023 07:33:49 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qoGyf-0006fN-Or; Thu, 05 Oct 2023 01:32:49 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qoGye-0006Zc-Un for emacs-devel@gnu.org; Thu, 05 Oct 2023 01:32:48 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qoGye-0003gX-Mc; Thu, 05 Oct 2023 01:32:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=PDPnC4m29d/URZbdyzFh5SBVonqqd2sHt4nE0a+6zv4=; b=K4uVfUdMa85qGOaK1cep 0VQTm1V0+aJy/PB3P2+ekppwif6WW6JpgMfo8dlucHalgGYTt9gHo5p3qLiVue6sbUVYL+BFsL9qm xHq5XmfxYF23KtaPlzsC/DQvfk/jgB3CkveBoSSp6lYHGl//P1+UZDI8LCfRQr6fRv7dutKXhVfgE yTUkbTUoFXizb4s4RZ8byBnqw7FTjvATFKylcP3WR1Z+EJUiaQi1U+0S9AHnFtNfVpO7ZooV7B52k joiYCoDa3+sk3P6Ddkct3Aa/7fVjEovvIj3kcKxdjK2GeXV7Q7B2LLXfjNhz9s2qhTMGMeLduUHbi qFSFN00Zk3cLLg==; In-Reply-To: <5E16BC09-3063-4509-9DF6-7C8EC25E1285@gmail.com> (message from JD Smith on Wed, 4 Oct 2023 14:48:22 -0400) 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-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:311291 Archived-At: > From: JD Smith > Date: Wed, 4 Oct 2023 14:48:22 -0400 > Cc: emacs-devel@gnu.org > > > > On Oct 4, 2023, at 12:54 PM, Eli Zaretskii wrote: > > > > Use different faces? > > Ha. Yes, of course you can can find and replace all the relevant faces in a region, but given that face-remapping-alist already does this efficiently for the entire buffer, I had hoped a similar region-constrained / overlay-based functionality might exist. I’ll take that as a no :). Let me help you understand the situation better. In Emacs, faces are defined per-frame. That is, each frame can have a different definition of the same face symbol. face-remapping-alist doesn't (and cannot) change that simple fact, so it is a trick: it creates new faces based on default faces, in a way that is buffer-local. This works (btw, not in all places) because the display engine consults the buffer-local value of face-remapping-alist each time it needs to realize a face for display. If that variable is non-nil, and the face to be realized is mentioned in the alist, then the display engine generates a new face on the fly and uses that new face for display. So, if you want face-remapping that depends on buffer positions, you will need to change the implementation of face-remapping: instead of a simple alist, we will probably need to also allow a function returning such an alist, and the C code will need to be taught to deal with the situation where face-remapping-alist's value is a function. My suggestion to use different faces just does explicitly what face-remapping-alist does implicitly.