diff options
| author | shipmints | 2025-04-20 13:09:35 -0400 |
|---|---|---|
| committer | Eli Zaretskii | 2025-06-07 12:39:49 +0300 |
| commit | 13fa74b73c36de2439f7cae13f25647fb46161e9 (patch) | |
| tree | 52a26729dfb93d665eb7e9ffd89944a32a8dcab8 | |
| parent | fc96cc1feb488dfeffd760d63872515f04033894 (diff) | |
| download | emacs-13fa74b73c36de2439f7cae13f25647fb46161e9.tar.gz emacs-13fa74b73c36de2439f7cae13f25647fb46161e9.zip | |
Add optional inherit argument to 'face-all-attributes' (bug#77945)
* lisp/faces.el (face-all-attributes): Add 'inherit' argument
and pass to 'face-attribute'.
| -rw-r--r-- | doc/lispref/display.texi | 15 | ||||
| -rw-r--r-- | etc/NEWS | 7 | ||||
| -rw-r--r-- | lisp/faces.el | 13 |
3 files changed, 23 insertions, 12 deletions
diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index 3b48cb93405..55652682505 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi | |||
| @@ -3186,18 +3186,21 @@ For example: | |||
| 3186 | @end example | 3186 | @end example |
| 3187 | @end defun | 3187 | @end defun |
| 3188 | 3188 | ||
| 3189 | @defun face-all-attributes face &optional frame | 3189 | @defun face-all-attributes face &optional frame inherit |
| 3190 | This function returns an alist of attributes of @var{face}. The | 3190 | This function returns an alist of attributes of @var{face}. The |
| 3191 | elements of the result are name-value pairs of the form | 3191 | elements of the result are name-value pairs of the form |
| 3192 | @w{@code{(@var{attr-name} . @var{attr-value})}}. Optional argument | 3192 | @w{@code{(@var{attr-name} . @var{attr-value})}}. Optional argument |
| 3193 | @var{frame} specifies the frame whose definition of @var{face} to | 3193 | @var{frame} specifies the frame whose definition of @var{face} to |
| 3194 | return; if omitted or @code{nil}, the returned value describes the | 3194 | return; if omitted or @code{nil}, the returned value describes the |
| 3195 | default attributes of @var{face} for newly created frames, i.e.@: the | 3195 | default attributes of @var{face} for newly created frames, i.e.@: the |
| 3196 | values these attributes have before applying the face spec in the | 3196 | values these attributes have before applying the face spec in the face's |
| 3197 | face's @code{defface} definition or the spec set by | 3197 | @code{defface} definition or the spec set by @code{face-spec-set}. |
| 3198 | @code{face-spec-set}. These default values of the attributes are | 3198 | These default values of the attributes are normally @code{unspecified}, |
| 3199 | normally @code{unspecified}, unless you have specified some other | 3199 | unless you have specified some other value using |
| 3200 | value using @code{set-face-attribute}; see below. | 3200 | @code{set-face-attribute}; see below. The optional argument |
| 3201 | @var{inherit} has the same meaning as the same argument to | ||
| 3202 | @code{face-attribute}, which see. This is useful when you want the face | ||
| 3203 | attributes to be absolute and not @code{unspecified}. | ||
| 3201 | @end defun | 3204 | @end defun |
| 3202 | 3205 | ||
| 3203 | @defun merge-face-attribute attribute value1 value2 | 3206 | @defun merge-face-attribute attribute value1 value2 |
| @@ -2057,6 +2057,13 @@ This option tells 'flash-face-bell-function' and | |||
| 2057 | 'flash-echo-area-bell-function' which face attributes should be used | 2057 | 'flash-echo-area-bell-function' which face attributes should be used |
| 2058 | for flash. | 2058 | for flash. |
| 2059 | 2059 | ||
| 2060 | +++ | ||
| 2061 | *** 'face-all-attributes' now accepts an optional inherit argument. | ||
| 2062 | 'inherit' has the same meaning as the same argument to 'face-attribute', | ||
| 2063 | which already takes this argument for a single attribute. This is | ||
| 2064 | useful when you want the face attributes to be absolute and not | ||
| 2065 | 'unspecified'. | ||
| 2066 | |||
| 2060 | --- | 2067 | --- |
| 2061 | ** Flymake | 2068 | ** Flymake |
| 2062 | 2069 | ||
diff --git a/lisp/faces.el b/lisp/faces.el index dbc0a2e04f6..3b48c243587 100644 --- a/lisp/faces.el +++ b/lisp/faces.el | |||
| @@ -442,15 +442,16 @@ If `inhibit-x-resources' is non-nil, this function does nothing." | |||
| 442 | (symbol-name (check-face face))) | 442 | (symbol-name (check-face face))) |
| 443 | 443 | ||
| 444 | 444 | ||
| 445 | (defun face-all-attributes (face &optional frame) | 445 | (defun face-all-attributes (face &optional frame inherit) |
| 446 | "Return an alist stating the attributes of FACE. | 446 | "Return an alist stating the attributes of FACE. |
| 447 | Each element of the result has the form (ATTR-NAME . ATTR-VALUE). | 447 | Each element of the result has the form (ATTR-NAME . ATTR-VALUE). If |
| 448 | If FRAME is omitted or nil the value describes the default attributes, | 448 | FRAME is omitted or nil the value describes the default attributes, but |
| 449 | but if you specify FRAME, the value describes the attributes | 449 | if you specify FRAME, the value describes the attributes of FACE on |
| 450 | of FACE on FRAME." | 450 | FRAME. INHERIT has the same meaning as the same argument to |
| 451 | `face-attribute', which see." | ||
| 451 | (mapcar (lambda (pair) | 452 | (mapcar (lambda (pair) |
| 452 | (let ((attr (car pair))) | 453 | (let ((attr (car pair))) |
| 453 | (cons attr (face-attribute face attr (or frame t))))) | 454 | (cons attr (face-attribute face attr (or frame t) inherit)))) |
| 454 | face-attribute-name-alist)) | 455 | face-attribute-name-alist)) |
| 455 | 456 | ||
| 456 | (defun face-attribute (face attribute &optional frame inherit) | 457 | (defun face-attribute (face attribute &optional frame inherit) |