aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2012-11-21 00:39:08 -0800
committerGlenn Morris2012-11-21 00:39:08 -0800
commit1bf335cf4327486931b6d4fe42fe1bd3c14406cf (patch)
treece1b0a6dae728a6b00c9f5e5af3e3421f66c9e1d
parent3ca2f1bf25b46877497c34c70b36dd511678e29b (diff)
downloademacs-1bf335cf4327486931b6d4fe42fe1bd3c14406cf.tar.gz
emacs-1bf335cf4327486931b6d4fe42fe1bd3c14406cf.zip
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".
-rw-r--r--doc/lispref/ChangeLog2
-rw-r--r--doc/lispref/display.texi41
-rw-r--r--lisp/ChangeLog3
-rw-r--r--lisp/faces.el30
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 @@
2 2
3 * display.texi (Attribute Functions): 3 * display.texi (Attribute Functions):
4 Update for set-face-* name changes. 4 Update for set-face-* name changes.
5 Add new "inherit" argument for face-bold-p etc.
6 Move description of this argument to a common section, like "frame".
5 7
6 * debugging.texi (Profiling): New section. 8 * debugging.texi (Profiling): New section.
7 (Debugging): Mention profiling in the introduction. 9 (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}.
2453don't specify @var{frame}, they refer to the selected frame; @code{t} 2453don't specify @var{frame}, they refer to the selected frame; @code{t}
2454refers to the default data for new frames. They return the symbol 2454refers to the default data for new frames. They return the symbol
2455@code{unspecified} if the face doesn't define any value for that 2455@code{unspecified} if the face doesn't define any value for that
2456attribute. 2456attribute. If @var{inherit} is @code{nil}, only an attribute directly
2457defined by the face is returned. If @var{inherit} is non-@code{nil},
2458any faces specified by its @code{:inherit} attribute are considered as
2459well, and if @var{inherit} is a face or a list of faces, then they are
2460also considered, until a specified attribute is found. To ensure that
2461the return value is always specified, use a value of @code{default} for
2462@var{inherit}.
2463
2464@defun face-font face &optional frame
2465This function returns the name of the font of face @var{face}.
2466@end defun
2457 2467
2458@defun face-foreground face &optional frame inherit 2468@defun face-foreground face &optional frame inherit
2459@defunx face-background face &optional frame inherit 2469@defunx face-background face &optional frame inherit
2460These functions return the foreground color (or background color, 2470These functions return the foreground color (or background color,
2461respectively) of face @var{face}, as a string. 2471respectively) of face @var{face}, as a string.
2462
2463If @var{inherit} is @code{nil}, only a color directly defined by the face is
2464returned. If @var{inherit} is non-@code{nil}, any faces specified by its
2465@code{:inherit} attribute are considered as well, and if @var{inherit}
2466is a face or a list of faces, then they are also considered, until a
2467specified color is found. To ensure that the return value is always
2468specified, use a value of @code{default} for @var{inherit}.
2469@end defun 2472@end defun
2470 2473
2471@defun face-stipple face &optional frame inherit 2474@defun face-stipple face &optional frame inherit
2472This function returns the name of the background stipple pattern of face 2475This function returns the name of the background stipple pattern of face
2473@var{face}, or @code{nil} if it doesn't have one. 2476@var{face}, or @code{nil} if it doesn't have one.
2474
2475If @var{inherit} is @code{nil}, only a stipple directly defined by the
2476face is returned. If @var{inherit} is non-@code{nil}, any faces
2477specified by its @code{:inherit} attribute are considered as well, and
2478if @var{inherit} is a face or a list of faces, then they are also
2479considered, until a specified stipple is found. To ensure that the
2480return value is always specified, use a value of @code{default} for
2481@var{inherit}.
2482@end defun
2483
2484@defun face-font face &optional frame
2485This function returns the name of the font of face @var{face}.
2486@end defun 2477@end defun
2487 2478
2488@defun face-bold-p face &optional frame 2479@defun face-bold-p face &optional frame inherit
2489This function returns a non-@code{nil} value if the @code{:weight} 2480This function returns a non-@code{nil} value if the @code{:weight}
2490attribute of @var{face} is bolder than normal (i.e., one of 2481attribute of @var{face} is bolder than normal (i.e., one of
2491@code{semi-bold}, @code{bold}, @code{extra-bold}, or 2482@code{semi-bold}, @code{bold}, @code{extra-bold}, or
2492@code{ultra-bold}). Otherwise, it returns @code{nil}. 2483@code{ultra-bold}). Otherwise, it returns @code{nil}.
2493@end defun 2484@end defun
2494 2485
2495@defun face-italic-p face &optional frame 2486@defun face-italic-p face &optional frame inherit
2496This function returns a non-@code{nil} value if the @code{:slant} 2487This function returns a non-@code{nil} value if the @code{:slant}
2497attribute of @var{face} is @code{italic} or @code{oblique}, and 2488attribute of @var{face} is @code{italic} or @code{oblique}, and
2498@code{nil} otherwise. 2489@code{nil} otherwise.
2499@end defun 2490@end defun
2500 2491
2501@c Note the weasel words. A face that inherits from an underlined 2492@defun face-underline-p face &optional frame inherit
2502@c face but does not specify :underline will return nil.
2503@defun face-underline-p face &optional frame
2504This function returns non-@code{nil} if face @var{face} specifies 2493This function returns non-@code{nil} if face @var{face} specifies
2505a non-@code{nil} @code{:underline} attribute. 2494a non-@code{nil} @code{:underline} attribute.
2506@end defun 2495@end defun
2507 2496
2508@defun face-inverse-video-p face &optional frame 2497@defun face-inverse-video-p face &optional frame inherit
2509This function returns non-@code{nil} if face @var{face} specifies 2498This function returns non-@code{nil} if face @var{face} specifies
2510a non-@code{nil} @code{:inverse-video} attribute. 2499a non-@code{nil} @code{:inverse-video} attribute.
2511@end defun 2500@end defun
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 19268a4f860..192de015ea6 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,8 @@
12012-11-21 Glenn Morris <rgm@gnu.org> 12012-11-21 Glenn Morris <rgm@gnu.org>
2 2
3 * faces.el (face-underline-p, face-inverse-video-p, face-bold-p)
4 (face-italic-p): Add optional argument "inherit".
5
3 * faces.el (set-face-inverse-video, set-face-bold, set-face-italic): 6 * faces.el (set-face-inverse-video, set-face-bold, set-face-italic):
4 Remove -p suffix from names, for consistency with other set-face-*. 7 Remove -p suffix from names, for consistency with other set-face-*.
5 (set-face-inverse-video): Fix interactive spec. 8 (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)."
487(defalias 'face-background-pixmap 'face-stipple) 487(defalias 'face-background-pixmap 'face-stipple)
488 488
489 489
490;; FIXME all of these -p functions ignore inheritance (cf face-stipple). 490(defun face-underline-p (face &optional frame inherit)
491;; Ie, a face that inherits from an underlined face but does not
492;; specify :underline will return nil.
493;; So these functions don't actually tell you anything about how the
494;; face will _appear_. So not very useful IMO.
495(defun face-underline-p (face &optional frame)
496 "Return non-nil if FACE specifies a non-nil underlining. 491 "Return non-nil if FACE specifies a non-nil underlining.
497If the optional argument FRAME is given, report on face FACE in that frame. 492If the optional argument FRAME is given, report on face FACE in that frame.
498If FRAME is t, report on the defaults for face FACE (for new frames). 493If FRAME is t, report on the defaults for face FACE (for new frames).
499If FRAME is omitted or nil, use the selected frame." 494If FRAME is omitted or nil, use the selected frame.
500 (face-attribute-specified-or (face-attribute face :underline frame) nil)) 495Optional argument INHERIT is passed to `face-attribute'."
496 (face-attribute-specified-or
497 (face-attribute face :underline frame inherit) nil))
501 498
502 499
503(defun face-inverse-video-p (face &optional frame) 500(defun face-inverse-video-p (face &optional frame inherit)
504 "Return non-nil if FACE specifies a non-nil inverse-video. 501 "Return non-nil if FACE specifies a non-nil inverse-video.
505If the optional argument FRAME is given, report on face FACE in that frame. 502If the optional argument FRAME is given, report on face FACE in that frame.
506If FRAME is t, report on the defaults for face FACE (for new frames). 503If FRAME is t, report on the defaults for face FACE (for new frames).
507If FRAME is omitted or nil, use the selected frame." 504If FRAME is omitted or nil, use the selected frame.
508 (eq (face-attribute face :inverse-video frame) t)) 505Optional argument INHERIT is passed to `face-attribute'."
506 (eq (face-attribute face :inverse-video frame inherit) t))
509 507
510 508
511(defun face-bold-p (face &optional frame) 509(defun face-bold-p (face &optional frame inherit)
512 "Return non-nil if the font of FACE is bold on FRAME. 510 "Return non-nil if the font of FACE is bold on FRAME.
513If the optional argument FRAME is given, report on face FACE in that frame. 511If the optional argument FRAME is given, report on face FACE in that frame.
514If FRAME is t, report on the defaults for face FACE (for new frames). 512If FRAME is t, report on the defaults for face FACE (for new frames).
515If FRAME is omitted or nil, use the selected frame. 513If FRAME is omitted or nil, use the selected frame.
514Optional argument INHERIT is passed to `face-attribute'.
516Use `face-attribute' for finer control." 515Use `face-attribute' for finer control."
517 (let ((bold (face-attribute face :weight frame))) 516 (let ((bold (face-attribute face :weight frame inherit)))
518 (memq bold '(semi-bold bold extra-bold ultra-bold)))) 517 (memq bold '(semi-bold bold extra-bold ultra-bold))))
519 518
520 519
521(defun face-italic-p (face &optional frame) 520(defun face-italic-p (face &optional frame inherit)
522 "Return non-nil if the font of FACE is italic on FRAME. 521 "Return non-nil if the font of FACE is italic on FRAME.
523If the optional argument FRAME is given, report on face FACE in that frame. 522If the optional argument FRAME is given, report on face FACE in that frame.
524If FRAME is t, report on the defaults for face FACE (for new frames). 523If FRAME is t, report on the defaults for face FACE (for new frames).
525If FRAME is omitted or nil, use the selected frame. 524If FRAME is omitted or nil, use the selected frame.
525Optional argument INHERIT is passed to `face-attribute'.
526Use `face-attribute' for finer control." 526Use `face-attribute' for finer control."
527 (let ((italic (face-attribute face :slant frame))) 527 (let ((italic (face-attribute face :slant frame inherit)))
528 (memq italic '(italic oblique)))) 528 (memq italic '(italic oblique))))
529 529
530 530