unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Davin Pearson <davin.pearson@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re:
Date: Tue, 28 Dec 2021 19:51:03 +0200	[thread overview]
Message-ID: <83h7aslit4.fsf@gnu.org> (raw)
In-Reply-To: <CAG9ihEv_OPaYhTgfh2WnfckC5r21U5Hv0qW7Msnwz4Bbvz6ccg@mail.gmail.com> (message from Davin Pearson on Tue, 28 Dec 2021 16:58:50 +1300)

[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.  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.



  parent reply	other threads:[~2021-12-28 17:51 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-20  2:29 (unknown) Davin Pearson
2021-12-20 14:13 ` none Stefan Monnier
2021-12-21 14:29 ` Eli Zaretskii
     [not found]   ` <CAG9ihEvK5VVgP9O+TXYSz+BQF1=YzMgzGBbc5s-fewwT34yytA@mail.gmail.com>
     [not found]     ` <CAG9ihEsdD2Dd=paZatMfnD3HJxKsUM=3etTz7c-tDcs-H80PoA@mail.gmail.com>
     [not found]       ` <CAG9ihEsQFkx+uE+pZ7R42GXUFR_C2PSzVK8M5AQuHdtOsND0cg@mail.gmail.com>
     [not found]         ` <CAG9ihEv_OPaYhTgfh2WnfckC5r21U5Hv0qW7Msnwz4Bbvz6ccg@mail.gmail.com>
2021-12-28 17:51           ` Eli Zaretskii [this message]
2021-12-28 23:41             ` Re: Davin Pearson
2021-12-31 15:23               ` Re: Anders Lindgren
2022-01-02  1:15                 ` Re: Davin Pearson
2022-01-02  5:19                   ` Re: Stefan Monnier
2022-01-03  0:53                     ` Re: Davin Pearson
  -- strict thread matches above, loose matches on Subject: below --
2023-02-15 17:57 Make all tree-sitter modes optional Alan Mackenzie
2023-02-15 18:33 ` Eli Zaretskii
2023-02-17 13:30   ` Alan Mackenzie
2023-02-17 13:37     ` Po Lu
2023-02-17 13:46       ` Stefan Monnier
2023-02-17 14:16         ` Po Lu
2023-02-17 14:40           ` Eli Zaretskii
2023-02-17 14:56             ` Dmitry Gutov
2023-02-17 15:04               ` Eli Zaretskii
     [not found]                 ` <8735741fic.fsf@dick>
2023-02-17 15:41                   ` Alan Mackenzie
2021-12-02 14:09 Re: Angelo Graziosi
2021-11-04  6:36 Re: Pedro Andres Aranda Gutierrez
2017-10-24 18:52 wait_reading_process_ouput hangs in certain cases (w/ patches) Matthias Dahl
2017-11-14 16:03 ` Eli Zaretskii
2017-11-14 16:23   ` Eli Zaretskii
2017-11-14 21:54     ` Paul Eggert
2017-11-15 14:03       ` Matthias Dahl
2017-11-16 16:46         ` Paul Eggert
2017-11-18 14:24           ` Matthias Dahl
2017-11-19  7:07             ` Paul Eggert
2017-11-20 15:29               ` Matthias Dahl
2017-11-21 14:44                 ` Matthias Dahl
2017-11-22  8:55                   ` Paul Eggert
2017-12-04  9:40                     ` Matthias Dahl
2018-02-13 14:25                       ` Matthias Dahl
2018-02-16 16:01                         ` Eli Zaretskii
2018-02-16 16:09                           ` Lars Ingebrigtsen
2018-02-22 11:45                             ` andres.ramirez
2018-02-26 14:39                               ` Matthias Dahl
2018-02-26 15:11                                 ` andrés ramírez
2018-02-26 15:17                                   ` Lars Ingebrigtsen
2018-02-26 15:29                                     ` andrés ramírez
2018-02-26 16:52                                       ` Daniel Colascione
2018-02-26 17:19                                         ` andrés ramírez
2018-02-26 17:24                                           ` Daniel Colascione
2018-02-27  1:53                                             ` Re: andrés ramírez
2016-02-08  7:54 (unknown) steve
2016-02-08 12:56 ` Artur Malabarba
2016-02-08 19:05   ` Re: Steve Purcell
2016-02-08 20:16     ` Re: Artur Malabarba
     [not found] <CAFkz2yroLhknptDnWyC9B1fbZKEwTCV-T0VttHQiwZoaAW-j6A@mail.gmail.com>
2012-12-20  8:36 ` Re: Константин Куликов
2005-09-10 14:39 Re: Abdulaim
2005-07-06 17:37 Re: Ishok
2005-03-20  5:29 Re: info
2005-01-06 12:16 Re: Документ
2004-11-26 21:10 Re: Robbie Womack
2004-10-10 18:45 Re: John Gard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83h7aslit4.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=davin.pearson@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).