From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Anders Lindgren Newsgroups: gmane.emacs.devel Subject: Re: Date: Fri, 31 Dec 2021 16:23:42 +0100 Message-ID: References: <83r1a6yqth.fsf@gnu.org> <83h7aslit4.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000047381f05d472c2aa" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39734"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , emacs-devel To: Davin Pearson Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Dec 31 16:24:47 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 1n3Jlu-000A8w-Uq for ged-emacs-devel@m.gmane-mx.org; Fri, 31 Dec 2021 16:24:47 +0100 Original-Received: from localhost ([::1]:46746 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n3Jlt-0007GM-FC for ged-emacs-devel@m.gmane-mx.org; Fri, 31 Dec 2021 10:24:45 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:33188) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n3Jl9-0006bL-0O for emacs-devel@gnu.org; Fri, 31 Dec 2021 10:23:59 -0500 Original-Received: from [2a00:1450:4864:20::135] (port=34433 helo=mail-lf1-x135.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n3Jl6-0000dm-TP; Fri, 31 Dec 2021 10:23:58 -0500 Original-Received: by mail-lf1-x135.google.com with SMTP id o12so60881153lfk.1; Fri, 31 Dec 2021 07:23:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=5tMC3YYgbO8vtkbN3t5yNVrIhFJydPVoWgy3hNOqcQA=; b=H7GbJkXVY076k3yt3wYuSZS2WmNmJz4Hzo6mHAz6uGkamRwgLQDuSeon27IC4GxprG Bd5QoYwILOYXFyPJo/YEYcb6KKb0MH4JN3y/wXJLOFUh2TgthYkiFq8MKuGh7mKG05T1 Pjh/f8JoUHlrrcxZQLsL6ctqRc9XMskD62Ok3PdEweXZsvj4Is1O3IqBUFFptHpT9wPI Og18sShmFSTp+sS031JlvoOnfOJWA4yoexylMOZq9f1NsBysYvqDo5zCh21dNLUguSj8 2pAqjhehGR54n0Fld6XtrVAF8mfrlD4oGsE689/A50j3/XJbncQctAZR4HaV7mhdEZ/+ 4b5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=5tMC3YYgbO8vtkbN3t5yNVrIhFJydPVoWgy3hNOqcQA=; b=wxjgLVvX+MKdDFNtjGJZAMPapu0XFKbmeT7NTf0DilujZtijLqLeuUlu7vcV5P6Ysb Mm+nDe27dii4r0O4YSQ0Qe6Dkkr2u2L1DPCvKmZv6ZzXFRI2VL5RrKfK6k7L+0Z/vCLH OTdvnKsN4nBY4ox1nks10AepAuCChmC5e1fK1Qgx22PxzRcIsUqniL0Sawm7UL9i+smB YDiYRQn6jCaIbHY/vCapF2Xg6txdo6u3m0defPHx2N6lCTNOHUSsJY2ybMld+GmQSEA/ C9fCgIpZpF6lSemy89VeMRclqjmx1Fsw/pAw9T8SxIxms+AVj0neM4o15/l4WlozMys1 M5Ug== X-Gm-Message-State: AOAM532vVrHP8bX6PU5ple8DrWpbWd9bSOtQK4djOPME7iE61QNm3cOF gMOnu7PbgRJ7g4EzJfetbeIn/QphoooF56JVtzs= X-Google-Smtp-Source: ABdhPJzzJUGtSjG+oAUCzOGZoomthJtq6eR1WQ2ojSin1MaxZTXzWZpWD8yO7Rzmf3/WFTUyl9QlOm8/qWJg0gGZTxg= X-Received: by 2002:a05:6512:3caa:: with SMTP id h42mr31049230lfv.273.1640964234359; Fri, 31 Dec 2021 07:23:54 -0800 (PST) In-Reply-To: X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::135 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::135; envelope-from=andlind@gmail.com; helo=mail-lf1-x135.google.com X-Spam_score_int: 6 X-Spam_score: 0.6 X-Spam_bar: / X-Spam_report: (0.6 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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:283746 Archived-At: --00000000000047381f05d472c2aa Content-Type: text/plain; charset="UTF-8" Hi! I just noticed that all your font-lock rules have specified "t" as the OVERRIDE flag. This has the effect that the face in the rule replaces the existing face. Instead, if you use 'prepend' or 'append' it will place both faces on the text. With 'append' the new face will come before the old face. (If the two faces both define a face property, the first face in the list takes precedence.) You can check the result for yourself. If you eval '(buffer-substring (point) (+ (point) 1))' where you want both faces to be applied, the value of the 'face' property should be a list of faces. -- Anders On Wed, Dec 29, 2021 at 12:43 AM Davin Pearson wrote: > Could you please run my code on your machine to verify that it works on > your machine but not mine. > > On Wed, 29 Dec 2021 at 06:51, Eli Zaretskii wrote: > >> [Please keep the list address on the CC.] >> >> > From: Davin Pearson >> > Date: Tue, 28 Dec 2021 16:58:50 +1300 >> > >> > In your email to me you said that one of the foreground colours >> > will "win" and the other will be ignored. What I want is the >> > same thing for the background colour. As far as I understand the >> > winning foreground colour will be the one that is added last in >> > the fontification spec, and with the symbol 'end added to >> > font-lock-add-keywords. >> > >> > Here is my font-lock-string-face >> > >> > "assdsdasd" >> > >> > Here is the text dmp-asdssd coloured in my choice of colours: red >> > and green: >> > >> > "dmp-asdssd" (*) >> > >> > Here is the code that fontifies the above code. >> > >> > (make-face 'dmp-face--line0--col1-red) >> > (set-face-foreground 'dmp-face--line0--col1-red "#ff0000") >> > (set-face-background 'dmp-face--line0--col1-red nil) >> > (make-face-bold 'dmp-face--line0--col1-red) >> > >> > (make-face 'dmp-face--line0--col2-green) >> > (set-face-foreground 'dmp-face--line0--col2-green "#00ff00") >> > (set-face-background 'dmp-face--line0--col2-green nil) >> > (make-face-bold 'dmp-face--line0--col2-green) >> > >> > (make-face 'dmp-face--line0--col3-blue) >> > (set-face-foreground 'dmp-face--line0--col3-blue "#0000ff") >> > (set-face-background 'dmp-face--line0--col3-blue nil) >> > (make-face-bold 'dmp-face--line0--col3-blue) >> > >> > Here are some useful constant strings: >> > >> > (defvar dmp-defun-inner-regexp-less-dash+star >> "a-zA-Z0-9_.!@$%^&=<>/|+:;?~") >> > (defvar dmp-defun-inner-regexp-less-dash (concat "" >> dmp-defun-inner-regexp-less-dash+star)) >> > (defvar dmp-defun-inner-regexp-less-star (concat "-" >> dmp-defun-inner-regexp-less-dash+star)) >> > (defvar dmp-defun-inner-regexp (concat "-," >> dmp-defun-inner-regexp-less-dash+star)) >> > (defvar dmp-defun-outer-regexp (concat "[" >> dmp-defun-inner-regexp "]+")) >> > (defvar dmp-bra "\\(^\\|[][ >> \t\r\n()'\",.:=]\\)") >> > (defvar dmp-ket "\\($\\|[][ >> \t\r\n()\",.:=]\\)") >> > >> > Here is the actual font lock code: >> > >> > (defun dmp-getting--syntax-highlighting--online () >> > (font-lock-add-keywords >> > 'emacs-lisp-mode >> > '( >> > (, (format "\\(dmp[0-9]\\)\\(\\(-[%s]+\\)+\\)%s" >> > dmp-defun-inner-regexp-less-dash >> > dmp-ket) >> > (1 'dmp-face--line0--col1-red t) >> > (2 'dmp-face--line0--col2-green t) >> > ) >> > (, (format >> "\\(dmp[0-9]\\(-[%s]+\\)\\)\\(\\([-_][-_]\\|:\\)[%s]+\\)%s" >> > dmp-defun-inner-regexp-less-dash >> > dmp-defun-inner-regexp >> > dmp-ket) >> > (1 'dmp-face--line0--col1-red t) >> > (3 'dmp-face--line0--col2-green t)) >> > (, (format >> "\\(dmp[0-9]*\\(-[%s]+\\)*\\)\\([_-][_-][%s]+\\)\\([_-][_-][%s]+\\)%s" >> > *dmp-defun-inner-regexp-less-dash* >> > *dmp-defun-inner-regexp* >> > *dmp-defun-inner-regexp* >> > *dmp-ket*) >> > (1 'dmp-face--line0--col1-red t) >> > (3 'dmp-face--line0--col2-green t) >> > (4 'dmp-face--line0--col3-blue t)) >> > ) >> > 'end) >> > ) >> > (add-hook 'font-lock-mode-hook >> 'dmp-getting--syntax-highlighting--online 'APPEND) >> > >> > Notice that in the text marked with a (*) the background colour >> > of the above text is the same as the background colour of the >> > screen. >> > >> > When dmp-face--line0--col1-red, dmp-face--line0--col2-green and >> > dmp-face--line0--col3-blue 's set-face-foreground set to nil, as it >> > is above, I want the for the string face's background colour to >> > show through as light blue in the fontification of dmp-asdssd. >> >> I think this is something that your code does. If I just merge two >> faces, one with a background color, the other with a foreground color, >> the result of the merge has the background of the first faces and the >> foreground of the second. >> >> So I conclude that something goes wrong in your >> dmp-getting--syntax-highlighting--on-line function, or in how it >> interacts with font-lock. >> > --00000000000047381f05d472c2aa Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi!

I just noticed that all your font-l= ock rules have specified "t" as the OVERRIDE flag. This has the e= ffect that the face in the rule replaces the existing face. Instead, if you= use 'prepend' or 'append' it will place both faces on the = text. With 'append' the new face will come before the old face. (If= the two faces both define a face property, the first face in the list take= s precedence.)

You can check the result for yourse= lf. If you eval '(buffer-substring (point) (+ (point) 1))' where yo= u want both faces to be applied, the value of the 'face' property s= hould=C2=A0be a list of faces.

=C2=A0 =C2=A0 -- An= ders

On Wed, Dec 29, 2021 at 12:43 AM Davin Pearson <davin.pearson@gmail.com> wrote:
Could you please run my code on your machine to verify that= it works on your machine but not mine.

On Wed, 29 Dec 2021 at 06:51, = Eli Zaretskii <eliz@gn= u.org> wrote:
[Please keep the list address on the CC.]

> From: Davin Pearson <davin.pearson@gmail.com>
> Date: Tue, 28 Dec 2021 16:58:50 +1300
>
> In your email to me you said that one of the foreground colours
> will "win" and the other will be ignored.=C2=A0 What I want = is the
> same thing for the background colour.=C2=A0 As far as I understand the=
> winning foreground colour will be the one that is added last in
> the fontification spec, and with the symbol 'end added to
> font-lock-add-keywords.
>
> Here is my font-lock-string-face
>
> "assdsdasd"
>
> Here is the text dmp-asdssd coloured in my choice of colours: red
> and green:
>
> "dmp-asdssd" (*)
>
> Here is the code that fontifies the above code.
>
> (make-face 'dmp-face--line0--col1-red)
> (set-face-foreground 'dmp-face--line0--col1-red "#ff0000"= ;)
> (set-face-background 'dmp-face--line0--col1-red nil)
> (make-face-bold 'dmp-face--line0--col1-red)
>
> (make-face 'dmp-face--line0--col2-green)
> (set-face-foreground 'dmp-face--line0--col2-green "#00ff00&qu= ot;)
> (set-face-background 'dmp-face--line0--col2-green nil)
> (make-face-bold 'dmp-face--line0--col2-green)
>
> (make-face 'dmp-face--line0--col3-blue)
> (set-face-foreground 'dmp-face--line0--col3-blue "#0000ff&quo= t;)
> (set-face-background 'dmp-face--line0--col3-blue nil)
> (make-face-bold 'dmp-face--line0--col3-blue)
>
> Here are some useful constant strings:
>
> (defvar dmp-defun-inner-regexp-less-dash+star "a-zA-Z0-9_.!@$%^&a= mp;=3D<>/|+:;?~")
> (defvar dmp-defun-inner-regexp-less-dash=C2=A0 =C2=A0 =C2=A0 (concat &= quot;"=C2=A0 dmp-defun-inner-regexp-less-dash+star))
> (defvar dmp-defun-inner-regexp-less-star=C2=A0 =C2=A0 =C2=A0 (concat &= quot;-"=C2=A0 dmp-defun-inner-regexp-less-dash+star))
> (defvar dmp-defun-inner-regexp=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 (concat "-," dmp-defun-inner-regexp-less-dash+s= tar))
> (defvar dmp-defun-outer-regexp=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 (concat "["=C2=A0 dmp-defun-inner-regexp=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "]+"))
> (defvar dmp-bra=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"\\(^\\|[][ \t= \r\n()'\",.:=3D]\\)")
> (defvar dmp-ket=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"\\($\\|[][ \t= \r\n()\",.:=3D]\\)")
>
> Here is the actual font lock code:
>
> (defun dmp-getting--syntax-highlighting--online ()
>=C2=A0 =C2=A0(font-lock-add-keywords
>=C2=A0 =C2=A0 'emacs-lisp-mode
>=C2=A0 =C2=A0 '(
>=C2=A0 =C2=A0 =C2=A0 (, (format "\\(dmp[0-9]\\)\\(\\(-[%s]+\\)+\\)= %s"
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0dmp-defun= -inner-regexp-less-dash
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0dmp-ket)<= br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(1 'dmp-face--line0--col1-red t)<= br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(2 'dmp-face--line0--col2-green t= )
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0)
>=C2=A0 =C2=A0 =C2=A0 (, (format "\\(dmp[0-9]\\(-[%s]+\\)\\)\\(\\([= -_][-_]\\|:\\)[%s]+\\)%s"
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0dmp-defun= -inner-regexp-less-dash
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0dmp-defun= -inner-regexp
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0dmp-ket)<= br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(1 'dmp-face--line0--col1-red t)<= br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(3 'dmp-face--line0--col2-green t= ))
>=C2=A0 =C2=A0 =C2=A0 (, (format "\\(dmp[0-9]*\\(-[%s]+\\)*\\)\\([_= -][_-][%s]+\\)\\([_-][_-][%s]+\\)%s"
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0*dmp-defu= n-inner-regexp-less-dash*
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0*dmp-defu= n-inner-regexp*
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0*dmp-defu= n-inner-regexp*
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0*dmp-ket*= )
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(1 'dmp-face--line0--col1-red t)<= br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(3 'dmp-face--line0--col2-green t= )
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(4 'dmp-face--line0--col3-blue t)= )
>=C2=A0 =C2=A0 =C2=A0 )
>=C2=A0 =C2=A0 'end)
>=C2=A0 =C2=A0)
> (add-hook 'font-lock-mode-hook 'dmp-getting--syntax-highlighti= ng--online 'APPEND)
>
> Notice that in the text marked with a (*) the background colour
> of the above text is the same as the background colour of the
> screen.
>
> When dmp-face--line0--col1-red, dmp-face--line0--col2-green and
> dmp-face--line0--col3-blue 's set-face-foreground set to nil, as i= t
> is above, I want the for the string face's background colour to > show through as light blue in the fontification of dmp-asdssd.

I think this is something that your code does.=C2=A0 If I just merge two faces, one with a background color, the other with a foreground color,
the result of the merge has the background of the first faces and the
foreground of the second.

So I conclude that something goes wrong in your
dmp-getting--syntax-highlighting--on-line function, or in how it
interacts with font-lock.
--00000000000047381f05d472c2aa--