Handle also faces after loading in memory

This commit is contained in:
Gerard Vermeulen 2022-01-25 15:28:39 +01:00
parent 23a7b713df
commit 389de6e59c
1 changed files with 30 additions and 31 deletions

View File

@ -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]]