From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Boris Buliga Newsgroups: gmane.emacs.help Subject: Re: Overriding inherited face attributes Date: Wed, 28 Nov 2018 09:39:29 +0200 Message-ID: References: <87pnuqfboc.fsf@gmx.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: blaine.gmane.org 1543390691 7546 195.159.176.226 (28 Nov 2018 07:38:11 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 28 Nov 2018 07:38:11 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: stephen.berman@gmx.net Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Nov 28 08:38:07 2018 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gRuQA-0001su-OM for geh-help-gnu-emacs@m.gmane.org; Wed, 28 Nov 2018 08:38:07 +0100 Original-Received: from localhost ([::1]:46389 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRuSH-0007Er-11 for geh-help-gnu-emacs@m.gmane.org; Wed, 28 Nov 2018 02:40:17 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55704) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRuRi-0007El-Gz for help-gnu-emacs@gnu.org; Wed, 28 Nov 2018 02:39:43 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRuRh-0006zc-89 for help-gnu-emacs@gnu.org; Wed, 28 Nov 2018 02:39:42 -0500 Original-Received: from mail-ot1-x331.google.com ([2607:f8b0:4864:20::331]:35541) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gRuRg-0006xN-UI for help-gnu-emacs@gnu.org; Wed, 28 Nov 2018 02:39:41 -0500 Original-Received: by mail-ot1-x331.google.com with SMTP id 81so22711627otj.2 for ; Tue, 27 Nov 2018 23:39:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=d12frosted-io.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=BBQIw/LcLL+5PJek/kZwhd99+ID3ldzkrHs+OBqkXpI=; b=XyTZs1lRgFN2FIn3XGfOYH/YhH7dejMvmueR4OQqhDIslHqqnIVC4J1WHGQOdUxzEH G3CQS/vMtDbQ9jTrrxuRvnyB9fyRziupT+m7p3WF7/8e7yj+pk9I6Svv4/la2TMocI33 Ywk/6MlZeHKdA8MKKrY4YeQjZPeoq8g6aNdzV/JVqYXyp1EBhHqJ3FdjrpwBgr5adJIM KjaL5hh/Ly0vVrQTo75fyZIFL7b7myw6NN4uXHpzdBBA061sLBHYlv8nKXQDV3slao2z fBolV0EmHRmTC4GaMN+9QUpGITdNInzcjLVO/yxf4GQdat7RRGKa3CHg3XEXUIA595bo ldKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=BBQIw/LcLL+5PJek/kZwhd99+ID3ldzkrHs+OBqkXpI=; b=ndWzL7yJ68pUi2f2VhghZBFVRu1uY5mkAooRHigkAwH9op5BBxfZc51wYSVG49LASE 4chqTg/ozoD5o49m3rjZl14E9AeAoSkYAEyqcbSjaWMEITpJtYAPE0jgvmgoIiRyldpL hlDEy9m07ef/77igbA2RBrz+zK7Ccqz8QeC6emFA46UTQnqzfaNXJnvs/39lIp6uESxC rZiJDrJZrptYzeOvINvQGVcSxYiOluAO56HIiA9XPde7xikb8LppTQI5hKfFGwt5V0OK P6Wip96P+azaREP7ZblhhvBKvActxecBm1hs/824tZnEwG0QbshlxL001N1vg+DXF09S Xcbg== X-Gm-Message-State: AA+aEWbqpIGOAsvdndjRSuTmyhJpvO3RT1Px4rm4k8yDvjSFvqOuYB9Z Jq5uaKW71EeUFKMOZ27QFuKwlFMHDA0IvyQ+wnvp3gmkT1Z3AQ== X-Google-Smtp-Source: AFSGD/Wz7CaSg3ZiTa2Pr9C1fRVyteH7/UoduOeE2RYb66aUyi77k2JcUz1AsFTajzOY8V8V2N5X8NOVxH8QasW6q7w= X-Received: by 2002:a9d:220c:: with SMTP id o12mr15002559ota.19.1543390780172; Tue, 27 Nov 2018 23:39:40 -0800 (PST) In-Reply-To: <87pnuqfboc.fsf@gmx.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::331 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:118784 Archived-At: Stephen, Thank you for the answer. Indeed, adding this property to the end resolves my problem. -------------------------------------------------------------------------------- Stephen and Eli, Regarding documentation. 1. We have a part saying that 'faces occurring earlier in the list have higher priority'. This is super clear and easy to check. For example, > (setq my-test-string (propertize "hello" 'face '(:inherit (:foreground "orange")))) #("hello" 0 5 (face (:inherit (:foreground "orange")))) > (add-face-text-property 0 5 '(:foreground "red") nil my-test-string) nil > my-test-string #("hello" 0 5 (face ((:foreground "red") (:inherit ...)))) Inserting this string results in the red 'hello'. If you try you do append the property to the end, you'll get an orange 'hello'. So far so good. Then I tried to do the same with propertize and I've got quite different result. > (propertize "hello" 'face '(:foreground "red" :inherit (:foreground "orange"))) #("hello" 0 5 (face (:foreground "red" :inherit (:foreground "orange")))) ;; results in an orange text > (propertize "hello" 'face '((:foreground "red") (:inherit (:foreground "orange")))) #("hello" 0 5 (face ((:foreground "red") (:inherit ...)))) ;; results in a red text To me, it's still confusing. Why in the first example I have an orange text and in the second one - red? 2. And there is a part saying something I don't quite understand about inheritance. > Attributes from inherited faces are merged into the face like an underlying > face would be, with higher priority than underlying faces. This one looks good to me. If I understand this correctly - inherited face attributes behave as usual face attributes. Am I right? On Tue, 27 Nov 2018 at 23:33, Stephen Berman wrote: > On Tue, 27 Nov 2018 22:18:45 +0200 Boris Buliga > wrote: > > > Hi everyone, > > > > Sorry if this question was answered somewhere before. I searched and > didn't > > find any working solution, so here I am. > > > > Problem. Override a face attribute that is defined in an inherited face. > > > > For example, open up a new buffer in the fundamental mode and evaulate > the > > following experssion: > > > > (insert (propertize "hello" 'face '(:foreground "red" :inherit > (:foreground > > "orange")))) > > > > I expect the word 'hello' to be red, but instead, it is orange. > > > > So two questions: > > > > 1. Am I right to expect the text to be red? > > 2. How to achieve this? > > I don't know the answer to your first questions, but the answer to the > second question appears to be: switch the order. At least, when I > evaluate the following in fundamental mode, 'hello' is red: > > (insert (propertize "hello" 'face '(:inherit (:foreground "orange") > :foreground "red"))) > > In (info "(elisp) Special Properties") it says this: "The value of the > [`face'] property can be... A list of faces... Faces occurring earlier > in the list have higher priority." And in (info "(elisp) Face > Attributes") it says: "Attributes from inherited faces are merged into > the face like an underlying face would be, with higher priority than > underlying faces." Whether this implies the above observed behavior is > not clear to me. > > Steve Berman > -- Cheers, Boris