From 1bf335cf4327486931b6d4fe42fe1bd3c14406cf Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Wed, 21 Nov 2012 00:39:08 -0800 Subject: [PATCH] Add optional "inherit" argument for face-bold-p and related functions * lisp/faces.el (face-underline-p, face-inverse-video-p, face-bold-p) (face-italic-p): Add optional argument "inherit". * doc/lispref/display.texi (Attribute Functions): Add new "inherit" argument for face-bold-p etc. Move description of this argument to a common section, like "frame". --- doc/lispref/ChangeLog | 2 ++ doc/lispref/display.texi | 41 +++++++++++++++-------------------------- lisp/ChangeLog | 3 +++ lisp/faces.el | 30 +++++++++++++++--------------- 4 files changed, 35 insertions(+), 41 deletions(-) diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index 9dee3797bdd..99e21bac469 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog @@ -2,6 +2,8 @@ * display.texi (Attribute Functions): Update for set-face-* name changes. + Add new "inherit" argument for face-bold-p etc. + Move description of this argument to a common section, like "frame". * debugging.texi (Profiling): New section. (Debugging): Mention profiling in the introduction. diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index 0932e8ceac2..5148c6ec22e 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi @@ -2453,59 +2453,48 @@ This swaps the foreground and background colors of face @var{face}. don't specify @var{frame}, they refer to the selected frame; @code{t} refers to the default data for new frames. They return the symbol @code{unspecified} if the face doesn't define any value for that -attribute. +attribute. If @var{inherit} is @code{nil}, only an attribute directly +defined by the face is returned. If @var{inherit} is non-@code{nil}, +any faces specified by its @code{:inherit} attribute are considered as +well, and if @var{inherit} is a face or a list of faces, then they are +also considered, until a specified attribute is found. To ensure that +the return value is always specified, use a value of @code{default} for +@var{inherit}. + +@defun face-font face &optional frame +This function returns the name of the font of face @var{face}. +@end defun @defun face-foreground face &optional frame inherit @defunx face-background face &optional frame inherit These functions return the foreground color (or background color, respectively) of face @var{face}, as a string. - -If @var{inherit} is @code{nil}, only a color directly defined by the face is -returned. If @var{inherit} is non-@code{nil}, any faces specified by its -@code{:inherit} attribute are considered as well, and if @var{inherit} -is a face or a list of faces, then they are also considered, until a -specified color is found. To ensure that the return value is always -specified, use a value of @code{default} for @var{inherit}. @end defun @defun face-stipple face &optional frame inherit This function returns the name of the background stipple pattern of face @var{face}, or @code{nil} if it doesn't have one. - -If @var{inherit} is @code{nil}, only a stipple directly defined by the -face is returned. If @var{inherit} is non-@code{nil}, any faces -specified by its @code{:inherit} attribute are considered as well, and -if @var{inherit} is a face or a list of faces, then they are also -considered, until a specified stipple is found. To ensure that the -return value is always specified, use a value of @code{default} for -@var{inherit}. -@end defun - -@defun face-font face &optional frame -This function returns the name of the font of face @var{face}. @end defun -@defun face-bold-p face &optional frame +@defun face-bold-p face &optional frame inherit This function returns a non-@code{nil} value if the @code{:weight} attribute of @var{face} is bolder than normal (i.e., one of @code{semi-bold}, @code{bold}, @code{extra-bold}, or @code{ultra-bold}). Otherwise, it returns @code{nil}. @end defun -@defun face-italic-p face &optional frame +@defun face-italic-p face &optional frame inherit This function returns a non-@code{nil} value if the @code{:slant} attribute of @var{face} is @code{italic} or @code{oblique}, and @code{nil} otherwise. @end defun -@c Note the weasel words. A face that inherits from an underlined -@c face but does not specify :underline will return nil. -@defun face-underline-p face &optional frame +@defun face-underline-p face &optional frame inherit This function returns non-@code{nil} if face @var{face} specifies a non-@code{nil} @code{:underline} attribute. @end defun -@defun face-inverse-video-p face &optional frame +@defun face-inverse-video-p face &optional frame inherit This function returns non-@code{nil} if face @var{face} specifies a non-@code{nil} @code{:inverse-video} attribute. @end defun diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 19268a4f860..192de015ea6 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,8 @@ 2012-11-21 Glenn Morris + * faces.el (face-underline-p, face-inverse-video-p, face-bold-p) + (face-italic-p): Add optional argument "inherit". + * faces.el (set-face-inverse-video, set-face-bold, set-face-italic): Remove -p suffix from names, for consistency with other set-face-*. (set-face-inverse-video): Fix interactive spec. diff --git a/lisp/faces.el b/lisp/faces.el index cb3470c167d..f8dc4783cbb 100644 --- a/lisp/faces.el +++ b/lisp/faces.el @@ -487,44 +487,44 @@ with the `default' face (which is always completely specified)." (defalias 'face-background-pixmap 'face-stipple) -;; FIXME all of these -p functions ignore inheritance (cf face-stipple). -;; Ie, a face that inherits from an underlined face but does not -;; specify :underline will return nil. -;; So these functions don't actually tell you anything about how the -;; face will _appear_. So not very useful IMO. -(defun face-underline-p (face &optional frame) +(defun face-underline-p (face &optional frame inherit) "Return non-nil if FACE specifies a non-nil underlining. 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." - (face-attribute-specified-or (face-attribute face :underline frame) nil)) +If FRAME is omitted or nil, use the selected frame. +Optional argument INHERIT is passed to `face-attribute'." + (face-attribute-specified-or + (face-attribute face :underline frame inherit) nil)) -(defun face-inverse-video-p (face &optional frame) +(defun face-inverse-video-p (face &optional frame inherit) "Return non-nil if FACE specifies a non-nil inverse-video. 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." - (eq (face-attribute face :inverse-video frame) t)) +If FRAME is omitted or nil, use the selected frame. +Optional argument INHERIT is passed to `face-attribute'." + (eq (face-attribute face :inverse-video frame inherit) t)) -(defun face-bold-p (face &optional frame) +(defun face-bold-p (face &optional frame inherit) "Return non-nil if the font of FACE is bold 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. +Optional argument INHERIT is passed to `face-attribute'. Use `face-attribute' for finer control." - (let ((bold (face-attribute face :weight frame))) + (let ((bold (face-attribute face :weight frame inherit))) (memq bold '(semi-bold bold extra-bold ultra-bold)))) -(defun face-italic-p (face &optional frame) +(defun face-italic-p (face &optional frame inherit) "Return non-nil if the font of FACE is italic 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. +Optional argument INHERIT is passed to `face-attribute'. Use `face-attribute' for finer control." - (let ((italic (face-attribute face :slant frame))) + (let ((italic (face-attribute face :slant frame inherit))) (memq italic '(italic oblique)))) -- 2.11.4.GIT