diff options
| author | Glenn Morris | 2012-11-14 23:30:46 -0800 |
|---|---|---|
| committer | Glenn Morris | 2012-11-14 23:30:46 -0800 |
| commit | bde3c6c0f79ab814e12ea0f04b06625f91f5cd52 (patch) | |
| tree | 1c5120a620b7fd140b6325cfa0a42173d155589e | |
| parent | e2e13f1831a71b558b3625c4ecf3d35100236870 (diff) | |
| download | emacs-bde3c6c0f79ab814e12ea0f04b06625f91f5cd52.tar.gz emacs-bde3c6c0f79ab814e12ea0f04b06625f91f5cd52.zip | |
Fixes related to face underlining
* lisp/faces.el (face-underline-p): Doc fix. Handle :underline being
things other than `t' (a string, a list).
(face-inverse-video-p): Doc fix.
(set-face-underline): Rename it back from set-face-underline-p.
Doc fix. Allow interactive input of values other than t.
(read-face-attribute): Apply formatting to :underline,
since like :box and :stipple it can take list values.
* doc/lispref/display.texi (Face Attributes): Fix :underline COLOR description.
(Attribute Functions): Update for set-face-underline rename.
Tweak descriptions of face-underline-p, face-inverse-video-p.
* etc/NEWS: Related edit.
| -rw-r--r-- | doc/lispref/ChangeLog | 2 | ||||
| -rw-r--r-- | doc/lispref/display.texi | 10 | ||||
| -rw-r--r-- | etc/NEWS | 2 | ||||
| -rw-r--r-- | lisp/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/faces.el | 58 | ||||
| -rw-r--r-- | src/xfaces.c | 8 |
6 files changed, 61 insertions, 27 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index d05f48b9f2d..68d7bee2b64 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | 2012-11-15 Glenn Morris <rgm@gnu.org> | 1 | 2012-11-15 Glenn Morris <rgm@gnu.org> |
| 2 | 2 | ||
| 3 | * display.texi (Face Attributes): Fix :underline COLOR description. | 3 | * display.texi (Face Attributes): Fix :underline COLOR description. |
| 4 | (Attribute Functions): Update for set-face-underline rename. | ||
| 5 | Tweak descriptions of face-underline-p, face-inverse-video-p. | ||
| 4 | 6 | ||
| 5 | 2012-11-14 Glenn Morris <rgm@gnu.org> | 7 | 2012-11-14 Glenn Morris <rgm@gnu.org> |
| 6 | 8 | ||
diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index 6c77a9937d7..9fedd162da6 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi | |||
| @@ -2403,7 +2403,7 @@ This sets the @code{:slant} attribute of @var{face} to @var{normal} if | |||
| 2403 | @var{italic-p} is @code{nil}, and to @var{italic} otherwise. | 2403 | @var{italic-p} is @code{nil}, and to @var{italic} otherwise. |
| 2404 | @end defun | 2404 | @end defun |
| 2405 | 2405 | ||
| 2406 | @defun set-face-underline-p face underline &optional frame | 2406 | @defun set-face-underline face underline &optional frame |
| 2407 | This sets the @code{:underline} attribute of @var{face} to | 2407 | This sets the @code{:underline} attribute of @var{face} to |
| 2408 | @var{underline}. | 2408 | @var{underline}. |
| 2409 | @end defun | 2409 | @end defun |
| @@ -2466,12 +2466,16 @@ attribute of @var{face} is @code{italic} or @code{oblique}, and | |||
| 2466 | @code{nil} otherwise. | 2466 | @code{nil} otherwise. |
| 2467 | @end defun | 2467 | @end defun |
| 2468 | 2468 | ||
| 2469 | @c Note the weasel words. A face that inherits from an underlined | ||
| 2470 | @c face but does not specify :underline will return nil. | ||
| 2469 | @defun face-underline-p face &optional frame | 2471 | @defun face-underline-p face &optional frame |
| 2470 | This function returns the @code{:underline} attribute of face @var{face}. | 2472 | This function returns non-@code{nil} if face @var{face} specifies |
| 2473 | a non-@code{nil} @code{:underline} attribute. | ||
| 2471 | @end defun | 2474 | @end defun |
| 2472 | 2475 | ||
| 2473 | @defun face-inverse-video-p face &optional frame | 2476 | @defun face-inverse-video-p face &optional frame |
| 2474 | This function returns the @code{:inverse-video} attribute of face @var{face}. | 2477 | This function returns non-@code{nil} if face @var{face} specifies |
| 2478 | a non-@code{nil} @code{:inverse-video} attribute. | ||
| 2475 | @end defun | 2479 | @end defun |
| 2476 | 2480 | ||
| 2477 | @node Displaying Faces | 2481 | @node Displaying Faces |
| @@ -948,8 +948,8 @@ takes precedence over most other maps for a short while (normally one key). | |||
| 948 | +++ | 948 | +++ |
| 949 | ** New fringe bitmap `exclamation-mark'. | 949 | ** New fringe bitmap `exclamation-mark'. |
| 950 | 950 | ||
| 951 | +++ | ||
| 951 | ** Face underlining can now use a wave. | 952 | ** Face underlining can now use a wave. |
| 952 | See the "Face Attributes" section of the Elisp manual. | ||
| 953 | 953 | ||
| 954 | ** The following functions and variables are obsolete: | 954 | ** The following functions and variables are obsolete: |
| 955 | --- | 955 | --- |
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 01ccb886434..e53b667b2b2 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,13 @@ | |||
| 1 | 2012-11-15 Glenn Morris <rgm@gnu.org> | 1 | 2012-11-15 Glenn Morris <rgm@gnu.org> |
| 2 | 2 | ||
| 3 | * faces.el (face-underline-p): Doc fix. Handle :underline being | ||
| 4 | things other than `t' (a string, a list). | ||
| 5 | (face-inverse-video-p): Doc fix. | ||
| 6 | (set-face-underline): Rename it back from set-face-underline-p. | ||
| 7 | Doc fix. Allow interactive input of values other than t. | ||
| 8 | (read-face-attribute): Apply formatting to :underline, | ||
| 9 | since like :box and :stipple it can take list values. | ||
| 10 | |||
| 3 | * term.el (ansi-term): Don't let C-x escape-char binding | 11 | * term.el (ansi-term): Don't let C-x escape-char binding |
| 4 | clobber the more standard C-c binding. (Bug#12842) | 12 | clobber the more standard C-c binding. (Bug#12842) |
| 5 | 13 | ||
diff --git a/lisp/faces.el b/lisp/faces.el index f5ef88d08b0..d07c4d6f5a5 100644 --- a/lisp/faces.el +++ b/lisp/faces.el | |||
| @@ -487,16 +487,21 @@ 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). | ||
| 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. | ||
| 490 | (defun face-underline-p (face &optional frame) | 495 | (defun face-underline-p (face &optional frame) |
| 491 | "Return non-nil if FACE is underlined. | 496 | "Return non-nil if FACE specifies a non-nil underlining. |
| 492 | If the optional argument FRAME is given, report on face FACE in that frame. | 497 | If the optional argument FRAME is given, report on face FACE in that frame. |
| 493 | If FRAME is t, report on the defaults for face FACE (for new frames). | 498 | If FRAME is t, report on the defaults for face FACE (for new frames). |
| 494 | If FRAME is omitted or nil, use the selected frame." | 499 | If FRAME is omitted or nil, use the selected frame." |
| 495 | (eq (face-attribute face :underline frame) t)) | 500 | (not (memq (face-attribute face :underline frame) '(unspecified nil)))) |
| 496 | 501 | ||
| 497 | 502 | ||
| 498 | (defun face-inverse-video-p (face &optional frame) | 503 | (defun face-inverse-video-p (face &optional frame) |
| 499 | "Return non-nil if FACE is in inverse video on FRAME. | 504 | "Return non-nil if FACE specifies a non-nil inverse-video. |
| 500 | If the optional argument FRAME is given, report on face FACE in that frame. | 505 | If the optional argument FRAME is given, report on face FACE in that frame. |
| 501 | If FRAME is t, report on the defaults for face FACE (for new frames). | 506 | If FRAME is t, report on the defaults for face FACE (for new frames). |
| 502 | If FRAME is omitted or nil, use the selected frame." | 507 | If FRAME is omitted or nil, use the selected frame." |
| @@ -837,21 +842,24 @@ and DATA is a string, containing the raw bits of the bitmap." | |||
| 837 | (set-face-attribute face frame :stipple (or stipple 'unspecified))) | 842 | (set-face-attribute face frame :stipple (or stipple 'unspecified))) |
| 838 | 843 | ||
| 839 | 844 | ||
| 840 | (defun set-face-underline-p (face underline &optional frame) | 845 | (defun set-face-underline (face underline &optional frame) |
| 841 | "Specify whether face FACE is underlined. | 846 | "Specify whether face FACE is underlined. |
| 842 | UNDERLINE nil means FACE explicitly doesn't underline. | 847 | UNDERLINE nil means FACE explicitly doesn't underline. |
| 843 | UNDERLINE non-nil means FACE explicitly does underlining | 848 | UNDERLINE t means FACE underlines with its foreground color. |
| 844 | with the same of the foreground color. | 849 | If UNDERLINE is a string, underline with that color. |
| 845 | If UNDERLINE is a string, underline with the color named UNDERLINE. | 850 | |
| 851 | UNDERLINE may also be a list of the form (:color COLOR :style STYLE), | ||
| 852 | where COLOR is a string or `foreground-color', and STYLE is either | ||
| 853 | `line' or `wave'. :color may be omitted, which means to use the | ||
| 854 | foreground color. :style may be omitted, which means to use a line. | ||
| 855 | |||
| 846 | FRAME nil or not specified means change face on all frames. | 856 | FRAME nil or not specified means change face on all frames. |
| 847 | Use `set-face-attribute' to ``unspecify'' underlining." | 857 | Use `set-face-attribute' to ``unspecify'' underlining." |
| 848 | (interactive | 858 | (interactive (read-face-and-attribute :underline)) |
| 849 | (let ((list (read-face-and-attribute :underline))) | ||
| 850 | (list (car list) (eq (car (cdr list)) t)))) | ||
| 851 | (set-face-attribute face frame :underline underline)) | 859 | (set-face-attribute face frame :underline underline)) |
| 852 | 860 | ||
| 853 | (define-obsolete-function-alias 'set-face-underline | 861 | (define-obsolete-function-alias 'set-face-underline-p |
| 854 | 'set-face-underline-p "22.1") | 862 | 'set-face-underline "24.3") |
| 855 | 863 | ||
| 856 | 864 | ||
| 857 | (defun set-face-inverse-video-p (face inverse-video-p &optional frame) | 865 | (defun set-face-inverse-video-p (face inverse-video-p &optional frame) |
| @@ -866,6 +874,9 @@ Use `set-face-attribute' to ``unspecify'' the inverse video attribute." | |||
| 866 | (set-face-attribute face frame :inverse-video inverse-video-p)) | 874 | (set-face-attribute face frame :inverse-video inverse-video-p)) |
| 867 | 875 | ||
| 868 | 876 | ||
| 877 | ;; The -p suffix is a hostage to fortune. What if we want to extend | ||
| 878 | ;; this to allow more than boolean options? Exactly this happened | ||
| 879 | ;; to set-face-underline-p. | ||
| 869 | (defun set-face-bold-p (face bold-p &optional frame) | 880 | (defun set-face-bold-p (face bold-p &optional frame) |
| 870 | "Specify whether face FACE is bold. | 881 | "Specify whether face FACE is bold. |
| 871 | BOLD-P non-nil means FACE should explicitly display bold. | 882 | BOLD-P non-nil means FACE should explicitly display bold. |
| @@ -1114,6 +1125,9 @@ name of the attribute for prompting. Value is the new attribute value." | |||
| 1114 | (string-to-number new-value))))) | 1125 | (string-to-number new-value))))) |
| 1115 | 1126 | ||
| 1116 | 1127 | ||
| 1128 | ;; FIXME this does allow you to enter the list forms of :box, | ||
| 1129 | ;; :stipple, or :underline, because face-valid-attribute-values does | ||
| 1130 | ;; not return those forms. | ||
| 1117 | (defun read-face-attribute (face attribute &optional frame) | 1131 | (defun read-face-attribute (face attribute &optional frame) |
| 1118 | "Interactively read a new value for FACE's ATTRIBUTE. | 1132 | "Interactively read a new value for FACE's ATTRIBUTE. |
| 1119 | Optional argument FRAME nil or unspecified means read an attribute value | 1133 | Optional argument FRAME nil or unspecified means read an attribute value |
| @@ -1125,12 +1139,11 @@ of a global face. Value is the new attribute value." | |||
| 1125 | ;; Represent complex attribute values as strings by printing them | 1139 | ;; Represent complex attribute values as strings by printing them |
| 1126 | ;; out. Stipple can be a vector; (WIDTH HEIGHT DATA). Box can be | 1140 | ;; out. Stipple can be a vector; (WIDTH HEIGHT DATA). Box can be |
| 1127 | ;; a list `(:width WIDTH :color COLOR)' or `(:width WIDTH :shadow | 1141 | ;; a list `(:width WIDTH :color COLOR)' or `(:width WIDTH :shadow |
| 1128 | ;; SHADOW)'. | 1142 | ;; SHADOW)'. Underline can be `(:color COLOR :style STYLE)'. |
| 1129 | (when (and (or (eq attribute :stipple) | 1143 | (and (memq attribute '(:box :stipple :underline)) |
| 1130 | (eq attribute :box)) | 1144 | (or (consp old-value) |
| 1131 | (or (consp old-value) | 1145 | (vectorp old-value)) |
| 1132 | (vectorp old-value))) | 1146 | (setq old-value (prin1-to-string old-value))) |
| 1133 | (setq old-value (prin1-to-string old-value))) | ||
| 1134 | (cond ((listp valid) | 1147 | (cond ((listp valid) |
| 1135 | (let ((default | 1148 | (let ((default |
| 1136 | (or (car (rassoc old-value valid)) | 1149 | (or (car (rassoc old-value valid)) |
| @@ -1160,11 +1173,10 @@ of a global face. Value is the new attribute value." | |||
| 1160 | ;; Convert stipple and box value text we read back to a list or | 1173 | ;; Convert stipple and box value text we read back to a list or |
| 1161 | ;; vector if it looks like one. This makes the assumption that a | 1174 | ;; vector if it looks like one. This makes the assumption that a |
| 1162 | ;; pixmap file name won't start with an open-paren. | 1175 | ;; pixmap file name won't start with an open-paren. |
| 1163 | (when (and (or (eq attribute :stipple) | 1176 | (and (memq attribute '(:stipple :box :underline)) |
| 1164 | (eq attribute :box)) | 1177 | (stringp new-value) |
| 1165 | (stringp new-value) | 1178 | (string-match "^[[(]" new-value) |
| 1166 | (string-match "^[[(]" new-value)) | 1179 | (setq new-value (read new-value))) |
| 1167 | (setq new-value (read new-value))) | ||
| 1168 | new-value)) | 1180 | new-value)) |
| 1169 | 1181 | ||
| 1170 | (declare-function fontset-list "fontset.c" ()) | 1182 | (declare-function fontset-list "fontset.c" ()) |
diff --git a/src/xfaces.c b/src/xfaces.c index 221387c4b6d..5eda6dca6da 100644 --- a/src/xfaces.c +++ b/src/xfaces.c | |||
| @@ -2906,6 +2906,12 @@ FRAME 0 means change the face on all frames, and change the default | |||
| 2906 | Lisp_Object key, val, list; | 2906 | Lisp_Object key, val, list; |
| 2907 | 2907 | ||
| 2908 | list = value; | 2908 | list = value; |
| 2909 | /* FIXME? This errs on the side of acceptance. Eg it accepts: | ||
| 2910 | (defface foo '((t :underline 'foo) "doc") | ||
| 2911 | Maybe this is intentional, maybe it isn't. | ||
| 2912 | Non-nil symbols other than t are not documented as being valid. | ||
| 2913 | Eg compare with inverse-video, which explicitly rejects them. | ||
| 2914 | */ | ||
| 2909 | valid_p = 1; | 2915 | valid_p = 1; |
| 2910 | 2916 | ||
| 2911 | while (!NILP (CAR_SAFE(list))) | 2917 | while (!NILP (CAR_SAFE(list))) |
| @@ -5727,6 +5733,8 @@ realize_x_face (struct face_cache *cache, Lisp_Object attrs[LFACE_VECTOR_SIZE]) | |||
| 5727 | face->underline_defaulted_p = 1; | 5733 | face->underline_defaulted_p = 1; |
| 5728 | face->underline_type = FACE_UNDER_LINE; | 5734 | face->underline_type = FACE_UNDER_LINE; |
| 5729 | 5735 | ||
| 5736 | /* FIXME? This is also not robust about checking the precise form. | ||
| 5737 | See comments in Finternal_set_lisp_face_attribute. */ | ||
| 5730 | while (CONSP (underline)) | 5738 | while (CONSP (underline)) |
| 5731 | { | 5739 | { |
| 5732 | Lisp_Object keyword, value; | 5740 | Lisp_Object keyword, value; |