8

stefan-theme-tangle.org

 2 years ago
source link: https://gitlab.com/stefan.koch.micro/dotfiles/-/blob/master/emacs/stefan-theme-tangle.org
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Literate Emacs Color Theme Organized by Functionality

Theme File

This file sill generate the .emacs.d/stefan-theme.el files on tangling. It uses org tangle and noweb to collect the various parts of the theme files into a single theme file. The advantage of using noweb is that the content can be organized by functionality and the noweb will rearrange it into the sequential sections needed by the theme definition file.

The theme itself is not complete, nor do I have a great artistic style, but it works for me. The value of this file/code is more to serve as an example for how to organize an Emacs theme by using noweb to group by functionality instead of by the requirements needed for the theme elisp format.

The theme file uses autothemer based on System Crafters youtube video Emacs Tips - How to Create Your Own Color Theme. The sections below fill in the body of the theme. Specifically each section below will add content to the <<xxxx>> sections in the file below. Note that the source blocks below will have the :noweb-ref <<xxxx>> header argument. That is how the body of the theme file is filled in.

(require 'autothemer)
<<stefan-defface>>
(autothemer-deftheme
 stefan "Stefan's own personal theme"
 ((((class color) (min-colors #xFFFFFF)))
  <<stefan-colors>>
 )
 (
  <<stefan-faces>>
  ))
(custom-theme-set-variables
 'stefan
 <<stefan-variables>>
 )
(provide-theme 'stefan)

To load the theme: (load-theme 'stefan t)

Useful lisp functions for creating themes:

  • describe-face: Show the face that is active for the current cursor position.
  • list-faces-display: Show a buffer with the known faces
  • list-colors-display: show a buffer with the named colors.

General Setup

Colors

Set some color names that can be used across the modes.

(stefan-default "white")
(stefan-dim "DimGray")
(stefan-constant "Aquamarine")

Global Faces

Set the default, cursor and selection/active region colors.

(default (:foreground stefan-default :background "black" ))
(cursor (:background stefan-default))
(region (:background "gray40"))

Org Mode

Headings

Set the main headings to be larger, but with a subdued color. That way the text stands out, but the heading level is visible.

(stefan-outline-1 "OliveDrab")
(stefan-outline-2 "ForestGreen")
(stefan-outline-3 "SeaGreen")
(stefan-outline-4 "DarkOliveGreen")
(org-level-1 (:foreground stefan-outline-1 :height 1.50))
(org-level-2 (:foreground stefan-outline-2 :height 1.33))
(org-level-3 (:foreground stefan-outline-3 :height 1.16))
(org-level-4 (:foreground stefan-outline-4 ))
(org-level-5 (:foreground stefan-outline-4 ))
(org-level-6 (:foreground stefan-outline-4 ))
(org-level-7 (:foreground stefan-outline-4 ))
(org-level-8 (:foreground stefan-outline-4 ))

Since the above (and indent) makes the level apparent enough, don’t show Leading stars.

'(org-hide-leading-stars nil)

Todo Highlights

Todo keywords are split into active, waiting and future buckets.

This setup the faces for these.

(defface stefan-org-todo-active '() "TODO keywords that I can work on now.")
(defface stefan-org-todo-wait '() "TODO keywords where I am waiting")
(defface stefan-org-todo-future '() "Completed TODO keywords that are future reminders.")

Assign the names of the todo keywords into the buckets.

'(org-todo-keyword-faces
  '(("WAIT" . stefan-org-todo-wait)
    ("WAIT_OTHER" . stefan-org-todo-wait)
    ("TODO" . stefan-org-todo-active)
    ("PLAN" . stefan-org-todo-future)
    ("READING" . stefan-org-todo-future)))

Finally assign the colors to the todo keywords. Also set the whole headline to dim when it is done.

(stefan-org-todo-active (:foreground "coral" :weight 'bold))
(stefan-org-todo-wait (:foreground "chocolate" :weight 'bold))
(stefan-org-todo-future (:foreground "SaddleBrown" :weight 'bold))
(stefan-org-todo-done (:foreground stefan-dim :weight 'bold))
(org-todo (:foreground "red" :weight 'bold))
(org-done (:foreground stefan-dim))
(org-headline-done (:foreground stefan-dim))

I want to define a special face to highlight special tags.

(defface stefan-org-tag-context '() "Tags that indicate context of the activity.")

Assign the colors to the faces:

(stefan-org-tag-context (:foreground "orange"))

Body Faces

(org-link (:foreground "LightSteelBlue" :underline t))
(org-date (:foreground "LightSteelBlue" :underline t))
(org-priority (:foreground "DarkRed"))
(org-code (:inherit 'fixed-pitch :foreground "SkyBlue" :underline nil))
(org-verbatim (:inherit 'fixed-pitch :foreground stefan-constant ))

Variable Pitch Org Mode.

Set tables and source blocks to be fixed width even if the rest of org mode is not.

(org-table (:inherit 'fixed-pitch))
(org-block (:inherit 'fixed-pitch))

HC-Highlight (whitespace)

Set the white space indications/errors to be subtle.

(hc-tab (:background "gray20"))
(hc-trailing-whitespace (:background "gray20"))

Programming modes

Make comments and python doc-strings the same subtle color.

(font-lock-comment-face (:foreground stefan-dim))
(font-lock-doc-face (:foreground stefan-dim))

Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK