[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/compat 441539ae8b 11/27: Add face-spec-set
From: |
ELPA Syncer |
Subject: |
[elpa] externals/compat 441539ae8b 11/27: Add face-spec-set |
Date: |
Sat, 5 Mar 2022 04:57:27 -0500 (EST) |
branch: externals/compat
commit 441539ae8badc212444cb683f06297c6eb195914
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Philip Kaludercic <philipk@posteo.net>
Add face-spec-set
---
MANUAL | 1 +
compat-24.el | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 52 insertions(+)
diff --git a/MANUAL b/MANUAL
index 2421779067..6aa23fc97e 100644
--- a/MANUAL
+++ b/MANUAL
@@ -119,6 +119,7 @@ provided by compat by default:
- Function ~completion-table-merge~ :: See [[info:elisp#Basic
Completion][(elisp) Basic Completion]].
- Function ~completion-table-with-cache~ :: See [[info:elisp#Programmed
Completion][(elisp) Programmed
Completion]].
+- Function ~face-spec-set~ :: See [[info:elisp#Defining Faces][(elisp)
Defining Faces]].
These functions are prefixed with ~compat~ prefix, and are only loaded
when ~compat-24~ is required:
diff --git a/compat-24.el b/compat-24.el
index 29b5a1e22e..80dac0e309 100644
--- a/compat-24.el
+++ b/compat-24.el
@@ -453,5 +453,56 @@ carriage return."
(substring string 0 (- (length string) (length suffix)))
string))
+;;;; Defined in faces.el
+
+(compat-defun face-spec-set (face spec &optional spec-type)
+ "Set the FACE's spec SPEC, define FACE, and recalculate its attributes.
+See `defface' for the format of SPEC.
+
+The appearance of each face is controlled by its specs (set via
+this function), and by the internal frame-specific face
+attributes (set via `set-face-attribute').
+
+This function also defines FACE as a valid face name if it is not
+already one, and (re)calculates its attributes on existing
+frames.
+
+The optional argument SPEC-TYPE determines which spec to set:
+ nil, omitted or `face-override-spec' means the override spec,
+ which overrides all the other types of spec mentioned below
+ (this is usually what you want if calling this function
+ outside of Custom code);
+ `customized-face' or `saved-face' means the customized spec or
+ the saved custom spec;
+ `face-defface-spec' means the default spec
+ (usually set only via `defface');
+ `reset' means to ignore SPEC, but clear the `customized-face'
+ and `face-override-spec' specs;
+Any other value means not to set any spec, but to run the
+function for defining FACE and recalculating its attributes."
+ :version "24.4"
+ (if (get face 'face-alias)
+ (setq face (get face 'face-alias)))
+ ;; Save SPEC to the relevant symbol property.
+ (unless spec-type
+ (setq spec-type 'face-override-spec))
+ (if (memq spec-type '(face-defface-spec face-override-spec
+ customized-face saved-face))
+ (put face spec-type spec))
+ (if (memq spec-type '(reset saved-face))
+ (put face 'customized-face nil))
+ ;; Setting the face spec via Custom empties out any override spec,
+ ;; similar to how setting a variable via Custom changes its values.
+ (if (memq spec-type '(customized-face saved-face reset))
+ (put face 'face-override-spec nil))
+ ;; If we reset the face based on its custom spec, it is unmodified
+ ;; as far as Custom is concerned.
+ (unless (eq face 'face-override-spec)
+ (put face 'face-modified nil))
+ ;; Initialize the face if it does not exist, then recalculate.
+ (make-empty-face face)
+ (dolist (frame (frame-list))
+ (face-spec-recalc face frame)))
+
(provide 'compat-24)
;;; compat-24.el ends here
- [elpa] externals/compat e4db344ed5 01/27: Add MANUAL, (continued)
- [elpa] externals/compat e4db344ed5 01/27: Add MANUAL, ELPA Syncer, 2022/03/05
- [elpa] externals/compat f475f8027b 08/27: Set compat--generate-function globally when loading compat-tests, ELPA Syncer, 2022/03/05
- [elpa] externals/compat 511801e28f 02/27: Fix typo in README, ELPA Syncer, 2022/03/05
- [elpa] externals/compat 0706a69997 04/27: Avoid using gensym in with-existing-directory, ELPA Syncer, 2022/03/05
- [elpa] externals/compat 28a6e2db53 06/27: Remove unnecessary whitespace before closing parentheses, ELPA Syncer, 2022/03/05
- [elpa] externals/compat 26ee17853e 07/27: Add bool-vector functions, ELPA Syncer, 2022/03/05
- [elpa] externals/compat efb9ff712a 10/27: Add completion-table-merge and completion-table-with-cache, ELPA Syncer, 2022/03/05
- [elpa] externals/compat 4aca90834f 09/27: Add get-pos-property to missing functions in 24.4, ELPA Syncer, 2022/03/05
- [elpa] externals/compat 3f511afce0 12/27: Add directory-files-recursively, ELPA Syncer, 2022/03/05
- [elpa] externals/compat efa6e171e5 13/27: Document define-advice as not implemented, ELPA Syncer, 2022/03/05
- [elpa] externals/compat 441539ae8b 11/27: Add face-spec-set,
ELPA Syncer <=
- [elpa] externals/compat b3b75333b1 14/27: Document generators as not implemented, ELPA Syncer, 2022/03/05
- [elpa] externals/compat c4893fa014 15/27: Document bufferpos-to-filepos as not implemented, ELPA Syncer, 2022/03/05
- [elpa] externals/compat 35072b3d25 22/27: Fix if-let and add tests, ELPA Syncer, 2022/03/05
- [elpa] externals/compat ece91a5b89 03/27: Add function-put, ELPA Syncer, 2022/03/05
- [elpa] externals/compat 9034bcc0ac 05/27: Fix broken markup in some deftest docstrings, ELPA Syncer, 2022/03/05
- [elpa] externals/compat c8bc47b671 18/27: Add replace-string-in-region, ELPA Syncer, 2022/03/05
- [elpa] externals/compat a92aec7251 19/27: Add file-modes-number-to-symbolic, ELPA Syncer, 2022/03/05
- [elpa] externals/compat ba2918d6d3 21/27: Add file-backup-file-names, ELPA Syncer, 2022/03/05
- [elpa] externals/compat 15ca463a9e 20/27: Document that null-device and path-separator are not implemented, ELPA Syncer, 2022/03/05
- [elpa] externals/compat 6b14d5fa3b 24/27: Exclude the generated manual from the repository, ELPA Syncer, 2022/03/05