all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Óscar Fuentes" <ofv@wanadoo.es>
To: help-gnu-emacs@gnu.org
Subject: Re: Trying to define face dynamically
Date: Fri, 18 Oct 2019 02:15:47 +0200	[thread overview]
Message-ID: <87h846oqmk.fsf@telefonica.net> (raw)
In-Reply-To: 87lftjno57.fsf@telefonica.net

Óscar Fuentes <ofv@wanadoo.es> writes:

> Eli Zaretskii <eliz@gnu.org> writes:
>
>>> (mapcar (lambda (face)
>>>            (face-remap-add-relative
>>>               face `(:filtered (:window has-keyboard-focus nil)
>>>                      :background ,(color-darken-name
>>>                                    (face-attribute face :background)
>>> 				   10.0))))
>>>     '(default fringe))
>>> 
>>> But this has not the desired effect: faces remain the same and every now
>>> and then Emacs throws an error "wrong-type-argument stringp nil" from
>>> functions such as font-info.
>>> 
>>> What I'm doing wrong?
>>
>> You didn't say what color-darken-name does, but I think the problem is
>> that ':background "foo"' is not a face spec.  Did you try something
>> like '(background-color . ,(color-darken-name ...))' or maybe
>> '(:background ,(color-darken-name ...))' instead?
>
> Thanks. Changing to either of your suggestions eliminates the error, but
> the face is not altered.

Eli's suggestion was right. The face change didn't apply because
specific actions are required by the minor mode to be effective.

For the record, this is the complete call:

(mapcar (lambda (face)
	  (face-remap-add-relative
	   face
	   `(:filtered
	     (:window has-keyboard-focus nil)
	     (:background
	      ,(color-darken-name
		(face-attribute 'default :background)
		3.0)))))
	'(default fringe))

This darkens the "default" and "fringe" background colors by 3% when the
window has no keyboard focus. Neat. Now, if we only had a hook for
detecting enabling/disabling of themes for invocating the code above
automatically...

I'll submit a bug report about that.




      reply	other threads:[~2019-10-18  0:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-17 18:54 Trying to define face dynamically Óscar Fuentes
2019-10-17 19:30 ` Eli Zaretskii
2019-10-17 19:54   ` Óscar Fuentes
2019-10-18  0:15     ` Óscar Fuentes [this message]

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

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

  git send-email \
    --in-reply-to=87h846oqmk.fsf@telefonica.net \
    --to=ofv@wanadoo.es \
    --cc=help-gnu-emacs@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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.