Reorganize the two sections on text faces

This commit is contained in:
Gerard Vermeulen 2022-03-26 15:41:37 +01:00
parent c0c43c78e1
commit 41d12be70c

View File

@ -281,17 +281,16 @@ the ~custom-file~ as [[info:emacs#Saving Customizations][saving customizations (
:CUSTOM_ID: sec:text-faces-or-look :CUSTOM_ID: sec:text-faces-or-look
:END: :END:
Section [[#sec:text-faces-or-styles][text faces or styles (info)]] tells that this setup does not use theming. Section [[#sec:text-faces-or-styles][text faces or styles]] tells that this setup does not use theming.
However, in order to improve visibility, it relies on: However, in order to improve visibility, it relies on:
1. Tweaking faces in memory after loading as in listing 1. Tweaking faces in memory after loading as in listing
[[lst:tweak-faces-faces-after]]. [[lst:tweak-faces-faces-after]].
2. Shadowing the definition of faces before loading as in listing 2. Toggling between a dark and light background by means of
src_emacs-lisp{(invert-default-face)} in listing [[lst:invert-default-face]].
3. Shadowing the definition of faces before loading as in listing
[[lst:tweak-org-faces-before]] and [[lst:tweak-sh-script-faces-before]]. The last [[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 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. 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=]:
#+caption: Improve the visibility of faces in =faces.el=. #+caption: Improve the visibility of faces in =faces.el=.
@ -309,6 +308,18 @@ background.
(tweak-region-face-background-color)) (tweak-region-face-background-color))
#+end_src #+end_src
#+caption[Implement =invert-default-face=]:
#+caption: Implement =invert-default-face=.
#+name: lst:invert-default-face
#+begin_src emacs-lisp
(with-eval-after-load 'emacs
(defun invert-default-face ()
"Invert the default face."
(interactive)
(invert-face 'default)
(tweak-region-face-background-color)))
#+end_src
#+caption[Improve the visibility of faces in =org-faces.el=]: #+caption[Improve the visibility of faces in =org-faces.el=]:
#+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-before #+name: lst:tweak-org-faces-before
@ -3079,6 +3090,7 @@ on tables by means of =org-narrow-to-table=.
(define-key ctl-x-map (kbd "n t") #'org-narrow-to-table) (define-key ctl-x-map (kbd "n t") #'org-narrow-to-table)
(define-key ctl-x-map (kbd "C-n") #'narrow-or-widen-dwim) (define-key ctl-x-map (kbd "C-n") #'narrow-or-widen-dwim)
#+end_src #+end_src
** [[info:emacs#Faces][Text faces or styles (info)]] ** [[info:emacs#Faces][Text faces or styles (info)]]
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: sec:text-faces-or-styles :CUSTOM_ID: sec:text-faces-or-styles
@ -3094,9 +3106,7 @@ fonts properly. It boils down to two rules:
scaling). scaling).
The code in listing [[lst:configure-face-attributes]] source implements those rules. The code in listing [[lst:configure-face-attributes]] source implements those rules.
In case of proper initialization of all face heigths, font scaling is easy as In case of proper initialization of all face heigths, font scaling is easy as
listing [[lst:my-set-default-face-height]] shows. Finally, the code in listing listing [[lst:set-default-face-height]] shows.
[[lst:my-invert-default-face]] allows swapping the foreground and background colors
of the default face on all frames.
#+caption[Configure =face-attributse=]: #+caption[Configure =face-attributse=]:
#+caption: Configure =face-attributes=. #+caption: Configure =face-attributes=.
@ -3119,12 +3129,12 @@ of the default face on all frames.
(set-face-attribute 'variable-pitch nil :family "DejaVu Sans")))) (set-face-attribute 'variable-pitch nil :family "DejaVu Sans"))))
#+end_src #+end_src
#+caption[Implement =my-set-default-face-height=]: #+caption[Implement =set-default-face-height=]:
#+caption: Implement =my-set-default-face-height=. #+caption: Implement =set-default-face-height=.
#+name: lst:my-set-default-face-height #+name: lst:set-default-face-height
#+begin_src emacs-lisp #+begin_src emacs-lisp
(with-eval-after-load 'emacs (with-eval-after-load 'emacs
(defun my-set-default-face-height () (defun set-default-face-height ()
"Set the default face height in all current and future frames. "Set the default face height in all current and future frames.
Scale all other faces with a height that is a real number." Scale all other faces with a height that is a real number."
@ -3139,18 +3149,6 @@ of the default face on all frames.
(set-face-attribute 'default nil :height height)))) (set-face-attribute 'default nil :height height))))
#+end_src #+end_src
#+caption[Implement =my-invert-default-face=]:
#+caption: Implement =my-invert-default-face=.
#+name: lst:my-invert-default-face
#+begin_src emacs-lisp
(with-eval-after-load 'emacs
(defun my-invert-default-face ()
"Invert the default face."
(interactive)
(invert-face 'default)
(tweak-region-face-background-color)))
#+end_src
** [[https://jblevins.org/log/rainbow-mode][Visualize color codes and names]] ** [[https://jblevins.org/log/rainbow-mode][Visualize color codes and names]]
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: sec:rainbow-mode :CUSTOM_ID: sec:rainbow-mode