From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: irenezerafa Newsgroups: gmane.emacs.bugs Subject: bug#51715: defface forms not having dynamic value Date: Tue, 09 Nov 2021 14:17:03 +0000 Message-ID: References: <4r0LmHf2yOM8ZtFlkSfgFoHOVu-qI0dwHhAlsf2WxQbn_V5qvtb4t_c7teGE7DqtW8tlI0DRo9pMo0lVCbz33QZni6U0oaIHog5YxKecn80=@protonmail.com> <83ee7p5ujr.fsf@gnu.org> Reply-To: irenezerafa Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4998"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 51715@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Nov 09 15:41:21 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1mkSJL-00015h-SP for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 09 Nov 2021 15:41:19 +0100 Original-Received: from localhost ([::1]:41096 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mkSJK-0006lb-RA for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 09 Nov 2021 09:41:18 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:44768) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mkSJ4-0006ca-Q6 for bug-gnu-emacs@gnu.org; Tue, 09 Nov 2021 09:41:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49813) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mkSJ4-0001tM-HP for bug-gnu-emacs@gnu.org; Tue, 09 Nov 2021 09:41:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mkSJ4-0001kB-FO for bug-gnu-emacs@gnu.org; Tue, 09 Nov 2021 09:41:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: irenezerafa Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 09 Nov 2021 14:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51715 X-GNU-PR-Package: emacs Original-Received: via spool by 51715-submit@debbugs.gnu.org id=B51715.16364688346646 (code B ref 51715); Tue, 09 Nov 2021 14:41:02 +0000 Original-Received: (at 51715) by debbugs.gnu.org; 9 Nov 2021 14:40:34 +0000 Original-Received: from localhost ([127.0.0.1]:33125 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mkSIW-0001ix-Jf for submit@debbugs.gnu.org; Tue, 09 Nov 2021 09:40:33 -0500 Original-Received: from mail-40140.protonmail.ch ([185.70.40.140]:54378) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mkRw0-00018A-Gg for 51715@debbugs.gnu.org; Tue, 09 Nov 2021 09:17:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1636467425; bh=ZZTnZmVdl6cCoRXcDm4Z5WYos+1vWkHVGov/bkvF3+g=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=ha7OiSWN6dHBi4ffh7/Wq3XoXgEgxmiBn6GeMIAIJ8sZBgL9Kg2OrB7M4hJ3GrA/X cbra0oWiFkrsvlNKV/DUFfUedBv1231TLRYx2lsEScaCi3XHA5H/L+6gEXjZnQtmQw vKaN8JSrxmEct50btX+SyCetv1akuTrvHFyseOOM= In-Reply-To: <83ee7p5ujr.fsf@gnu.org> X-Mailman-Approved-At: Tue, 09 Nov 2021 09:40:26 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:219463 Archived-At: =E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90 Original Me= ssage =E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90 On Tuesday, November 9th, 2021 at 1:26 PM, Eli Zaretskii wro= te: > > Date: Tue, 09 Nov 2021 11:41:10 +0000 > > From: irenezerafa via "Bug reports for GNU Emacs, > > the Swiss army knife of text editors" bug-gnu-emacs@gnu.org > > > > I am getting into quite messy code because my macro creates > > defface forms. Those do not have a dynamic value, but use the > > value they get at the time they are evaluated. So using something > > like a variable purple-intense does not help, because its value > > would be a reference to one value, not a function that returns a > > value (and having a function as a value would not be possible for > > a face). > > > > Because the purpose of faces is to be configurable by the user, > > could there be some improvements to easily tackle such problems? > > Please tell more. Which face attributes did you want to make dynamic, > and how? I take rainbow-delimiters as example. Specifically, the (eval-when-compile (defmacro rainbow-delimiters--define-depth-faces () (let ( (faces '()) (dark-colors [ "#ff62d4" "#3fdfd0" "#fba849" "#9f80ff" "#4fe42f" "#fe6060" "#4fafff" "#f0dd60" "#ffffff" ]) =09 (light-colors [ "#a8007f" "#005f88" "#904200" "#7f10d0" "#006800" "#b60000" "#1f1fce" "#605b00" "#000000"]) ) (dotimes (i 9) (push `( defface ,(intern (format "rainbow-delimiters-depth-%d-face= " (1+ i))) =09=09 '( (default (:inherit rainbow-delimiters-base-face)) ( ((class color) (background dark)) =09=09 :foreground ,(aref dark-colors i)) =09=09 ( ((class color) (background light)) =09=09 :foreground ,(aref light-colors i)) ) ,(format "Nested delimiter face, depth %d." (1+ i)) :group 'rainbow-delimiters-faces ) =09 faces)) `(progn ,@faces)) )) (rainbow-delimiters--define-depth-faces) Now, suppose I want to use a colour scheme from modus-themes. (require 'modus-themes) (eval-when-compile (defmacro rainbow-delimiters--define-depth-faces () (let ( (faces '()) (dark-colors (rainbow-delimiters-modus-vivendi-intense-colours =09=09=09 (list magenta-intense cyan-intense orange-intense =09=09=09 purple-intense green-intense red-intense =09=09=09 blue-intense yellow-intense fg-main))) (light-colors (rainbow-delimiters-modus-operandi-intense-colours (list magenta-intense cyan-intense orange-intense =09=09=09=09purple-intense green-intense red-intense =09=09=09=09blue-intense yellow-intense fg-main))) ) (dotimes (i 9) =09(push `(defface ,(intern (format "rainbow-delimiters-depth-%d-face" (1+ = i))) =09=09 '( (default (:inherit rainbow-delimiters-base-face)) ( ((class color) (background light)) =09=09 :foreground ,(nth i light-colors)) ( ((class color) (background dark)) =09=09 :foreground ,(nth i dark-colors)) ) =09=09 ,(format "Nested delimiter face, depth %d." (1+ i)) =09=09 :group 'rainbow-delimiters-faces) faces)) `(progn ,@faces)) )) This would not be workable in practice. Because the dependency only matters when your macro is being evaluated and the faces are reified. Since you have a package, that will be the moment the package gets required. So you are making it a dependency for everyone. Ideally, one could simply add the colour values directly so it would work everywhere, or use the modus-themes dependency for those who are using modus-themes.