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: Date: Tue, 28 Dec 2021 19:51:03 +0200 Message-ID: <83h7aslit4.fsf@gnu.org> References: <83r1a6yqth.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34087"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Davin Pearson Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Dec 28 18:52:42 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 1n2GeP-0008hl-KQ for ged-emacs-devel@m.gmane-mx.org; Tue, 28 Dec 2021 18:52:41 +0100 Original-Received: from localhost ([::1]:34060 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n2GeN-00016P-HH for ged-emacs-devel@m.gmane-mx.org; Tue, 28 Dec 2021 12:52:39 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:56994) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n2Gcw-0000PE-MG for emacs-devel@gnu.org; Tue, 28 Dec 2021 12:51:10 -0500 Original-Received: from [2001:470:142:3::e] (port=43910 helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n2Gcw-00078a-8y; Tue, 28 Dec 2021 12:51:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=BUtiT+zeqOUoJX1ewSCwtVpR3XGmXlrHe/guty5OSXA=; b=K3meMFLI05Rd XR1MygAh8B3GZSuyzLXP+i8cqc6cvJR6VcUeFMclK6WS1ql0jISXsDkHIwEKh6FgsnazeGEQPwI3h I1eEVqTL1jhaAtDFxz/uxUqMpUFEXWONXTL8MlL46E6dOlq3qFyGsXwY3sDtUYcKQb7HPOrG89mle +n2hJQMh9cpP+Q0Woe9ZVCnc7yF4Wa4WXchmXh6uFmGSLPL0KC3K7SR7qoKvTmH+YaSqDUilQ99nK xcXDwG/nlL0fjfhoIWGvO/XTOns3CVDnFeTMncbVyC1/n0LT4arGnNsv3DO9jO9Jh0HdvzX2Dau2o ONnMvLV8ro9mDmkUCXNGNg==; Original-Received: from [87.69.77.57] (port=2888 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n2Gcw-0004oM-4y; Tue, 28 Dec 2021 12:51:10 -0500 In-Reply-To: (message from Davin Pearson on Tue, 28 Dec 2021 16:58:50 +1300) 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:283518 Archived-At: [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.