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