all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Keith David Bershatsky <esq@lawlist.com>
To: emacs-devel@gnu.org
Subject: Re: C equivalent for: (face-attribute 'region :background (selected-frame) 'default)
Date: Tue, 26 Sep 2017 11:38:03 -0700	[thread overview]
Message-ID: <m2poadnw50.wl%esq@lawlist.com> (raw)

I have begun porting the two relevant Lisp functions to C and will submit them (when finished) in conjunction with the next draft of implementing my feature requests for crosshairs (#17684) and multiple fake cursors (#22873).  I may end up needing some help with some portions of the conversion, but it does not look as difficult as I had initially thought.

DEFUN ("mc-face-attribute", Fmc_face_attribute, Smc_face_attribute, 2, 4, 0,
       doc: /* Return the value of FACE's ATTRIBUTE on FRAME.
If the optional argument FRAME is given, report on face FACE in that frame.
If FRAME is t, report on the defaults for face FACE (for new frames).
If FRAME is omitted or nil, use the selected frame.
If INHERIT is nil, only attributes directly defined by FACE are considered,
  so the return value may be `unspecified', or a relative value.
If INHERIT is non-nil, FACE's definition of ATTRIBUTE is merged with the
  faces specified by its `:inherit' attribute; however the return value
  may still be `unspecified' or relative.
If INHERIT is a face or a list of faces, then the result is further merged
  with that face (or faces), until it becomes specified and absolute.
To ensure that the return value is always specified and absolute, use a
value of `default' for INHERIT; this will resolve any unspecified or
relative values by merging with the `default' face (which is always
completely specified). */)
     (Lisp_Object face, Lisp_Object attribute, Lisp_Object frame, Lisp_Object inherit)
{
  (let ((value (internal-get-lisp-face-attribute face attribute frame)))
    (when (and inherit (face-attribute-relative-p attribute value))
      (let ((inh-from (mc-face-attribute face :inherit frame)))
  (unless (or (null inh-from) (eq inh-from 'unspecified))
          (condition-case nil
              (setq value
                    (mc-face-attribute-merged-with attribute value inh-from frame))
            (error nil)))))
    (when (and inherit
         (not (eq inherit t))
         (face-attribute-relative-p attribute value))
      (setq value (mc-face-attribute-merged-with attribute value inherit frame)))
    value)
}

DEFUN ("mc-face-attribute-merged-with", Fmc_face_attribute_merged_with, Smc_face_attribute_merged_with, 3, 4, 0,
       doc: /* Merges ATTRIBUTE, initially VALUE, with faces from FACES until absolute.
FACES may be either a single face or a list of faces.
[This is an internal function.] */)
     (Lisp_Object attribute, Lisp_Object value, Lisp_Object faces, Lisp_Object frame)
{
  (cond
    ((not (face-attribute-relative-p attribute value))
       value)
    ((null faces)
       value)
    ((consp faces)
      (mc-face-attribute-merged-with
        attribute
        (mc-face-attribute-merged-with attribute value (car faces) frame)
        (cdr faces)
        frame))
    (t
      (merge-face-attribute attribute value (mc-face-attribute faces attribute frame t))))
}



             reply	other threads:[~2017-09-26 18:38 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-26 18:38 Keith David Bershatsky [this message]
2017-09-29 13:25 ` C equivalent for: (face-attribute 'region :background (selected-frame) 'default) Eli Zaretskii
  -- strict thread matches above, loose matches on Subject: below --
2017-10-06  3:53 Keith David Bershatsky
2017-10-05  0:24 Keith David Bershatsky
2017-10-05  6:47 ` Eli Zaretskii
2017-10-05  7:11   ` YAMAMOTO Mitsuharu
2017-09-27  0:24 Keith David Bershatsky
2017-09-27  5:58 ` YAMAMOTO Mitsuharu
2017-09-26 22:11 Keith David Bershatsky
2017-09-29 20:33 ` Philipp Stephani
2017-09-26 22:06 Keith David Bershatsky
2017-09-26  4:38 Keith David Bershatsky
2017-09-26 18:46 ` Philipp Stephani
2017-09-26 23:19 ` YAMAMOTO Mitsuharu

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=m2poadnw50.wl%esq@lawlist.com \
    --to=esq@lawlist.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 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.