aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiles Bader2000-08-26 10:59:51 +0000
committerMiles Bader2000-08-26 10:59:51 +0000
commit19feb949cea546fbc21e9efd65ad4cd69d097c29 (patch)
tree4edc21a1a3afdd295913e12d4744ad11b80fa15d
parent7c100e1a3f7be805319c41a5bb1a4d3896b92158 (diff)
downloademacs-19feb949cea546fbc21e9efd65ad4cd69d097c29.tar.gz
emacs-19feb949cea546fbc21e9efd65ad4cd69d097c29.zip
(set-face-attribute):
Update doc string. (face-attribute-name-alist): Add :inherit. (face-valid-attribute-values): Handle :inherit. (face-read-string): Rephrase prompt to be less confusing. Assume that DEFAULT is a string, since we must return a string. (face-read-integer): Use `format' to turn DEFAULT into an acceptable default for face-read-string. Match NEW-VALUE against the string "unspecified", not the symbol `unspecified', since that's what face-read-string returns. (read-face-attribute): Lookup a name for old-value in valid, and use it as a default if we find one. Treat all values from face-read-string as strings. If the default is used, don't do any more processing on the value, just use the old value directly. (read-face-and-attribute, modify-face): Tweak prompt. (read-face-name): Don't assume prompt ends with a space.
-rw-r--r--lisp/ChangeLog16
-rw-r--r--lisp/faces.el101
2 files changed, 76 insertions, 41 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index d55b156b1ad..6766a049f21 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,21 @@
12000-08-26 Miles Bader <miles@gnu.org> 12000-08-26 Miles Bader <miles@gnu.org>
2 2
3 * faces.el (set-face-attribute): Update doc string.
4 (face-attribute-name-alist): Add :inherit.
5 (face-valid-attribute-values): Handle :inherit.
6 (face-read-string): Rephrase prompt to be less confusing.
7 Assume that DEFAULT is a string, since we must return a string.
8 (face-read-integer): Use `format' to turn DEFAULT into an
9 acceptable default for face-read-string. Match NEW-VALUE against
10 the string "unspecified", not the symbol `unspecified', since
11 that's what face-read-string returns.
12 (read-face-attribute): Lookup a name for old-value in valid, and
13 use it as a default if we find one. Treat all values from
14 face-read-string as strings. If the default is used, don't do any
15 more processing on the value, just use the old value directly.
16 (read-face-and-attribute, modify-face): Tweak prompt.
17 (read-face-name): Don't assume prompt ends with a space.
18
3 * faces.el (describe-face): Add support for :inherit attribute. 19 * faces.el (describe-face): Add support for :inherit attribute.
4 20
52000-08-25 Kenichi Handa <handa@etl.go.jp> 212000-08-25 Kenichi Handa <handa@etl.go.jp>
diff --git a/lisp/faces.el b/lisp/faces.el
index cff3810219d..c8d58621fd1 100644
--- a/lisp/faces.el
+++ b/lisp/faces.el
@@ -451,8 +451,10 @@ It must be one of the symbols `ultra-condensed', `extra-condensed',
451 451
452`:height' 452`:height'
453 453
454VALUE must be an integer specifying the height of the font to use in 454VALUE must be either an integer specifying the height of the font to use
4551/10 pt. 455in 1/10 pt, a floating point number specifying the amount by which to
456scale any underlying face, or a function, which is called with the old
457height (from the underlying face), and should return the new height.
456 458
457`:weight' 459`:weight'
458 460
@@ -536,7 +538,13 @@ will be used.
536 538
537For compatibility with Emacs 20, keywords `:bold' and `:italic' can 539For compatibility with Emacs 20, keywords `:bold' and `:italic' can
538be used to specify that a bold or italic font should be used. VALUE 540be used to specify that a bold or italic font should be used. VALUE
539must be t or nil in that case. A value of `unspecified' is not allowed." 541must be t or nil in that case. A value of `unspecified' is not allowed.
542
543`:inherit'
544
545VALUE is the name of a face from which to inherit attributes, or a list
546of face names. Attributes from inherited faces are merged into the face
547like an underlying face would be, with higher priority than underlying faces."
540 (setq args (purecopy args)) 548 (setq args (purecopy args))
541 (cond ((null frame) 549 (cond ((null frame)
542 ;; Change face on all frames. 550 ;; Change face on all frames.
@@ -731,7 +739,7 @@ Value is a symbol naming a known face."
731 (def (thing-at-point 'symbol)) 739 (def (thing-at-point 'symbol))
732 face) 740 face)
733 (cond ((assoc def face-list) 741 (cond ((assoc def face-list)
734 (setq prompt (concat prompt "(default " def "): "))) 742 (setq prompt (concat prompt " (default " def "): ")))
735 (t (setq def nil) 743 (t (setq def nil)
736 (setq prompt (concat prompt ": ")))) 744 (setq prompt (concat prompt ": "))))
737 (while (equal "" (setq face (completing-read 745 (while (equal "" (setq face (completing-read
@@ -776,9 +784,13 @@ an integer value."
776 (mapcar #'list 784 (mapcar #'list
777 (apply #'nconc (mapcar #'directory-files 785 (apply #'nconc (mapcar #'directory-files
778 x-bitmap-file-path))))) 786 x-bitmap-file-path)))))
787 (:inherit
788 (cons '("none" . nil)
789 (mapcar #'(lambda (c) (cons (symbol-name c) c))
790 (face-list))))
779 (t 791 (t
780 (error "Internal error")))) 792 (error "Internal error"))))
781 (if (listp valid) 793 (if (and (listp valid) (not (memq attribute '(:inherit))))
782 (nconc (list (cons "unspecified" 'unspecified)) valid) 794 (nconc (list (cons "unspecified" 'unspecified)) valid)
783 valid))) 795 valid)))
784 796
@@ -797,7 +809,8 @@ an integer value."
797 (:inverse-video . "inverse-video display") 809 (:inverse-video . "inverse-video display")
798 (:foreground . "foreground color") 810 (:foreground . "foreground color")
799 (:background . "background color") 811 (:background . "background color")
800 (:stipple . "background stipple")) 812 (:stipple . "background stipple")
813 (:inherit . "inheritance"))
801 "An alist of descriptive names for face attributes. 814 "An alist of descriptive names for face attributes.
802Each element has the form (ATTRIBUTE-NAME . DESCRIPTION) where 815Each element has the form (ATTRIBUTE-NAME . DESCRIPTION) where
803ATTRIBUTE-NAME is a face attribute name (a keyword symbol), and 816ATTRIBUTE-NAME is a face attribute name (a keyword symbol), and
@@ -811,21 +824,22 @@ DESCRIPTION is a descriptive name for ATTRIBUTE-NAME.")
811 824
812(defun face-read-string (face default name &optional completion-alist) 825(defun face-read-string (face default name &optional completion-alist)
813 "Interactively read a face attribute string value. 826 "Interactively read a face attribute string value.
814FACE is the face whose attribute is read. DEFAULT is the default 827FACE is the face whose attribute is read. If non-nil, DEFAULT is the
815value to return if no new value is entered. NAME is a descriptive 828default string to return if no new value is entered. NAME is a
816name of the attribute for prompting. COMPLETION-ALIST is an alist 829descriptive name of the attribute for prompting. COMPLETION-ALIST is an
817of valid values, if non-nil. 830alist of valid values, if non-nil.
818 831
819Entering nothing accepts the default value DEFAULT. 832Entering nothing accepts the default string DEFAULT.
820Value is the new attribute value." 833Value is the new attribute value."
834 ;; Capitalize NAME (we don't use `capitalize' because that capitalizes
835 ;; each word in a string separately).
836 (setq name (concat (upcase (substring name 0 1)) (substring name 1)))
821 (let* ((completion-ignore-case t) 837 (let* ((completion-ignore-case t)
822 (value (completing-read 838 (value (completing-read
823 (if default 839 (if default
824 (format "Set face %s %s (default %s): " 840 (format "%s for face `%s' (default %s): "
825 face name (downcase (if (symbolp default) 841 name face default)
826 (symbol-name default) 842 (format "%s for face `%s': " name face))
827 default)))
828 (format "Set face %s %s: " face name))
829 completion-alist))) 843 completion-alist)))
830 (if (equal value "") default value))) 844 (if (equal value "") default value)))
831 845
@@ -837,17 +851,15 @@ value to return if no new value is entered. NAME is a descriptive
837name of the attribute for prompting. Value is the new attribute value." 851name of the attribute for prompting. Value is the new attribute value."
838 (let ((new-value 852 (let ((new-value
839 (face-read-string face 853 (face-read-string face
840 (if (memq default 854 (format "%s" default)
841 '(unspecified
842 "unspecified-fg"
843 "unspecified-bg"))
844 default
845 (int-to-string default))
846 name 855 name
847 (list (cons "unspecified" 'unspecified))))) 856 (list (cons "unspecified" 'unspecified)))))
848 (if (memq new-value '(unspecified "unspecified-fg" "unspecified-bg")) 857 (cond ((equal new-value "unspecified")
849 new-value 858 'unspecified)
850 (string-to-int new-value)))) 859 ((member new-value '("unspecified-fg" "unspecified-bg"))
860 new-value)
861 (t
862 (string-to-int new-value)))))
851 863
852 864
853(defun read-face-attribute (face attribute &optional frame) 865(defun read-face-attribute (face attribute &optional frame)
@@ -868,20 +880,27 @@ of a global face. Value is the new attribute value."
868 (vectorp old-value))) 880 (vectorp old-value)))
869 (setq old-value (prin1-to-string old-value))) 881 (setq old-value (prin1-to-string old-value)))
870 (cond ((listp valid) 882 (cond ((listp valid)
871 (setq new-value 883 (let ((default
872 (face-read-string face old-value attribute-name valid)) 884 (or (car (rassoc old-value valid))
873 ;; Terminal frames can support colors that don't appear 885 (format "%s" old-value))))
874 ;; explicitly in VALID, using color approximation code 886 (setq new-value
875 ;; in tty-colors.el. 887 (face-read-string face default attribute-name valid))
876 (if (and (memq attribute '(:foreground :background)) 888 (if (equal new-value default)
877 (not (memq window-system '(x w32 mac))) 889 ;; Nothing changed, so don't bother with all the stuff
878 (not (memq new-value 890 ;; below. In particular, this avoids a non-tty color
879 '(unspecified 891 ;; from being canonicalized for a tty when the user
880 "unspecified-fg" 892 ;; just uses the default.
881 "unspecified-bg")))) 893 (setq new-value old-value)
882 (setq new-value (car (tty-color-desc new-value frame)))) 894 ;; Terminal frames can support colors that don't appear
883 (unless (eq new-value 'unspecified) 895 ;; explicitly in VALID, using color approximation code
884 (setq new-value (cdr (assoc new-value valid))))) 896 ;; in tty-colors.el.
897 (if (and (memq attribute '(:foreground :background))
898 (not (memq window-system '(x w32 mac)))
899 (not (member new-value
900 '("unspecified"
901 "unspecified-fg" "unspecified-bg"))))
902 (setq new-value (car (tty-color-desc new-value frame))))
903 (setq new-value (cdr (assoc new-value valid))))))
885 ((eq valid 'integerp) 904 ((eq valid 'integerp)
886 (setq new-value (face-read-integer face old-value attribute-name))) 905 (setq new-value (face-read-integer face old-value attribute-name)))
887 (t (error "Internal error"))) 906 (t (error "Internal error")))
@@ -920,7 +939,7 @@ Value is a property list of attribute names and new values."
920If optional argument FRAME is nil or omitted, modify the face used 939If optional argument FRAME is nil or omitted, modify the face used
921for newly created frame, i.e. the global face." 940for newly created frame, i.e. the global face."
922 (interactive) 941 (interactive)
923 (let ((face (read-face-name "Modify face "))) 942 (let ((face (read-face-name "Modify face")))
924 (apply #'set-face-attribute face frame 943 (apply #'set-face-attribute face frame
925 (read-all-face-attributes face frame)))) 944 (read-all-face-attributes face frame))))
926 945
@@ -938,7 +957,7 @@ Value is a list (FACE NEW-VALUE) where FACE is the face read
938 (list face font))) 957 (list face font)))
939 (t 958 (t
940 (let* ((attribute-name (face-descriptive-attribute-name attribute)) 959 (let* ((attribute-name (face-descriptive-attribute-name attribute))
941 (prompt (format "Set %s of face " attribute-name)) 960 (prompt (format "Set %s of face" attribute-name))
942 (face (read-face-name prompt)) 961 (face (read-face-name prompt))
943 (new-value (read-face-attribute face attribute frame))) 962 (new-value (read-face-attribute face attribute frame)))
944 (list face new-value))))) 963 (list face new-value)))))