From 389de6e59c5e168a4e4e0d01b062ed4b16b30d04 Mon Sep 17 00:00:00 2001 From: Gerard Vermeulen Date: Tue, 25 Jan 2022 15:28:39 +0100 Subject: [PATCH] Handle also faces after loading in memory --- README.org | 61 +++++++++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/README.org b/README.org index bd4e497..ac83b36 100644 --- a/README.org +++ b/README.org @@ -263,43 +263,41 @@ the ~custom-file~ as [[info:emacs#Saving Customizations][saving customizations ( :END: Section [[#sec:text-faces-or-styles][text faces or styles (info)]] tells that this setup does not use theming. -However, it relies on shadowing the definition of faces in order to improve -visibility. The last item in the page on [[https://orgmode.org/worg/org-contrib/babel/examples/fontify-src-code-blocks.html#org5c4406f][fontifying source code blocks]] -describes this method. Section [[#sec:text-faces-or-styles][text faces or styles (info)]] also defines the -function src_emacs-lisp{(my-invert-default-face)} to toggle between a dark and a -light background. +However, in order to improve visibility, it relies on: +1. Tweaking faces in memory after loading as in listing + [[lst:tweak-faces-faces-after]]. +2. Shadowing the definition of faces before loading as in listing + [[lst:tweak-org-faces-before]] and [[lst:tweak-sh-script-faces-before]]. The last + item in the page on [[https://orgmode.org/worg/org-contrib/babel/examples/fontify-src-code-blocks.html#org5c4406f][fontifying Org mode source code blocks]] describes this + method. +Section [[#sec:text-faces-or-styles][text faces or styles (info)]] also defines the function +src_emacs-lisp{(my-invert-default-face)} to toggle between a dark and a light +background. #+caption[Improve the visibility of faces in =faces.el=]: #+caption: Improve the visibility of faces in =faces.el=. -#+name: lst:tweak-faces-faces-early +#+name: lst:tweak-faces-faces-after #+begin_src emacs-lisp - ;; Shadow the definition in faces.el: - (defface region - '((((class color) (min-colors 88) (background dark)) - :background "blue3" :extend t) - (((class color) (min-colors 88) (background light) (type gtk)) - :distant-foreground "gtk_selection_fg_color" - :background "LightGoldenrod2" :extend t) - (((class color) (min-colors 88) (background light) (type ns)) - :distant-foreground "ns_selection_fg_color" - :background "ns_selection_bg_color" :extend t) - (((class color) (min-colors 88) (background light)) - :background "LightGoldenrod2" :extend t) - (((class color) (min-colors 16) (background dark)) - :background "blue3" :extend t) - (((class color) (min-colors 16) (background light)) - :background "LightGoldenrod2" :extend t) - (((class color) (min-colors 8)) - :background "blue" :foreground "white" :extend t) - (((type tty) (class mono)) - :inverse-video t) - (t :background "gray" :extend t)) - "My basic face for highlighting the region.") + (defun tweak-region-face-background-color () + (when (featurep 'gtk) + (set-face-attribute + 'region nil + :background (cdr (assoc (face-attribute 'default :background) + '(("white" . "LightGoldenrod2") + ("black" . "blue3"))))))) + + (tweak-region-face-background-color) +#+end_src + +#+begin_src emacs-lisp + (cdr (assoc (face-attribute 'default :background) + '(("white" . "LightGoldenrod2") + ("black" . "blue3")))) #+end_src #+caption[Improve the visibility of faces in =org-faces.el=]: #+caption: Improve the visibility of faces in =org-faces.el=. -#+name: lst:tweak-org-faces-early +#+name: lst:tweak-org-faces-before #+begin_src emacs-lisp ;; Shadow the definition in org-faces.el: (defface org-block @@ -326,7 +324,7 @@ light background. #+caption[Improve the visibility of faces in =sh-script.el=]: #+caption: Improve the visibility of faces in =sh-script.el=. -#+name: lst:tweak-sh-script-faces-early +#+name: lst:tweak-sh-script-faces-before #+begin_src emacs-lisp ;; Shadow the definition in sh-script.el: (defface sh-heredoc @@ -2665,7 +2663,8 @@ of the default face on all frames. (defun my-invert-default-face () "Invert the default face." (interactive) - (invert-face 'default))) + (invert-face 'default) + (tweak-region-face-background-color))) #+end_src ** [[https://jblevins.org/log/rainbow-mode][Visualize color codes and names]]