diff options
| author | Glenn Morris | 2012-11-21 00:39:08 -0800 |
|---|---|---|
| committer | Glenn Morris | 2012-11-21 00:39:08 -0800 |
| commit | 1bf335cf4327486931b6d4fe42fe1bd3c14406cf (patch) | |
| tree | ce1b0a6dae728a6b00c9f5e5af3e3421f66c9e1d | |
| parent | 3ca2f1bf25b46877497c34c70b36dd511678e29b (diff) | |
| download | emacs-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/ChangeLog | 2 | ||||
| -rw-r--r-- | doc/lispref/display.texi | 41 | ||||
| -rw-r--r-- | lisp/ChangeLog | 3 | ||||
| -rw-r--r-- | 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 @@ | |||
| 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}. | |||
| 2453 | don't specify @var{frame}, they refer to the selected frame; @code{t} | 2453 | don't specify @var{frame}, they refer to the selected frame; @code{t} |
| 2454 | refers to the default data for new frames. They return the symbol | 2454 | refers 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 |
| 2456 | attribute. | 2456 | attribute. If @var{inherit} is @code{nil}, only an attribute directly |
| 2457 | defined by the face is returned. If @var{inherit} is non-@code{nil}, | ||
| 2458 | any faces specified by its @code{:inherit} attribute are considered as | ||
| 2459 | well, and if @var{inherit} is a face or a list of faces, then they are | ||
| 2460 | also considered, until a specified attribute is found. To ensure that | ||
| 2461 | the return value is always specified, use a value of @code{default} for | ||
| 2462 | @var{inherit}. | ||
| 2463 | |||
| 2464 | @defun face-font face &optional frame | ||
| 2465 | This 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 |
| 2460 | These functions return the foreground color (or background color, | 2470 | These functions return the foreground color (or background color, |
| 2461 | respectively) of face @var{face}, as a string. | 2471 | respectively) of face @var{face}, as a string. |
| 2462 | |||
| 2463 | If @var{inherit} is @code{nil}, only a color directly defined by the face is | ||
| 2464 | returned. If @var{inherit} is non-@code{nil}, any faces specified by its | ||
| 2465 | @code{:inherit} attribute are considered as well, and if @var{inherit} | ||
| 2466 | is a face or a list of faces, then they are also considered, until a | ||
| 2467 | specified color is found. To ensure that the return value is always | ||
| 2468 | specified, 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 |
| 2472 | This function returns the name of the background stipple pattern of face | 2475 | This 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 | |||
| 2475 | If @var{inherit} is @code{nil}, only a stipple directly defined by the | ||
| 2476 | face is returned. If @var{inherit} is non-@code{nil}, any faces | ||
| 2477 | specified by its @code{:inherit} attribute are considered as well, and | ||
| 2478 | if @var{inherit} is a face or a list of faces, then they are also | ||
| 2479 | considered, until a specified stipple is found. To ensure that the | ||
| 2480 | return 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 | ||
| 2485 | This 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 |
| 2489 | This function returns a non-@code{nil} value if the @code{:weight} | 2480 | This function returns a non-@code{nil} value if the @code{:weight} |
| 2490 | attribute of @var{face} is bolder than normal (i.e., one of | 2481 | attribute 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 |
| 2496 | This function returns a non-@code{nil} value if the @code{:slant} | 2487 | This function returns a non-@code{nil} value if the @code{:slant} |
| 2497 | attribute of @var{face} is @code{italic} or @code{oblique}, and | 2488 | attribute 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 | ||
| 2504 | This function returns non-@code{nil} if face @var{face} specifies | 2493 | This function returns non-@code{nil} if face @var{face} specifies |
| 2505 | a non-@code{nil} @code{:underline} attribute. | 2494 | a 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 |
| 2509 | This function returns non-@code{nil} if face @var{face} specifies | 2498 | This function returns non-@code{nil} if face @var{face} specifies |
| 2510 | a non-@code{nil} @code{:inverse-video} attribute. | 2499 | a 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 @@ | |||
| 1 | 2012-11-21 Glenn Morris <rgm@gnu.org> | 1 | 2012-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. |
| 497 | If the optional argument FRAME is given, report on face FACE in that frame. | 492 | If the optional argument FRAME is given, report on face FACE in that frame. |
| 498 | If FRAME is t, report on the defaults for face FACE (for new frames). | 493 | If FRAME is t, report on the defaults for face FACE (for new frames). |
| 499 | If FRAME is omitted or nil, use the selected frame." | 494 | If FRAME is omitted or nil, use the selected frame. |
| 500 | (face-attribute-specified-or (face-attribute face :underline frame) nil)) | 495 | Optional 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. |
| 505 | If the optional argument FRAME is given, report on face FACE in that frame. | 502 | If the optional argument FRAME is given, report on face FACE in that frame. |
| 506 | If FRAME is t, report on the defaults for face FACE (for new frames). | 503 | If FRAME is t, report on the defaults for face FACE (for new frames). |
| 507 | If FRAME is omitted or nil, use the selected frame." | 504 | If FRAME is omitted or nil, use the selected frame. |
| 508 | (eq (face-attribute face :inverse-video frame) t)) | 505 | Optional 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. |
| 513 | If the optional argument FRAME is given, report on face FACE in that frame. | 511 | If the optional argument FRAME is given, report on face FACE in that frame. |
| 514 | If FRAME is t, report on the defaults for face FACE (for new frames). | 512 | If FRAME is t, report on the defaults for face FACE (for new frames). |
| 515 | If FRAME is omitted or nil, use the selected frame. | 513 | If FRAME is omitted or nil, use the selected frame. |
| 514 | Optional argument INHERIT is passed to `face-attribute'. | ||
| 516 | Use `face-attribute' for finer control." | 515 | Use `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. |
| 523 | If the optional argument FRAME is given, report on face FACE in that frame. | 522 | If the optional argument FRAME is given, report on face FACE in that frame. |
| 524 | If FRAME is t, report on the defaults for face FACE (for new frames). | 523 | If FRAME is t, report on the defaults for face FACE (for new frames). |
| 525 | If FRAME is omitted or nil, use the selected frame. | 524 | If FRAME is omitted or nil, use the selected frame. |
| 525 | Optional argument INHERIT is passed to `face-attribute'. | ||
| 526 | Use `face-attribute' for finer control." | 526 | Use `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 | ||