branch: externals/face-shift
commit 547ec4e6b20e99cfe7b1f9576d1e1f402a52661f
Author: Philip K <[email protected]>
Commit: Philip K <[email protected]>
fixed packaging issues
---
face-shift.el | 68 ++++++++++++++++++++++++++++++++++++++++++++---------------
1 file changed, 51 insertions(+), 17 deletions(-)
diff --git a/face-shift.el b/face-shift.el
index 2a08be1034..a424578ea8 100644
--- a/face-shift.el
+++ b/face-shift.el
@@ -1,18 +1,46 @@
-;;; -*- lexical-binding: t -*-
-;;; published under CC0 into the public domain
-;;; author: philip k. [https://zge.us.to], 2019
+;;; face-shift.el --- shift the color of certain faces -*- lexical-binding: t
-*-
+
+;; Author: Philip K. <[email protected]>
+;; Version: 0.1.0
+;; Keywords: c, abbrev, convenience
+;; Package-Requires: ((emacs "24"))
+;; URL: https://git.sr.ht/~zge/face-shift
+
+;; This file is NOT part of Emacs.
+;;
+;; This file is in the public domain, to the extent possible under law,
+;; published under the CC0 1.0 Universal license.
+;;
+;; For a full copy of the CC0 license see
+;; https://creativecommons.org/publicdomain/zero/1.0/legalcode
+
+;;; Commentary:
+;;
+;; `face-shift-by' generates a function that linearly shifts all faces
+;; in `face-shift-faces'.
+;;
+;; To use face shift, add a function generated by `face-shift' to a hook
+;; of your choice like so:
+;;
+;; (add-hook 'prog-mode-hook (face-shift 'green))
+;;
+;; or optionally save the generated function in a variable before adding
+;; it.
(require 'color)
(eval-when-compile (require 'cl-lib))
+;;; Code:
+
(defgroup face-shift nil
- "Distort colours of certain faces"
+ "Distort colours of certain faces."
:group 'faces
:prefix "face-shift-")
(defcustom face-shift-force-fit nil
- "Make sure that all transformations stay in the RGB-unit-space,
-by wrapping values over 1 to 1."
+ "Ensure transformations stay in RGB-unit-space.
+
+This will be done by wrapping values over 1.0 to 1.0."
:type 'boolean
:group 'face-shift)
@@ -38,10 +66,10 @@ by wrapping values over 1 to 1."
(peach . ((max min min) (min int min) (min min int)))
(green . ((int min min) (min max min) (min min int)))
(purple . ((int min min) (min int min) (min min max))))
- "Alist of matrices representing RGB transformations towards a
- certain hue. Symbols `int', `max' and `min' are substituted
- with `face-shift-intensity', `face-shift-maximum' and
- `face-shift-minimum' respectively."
+ "Alist of matrices representing RGB transformations.
+Symbols `int', `max' and `min' are substituted with
+`face-shift-intensity', `face-shift-maximum' and
+`face-shift-minimum' respectively."
:type '(list (list symbol))
:group 'face-shift)
@@ -57,8 +85,9 @@ by wrapping values over 1 to 1."
:group 'face-shift)
(defun face-shift-by (face prop mat)
- "Call `face-remap-add-relative' on FACE by distorting the
-colour behind PROP by MAT in an RGB colour space."
+ "Calculate colour distortion and apply to property PROP of FACE.
+MAT describes the linear transformation that calculates the new
+colour. If property PROP is not a color, nothing is changed."
(let* ((mvp (lambda (vec)
(mapcar (lambda (row)
(apply #'+ (cl-mapcar #'* row vec)))
@@ -80,10 +109,13 @@ colour behind PROP by MAT in an RGB colour space."
ncolor))
(defun face-shift (color &optional ignore)
- "Produce a function that will shift all background and
-foreground colours behind the faces listed in `face-shift-faces',
-that can then be added to a hook. COLOR should index a
-transformation from the `face-shift-colors' alist.
+ "Produce a function that will shift face colors.
+
+All background and foreground colours behind the faces listed in
+`face-shift-faces' will be attempted to shift using
+`face-shift-by'. The generated function can then be added to a
+hook. COLOR should index a transformation from the
+`face-shift-colors' alist.
If IGNORE is non-nil, it has to be a list of modes that should be
ignored by this hook. For example
@@ -91,7 +123,7 @@ ignored by this hook. For example
(face-shift 'green '(mail-mode))
will apply the green shift, unless the mode of the hook it was
-added to is mail-mode or a derivative."
+added to is ‘mail-mode’ or a derivative."
(let ((mat (cl-sublis
`((int . ,face-shift-intensity)
(max . ,face-shift-maximum)
@@ -104,3 +136,5 @@ added to is mail-mode or a derivative."
(face-shift-by face :background mat))))))
(provide 'face-shift)
+
+;;; face-shift.el ends here