[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/lin 52fbd27a29 15/46: Document face customisation for m
From: |
ELPA Syncer |
Subject: |
[elpa] externals/lin 52fbd27a29 15/46: Document face customisation for macOS |
Date: |
Thu, 7 Apr 2022 23:57:45 -0400 (EDT) |
branch: externals/lin
commit 52fbd27a29be344a94538b6843754b68c8f41704
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Document face customisation for macOS
Thanks to Christian Tietze for the feedback in issue 2:
<https://gitlab.com/protesilaos/lin/-/issues/2>.
---
README.org | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 72 insertions(+), 1 deletion(-)
diff --git a/README.org b/README.org
index 88580c79d9..f2bcb48ff6 100644
--- a/README.org
+++ b/README.org
@@ -183,6 +183,77 @@ switching between Modus Operandi and Vivendi):
:underline (modus-themes-color 'green-intense))
#+end_src
+** Use system colors on macOS
+:PROPERTIES:
+:CUSTOM_ID: h:6bb11a50-cca9-49ca-9ea0-9d26c9324068
+:END:
+
+On macOS, it is possible to use named system colors. For a list of
+available colors, see Apple's Human Interface Guidelines:
+https://developer.apple.com/design/human-interface-guidelines/macos/visual-design/color/
+
+To use macOS's named colors for selections as LIN's background and
+foreground instead of specifying color values directly, tweak the two
+LIN faces:
+
+#+begin_src emacs-lisp
+(when (memq window-system '(mac ns))
+ (set-face-attribute 'lin-hl nil
+ :background "selectedContentBackgroundColor")
+
+ ;; To also override the foreground (see `lin-override-foreground'):
+ (set-face-attribute 'lin-hl-override-fg nil
+ :foreground "alternateSelectedControlTextColor"
+ :background "selectedContentBackgroundColor"))
+#+end_src
+
+Note that these named colors are "Dynamic System Colors": in dark
+mode, they produce a different value than in light mode. That means
+you don't need to pick dark and light colors individually. The same
+color names will work.
+
+However, you need to trigger an update of LIN's faces to pick up the
+color values if you change the appearance from dark to light, or light
+to dark. macOS builds of Emacs have a hook for this, and you can
+perform a color update by adding a function to
+~ns-system-appearance-change-functions~:
+
+#+begin_src emacs-lisp
+(defun my-lin-macos-system-colors ()
+ (when (memq window-system '(mac ns))
+ (set-face-attribute 'lin-hl nil
+ :background "selectedContentBackgroundColor")
+
+ ;; To also override the foreground (see `lin-override-foreground'):
+ (set-face-attribute 'lin-hl-override-fg nil
+ :foreground "alternateSelectedControlTextColor"
+ :background "selectedContentBackgroundColor")))
+
+(when (memq window-system '(mac ns))
+ (add-hook 'ns-system-appearance-change-functions
#'my-lin-macos-system-colors))
+#+end_src
+
+If you want to use a different color than the macOS selection colors
+in dark mode, you can tweak this approach:
+
+#+begin_src emacs-lisp
+(defun my-lin--macos-mode-color (light dark)
+ "Use LIGHT or DARK color value, depending on macOS mode."
+ (if (eq ns-system-appearance 'light)
+ light
+ dark))
+
+(defun my-lin-custom-faces ()
+ (when (memq window-system '(mac ns))
+ (let ((bg (my-lin--macos-mode-color "selectedContentBackgroundColor"
"#2a40b8"))
+ (fg (my-lin--macos-mode-color "alternateSelectedControlTextColor"
"#ffffff")))
+ (set-face-attribute 'lin-hl nil :background bg)
+ (set-face-attribute 'lin-hl-override-fg nil :background bg :foreground
fg))))
+
+(when (memq window-system '(mac ns))
+ (add-hook 'ns-system-appearance-change-functions #'my-lin-custom-faces))
+#+end_src
+
* Acknowledgements
:PROPERTIES:
:CUSTOM_ID: h:0f80e78f-d6b3-42cd-8e49-7ac47fd2fa96
@@ -195,7 +266,7 @@ LIN is meant to be a collective effort. Every bit of help
matters.
+ Contributions to code or documentation :: Nicolas De Jaeghere.
-+ Ideas and user feedback :: Nicolas De Jaeghere.
++ Ideas and user feedback :: Christian Tietze, Nicolas De Jaeghere.
* GNU Free Documentation License
:PROPERTIES:
- [elpa] externals/lin fb32511d20 08/46: Add Acknowledgements to the manual, (continued)
- [elpa] externals/lin fb32511d20 08/46: Add Acknowledgements to the manual, ELPA Syncer, 2022/04/07
- [elpa] externals/lin 8aa367ec86 13/46: Merge branch 'various' into 'main', ELPA Syncer, 2022/04/07
- [elpa] externals/lin e5a0da969e 20/46: Add function lin-add-to-many-modes and option lin-foreign-hooks (#3), ELPA Syncer, 2022/04/07
- [elpa] externals/lin a85b9da0d1 21/46: Merge branch 'lin-add-to-many-modes' into 'main', ELPA Syncer, 2022/04/07
- [elpa] externals/lin 69321c759a 22/46: Update manual's Acknowledgements, ELPA Syncer, 2022/04/07
- [elpa] externals/lin 307c19f2e3 27/46: Remove needless 'when', ELPA Syncer, 2022/04/07
- [elpa] externals/lin ea1275a282 02/46: Fix typo, ELPA Syncer, 2022/04/07
- [elpa] externals/lin df19fb1108 09/46: Fix disabling mode, ELPA Syncer, 2022/04/07
- [elpa] externals/lin aa42c93609 11/46: Support mu4e-headers-mode, ELPA Syncer, 2022/04/07
- [elpa] externals/lin c3bfd5c300 12/46: Tweak whitespace, ELPA Syncer, 2022/04/07
- [elpa] externals/lin 52fbd27a29 15/46: Document face customisation for macOS,
ELPA Syncer <=
- [elpa] externals/lin 067e7bcf6b 18/46: Update manual's acknowledgements section, ELPA Syncer, 2022/04/07
- [elpa] externals/lin 0f84a094a9 26/46: Add ilist-mode-hook to default foreign hooks, ELPA Syncer, 2022/04/07
- [elpa] externals/lin 3a916a795b 46/46: Update URL in sample code, ELPA Syncer, 2022/04/07
- [elpa] externals/lin dc41e4abec 31/46: Fix punctuation in doc string, ELPA Syncer, 2022/04/07
- [elpa] externals/lin aff58aeec5 34/46: Use correct key for local minor-mode, ELPA Syncer, 2022/04/07
- [elpa] externals/lin dd497be016 33/46: Clarify doc string, ELPA Syncer, 2022/04/07
- [elpa] externals/lin edc29c2afe 45/46: Upgrade to version 0.3.0, ELPA Syncer, 2022/04/07
- [elpa] externals/lin 3dc1ee3f6f 40/46: Make lin-setup obsolete alias of lin--setup, ELPA Syncer, 2022/04/07
- [elpa] externals/lin 4f3c872f28 42/46: Tweak doc string of lin-enable-mode-in-buffers, ELPA Syncer, 2022/04/07