From 6c7f0b8ae2de30a808901b16b0d462fe833ea1b4 Mon Sep 17 00:00:00 2001 From: Jakob L. Kreuze Date: Mon, 1 Jun 2020 16:53:50 -0400 Subject: Break config into files. --- lisp/appearance/modeline.el | 87 +++++++++++++++ lisp/appearance/theme.el | 251 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 338 insertions(+) create mode 100644 lisp/appearance/modeline.el create mode 100644 lisp/appearance/theme.el (limited to 'lisp/appearance') diff --git a/lisp/appearance/modeline.el b/lisp/appearance/modeline.el new file mode 100644 index 0000000..296a4f5 --- /dev/null +++ b/lisp/appearance/modeline.el @@ -0,0 +1,87 @@ +;;; modeline.el -*- lexical-binding: t; -*- +;;; +;;; Author: Jakob L. Kreuze +;;; URL: https://git.sr.ht/~jakob/.emacs.d/ +;;; +;;; My custom modeline for Emacs, which seeks to fit the dual role of a +;;; functional status indicator for Emacs, as well as a "bar" in the sense of a +;;; traditional tiling window manager. +;;; + +;; My implementation of a clock for the modeline. The modeline is refreshed by a +;; timer to ensure that it doesn't go too stale, as it could theoretically go +;; several minutes without being updated. + +(defun mode-line-time () + (format-time-string "%Y-%m-%d %H:%M")) + +(let ((timer (run-at-time t 60.0 #'ignore))) + (timer-set-function timer + (lambda () + (force-mode-line-update)))) + +;; For some time, I was using my own implementation of a modeline battery +;; monitor. However, the constant calls to `battery-linux-sysfs' were +;; interfering with the way that EXWM handles input focus, and I've since moved +;; towards reusing `display-battery-mode'. Because strings in `mode-line-format' +;; can contain control sequences, the percent symbol has to be escaped twice -- +;; once for `battery-format', and once for `mode-line-format'. +;; +;; Obviously, my tower lacks a battery, so I only enable this on my laptop. + +(when (string= (system-name) "Upsilon") + (require 'battery) + (display-battery-mode +1) + (setq battery-mode-line-format "%L: %t, %p%%%%")) + +(defun maybe-elide (s &optional max-length) + "Truncate `S' to `MAX-LENGTH'. +Return a string derived from `S', possible elided, that is at +most 1MAX-LENGTH characters long." + (let ((max-length (or max-length 30))) + (if (> (length s) max-length) + (concat (substring s 0 (- max-length 4)) " ...") + s))) + +(defun escape-mode-line-construct (s) + "Sanitize `S' for use in `mode-line-format'. +Ensure that no part of S will be interpreted as a modeline format +specifier." + (replace-regexp-in-string (regexp-quote "%") "%%" s t t)) + +(defun mode-line-render (left right) + "Return a string of `window-width' length containing LEFT, and +RIGHT aligned respectively." + (let* ((right (format-mode-line right)) + (left (maybe-elide (format-mode-line left) + (- (window-width) (length right) 1))) + (padding (- (window-width) (length left) (length right) 1)) + (padding (if (wholenump padding) (make-string padding ?\ )))) + (if padding + (escape-mode-line-construct (concat " " left padding right)) + (concat " " left right)))) + +(defun remove-unicode (s) + "Remove non-ASCII or non-printable ASCII characters from `S'." + (apply #'string (seq-filter #'(lambda (c) (and (>= c ? ) (<= c ?~))) s))) + +(setq-default mode-line-format + '((:eval + (mode-line-render + (cond ((eq major-mode 'exwm-mode) + (concat "%b: " (remove-unicode exwm-title))) + ((eq major-mode 'pdf-view-mode) + (concat "%b [" + (number-to-string (pdf-view-current-page)) + "/" + (number-to-string (pdf-cache-number-of-pages)) + "]")) + (t + (concat "%b [%m] [%*] Ln: %l/" + (number-to-string (1+ (count-lines 1 (point-max)))) + " Col: %c"))) + (cond ((string= (system-name) "Upsilon") + (format "%s | %s" + (mode-line-time) + battery-mode-line-string)) + (t (mode-line-time))))))) diff --git a/lisp/appearance/theme.el b/lisp/appearance/theme.el new file mode 100644 index 0000000..10b5624 --- /dev/null +++ b/lisp/appearance/theme.el @@ -0,0 +1,251 @@ +;;; theme.el -*- lexical-binding: t; -*- +;;; +;;; Author: Jakob L. Kreuze +;;; URL: https://git.sr.ht/~jakob/.emacs.d/ +;;; +;;; This is my custom theme, the code for which is very loosely adapted from +;;; moe-theme.el [1], but most of the palette has been altered to emulate the +;;; appearance of my old setup of Emacs in a terminal emulator. +;;; +;;; [1]: https://github.com/kuanyui/moe-theme.el + +(deftheme chayote + "Inspired by the appearance of Emacs in my terminal emulator.") + +;; The colors have been extracted into a variable, `palette', and a macro, +;; `with-palette', to provide access to the theme's color definitions without +;; significantly polluting the global namespace. To help me in modifying the +;; theme, I've defined a function similar to `list-colors-display', but for +;; showing the colors in the palette I've defined. + +(defvar palette + '((yellow-1 "#ffd787") (yellow-2 "#ffd700") (yellow-3 "#c4a000") + (yellow-3-5 "#aaaa11") (yellow-4 "#875f00") + + (orange-1 "#ffaf87") (orange-2 "#ff8700") (orange-3 "#ff5d17") + (orange-4 "#d75f00") (orange-5 "#af5f00") + + (magenta-1 "#ff7bbb") (magenta-2 "#ff4ea3") (magenta-3 "#ff1f8b") + + (green-1 "#87ff87") (green-2 "#a1db00") (green-3 "#5faf00") + (green-4 "#008700") (green-5 "#005f00") + + (cyan-1 "#afd7d7") (cyan-2 "#87ffd7") (cyan-3 "#00d7af") + (cyan-4 "#00ac8a") (cyan-5 "#5faf87") (cyan-6 "#005f5f") + (cyan-7 "#236f73") + + (blue-1 "#1fb6d3") (blue-2 "#1f5bff") (blue-3 "#005f87") + (blue-4 "#5f7ab1") (blue-5 "#0000af") (blue-6 "#00005f") + + (purple-1 "#d18aff") (purple-2 "#af5fff") (purple-3 "#9a08ff") + (purple-4 "#6c0099") + + (red-1 "#ef2929") (red-2 "#dd0000") (red-3 "#a40000") + (red-4 "#5f0000") + + (white-1 "#f0e9dc") (white-2 "#c6c6c6") (white-3 "#b2b2b2") + + (black-1 "#a8a8a8") (black-2 "#8a8a8a") (black-2-5 "#6c6c6c") + (black-3 "#4e4e4e") (black-4 "#3a3a3a") (black-5 "#303539") + (black-6 "#000000") + + (LIGHT_BG "#fdfde7") (white-0 "#eeeeee") + + (green-02 "#5fd700") (green-01 "#d7ff00") (green-0 "#d7ff5f") + (green-00 "#d7ff87") + + (cyan-0 "#d7ffd7") + + (blue-01 "#c3c9f8") (blue-0 "#afd7ff") (blue-00 "#d7d7ff") + + (yellow-0 "#ffff87") (yellow-00 "#ffffaf") + + (purple-0 "#af87ff") (purple-00 "#e6a8df") + + (red-0 "#ff4b4b") (red-00 "#ffafaf") + + (magenta-0 "#ffafd7") (magenta-00 "#ffd7ff") + + (orange-0 "#ffaf87") (orange-00 "#ffd787") (orange-000 "#ffd7af") + + (linum-dark "#87875f") (linum-light "#d7d7af")) + "The palette of colors in use with my 'chayote' theme.") + +(defmacro with-palette (&rest form) + "Evaluate `FORM' in a `let' containing the theme's colors." + `(let ((class '((class color) (min-colors 89))) + ,@palette) + ,@form)) + +(defun display-palette () + "Display names of colors in `PALETTE', and show what they look like." + (interactive) + (with-help-window "*Chayote Colors*" + (with-current-buffer standard-output + (erase-buffer) + (dolist (color palette) + (let* ((name (symbol-name (first color))) + (value (second color))) + (put-text-property 0 (length name) + 'font-lock-face `(:foreground ,value) + name) + (insert name) + (insert (propertize " " 'display '(space :align-to (- right 9)))) + (insert " ") + (put-text-property 0 (length value) + 'font-lock-face `(:background ,value) + value) + (insert value) + (terpri))) + (set-buffer-modified-p nil) + (setq truncate-lines t)))) + +(with-palette + (custom-theme-set-faces + 'chayote + `(default ((,class (:foreground ,white-1 :background ,black-5 :family "Terminus" :height 90)))) + `(italic ((,class (:italic t)))) + `(cursor ((,class (:background ,white-0)))) + `(variable-pitch ((,class (:inherit default)))) + + `(link ((,class (:foreground ,blue-1 :underline t)))) + + ;; Highlighting faces + `(highlight ((,class (:background ,black-3)))) + `(hl-line ((,class (:background ,black-4)))) + `(highlight-symbol-face ((,class (:background ,green-5)))) + `(region ((,class (:background ,blue-4)))) + `(secondary-selection ((,class (:background ,blue-3 :foreground ,white-0)))) + `(isearch ((,class (:foreground ,white-1 :background ,orange-3)))) + `(lazy-highlight ((,class (:background ,magenta-3 :foreground ,white-1)))) + `(trailing-whitespace ((,class (:background ,red-3)))) + `(show-paren-match ((,class (:background ,blue-3 :foreground nil)))) + `(header-line ((,class (:background ,blue-3 :foreground ,white-0)))) + `(help-argument-name ((,class (:foreground ,magenta-1 :italic t)))) + `(eldoc-highlight-function-argument ((,class (:foreground ,green-01 :bold t :underline t :background ,green-5)))) + + ;; Mode line & frames' faces + `(mode-line ((,class (:box nil :background ,white-1 :foreground ,black-5)))) + `(mode-line-inactive ((,class (:background ,white-3 :foreground ,black-5)))) + `(mode-line-buffer-id ((,class (:box nil :foreground ,black-5 :background nil)))) + `(vertical-border ((,class (:foreground ,black-3 :background ,black-3)))) + + ;; Escape and prompt faces + `(minibuffer-prompt ((,class (:foreground ,blue-1)))) + `(escape-glyph ((,class (:foreground ,yellow-3)))) + `(error ((,class (:foreground ,red-0)))) + `(warning ((,class (:foreground ,orange-1)))) + `(success ((,class (:foreground ,green-1)))) + + ;; Font lock faces + `(font-lock-builtin-face ((,class (:foreground ,cyan-1)))) + `(font-lock-comment-delimiter-face ((,class (:inherit font-lock-comment-face)))) + `(font-lock-comment-face ((,class (:foreground ,orange-2)))) + `(font-lock-constant-face ((,class (:foreground ,cyan-2)))) + `(font-lock-doc-face ((,class (:inherit font-lock-string-face)))) + `(font-lock-doc-string-face ((,class (:inherit font-lock-string-face)))) + `(font-lock-function-name-face ((,class (:foreground ,blue-0)))) + `(font-lock-keyword-face ((,class (:foreground ,blue-1)))) + `(font-lock-negation-char-face ((,class (:foreground ,red-0)))) + `(font-lock-preprocessor-face ((,class (:inherit font-lock-builtin-face)))) + `(font-lock-regexp-grouping-backslash ((,class (:foreground ,yellow-1)))) + `(font-lock-regexp-grouping-construct ((,class (:foreground ,purple-1)))) + `(font-lock-string-face ((,class (:foreground ,orange-1)))) + `(font-lock-type-face ((,class (:foreground ,green-1)))) + `(font-lock-variable-name-face ((,class (:foreground ,yellow-1)))) + `(font-lock-warning-face ((,class (:weight bold :foreground ,red-2)))) + + ;; Info + `(Info-quoted ((,class (:inherit default)))) + + ;; company + `(company-tooltip ((,class (:background ,black-4)))) + `(company-scrollbar-bg ((,class (:background ,black-4)))) + `(company-scrollbar-fg ((,class (:background ,orange-2)))) + `(company-tooltip-selection ((,class (:background ,black-3)))) + `(company-tooltip-common ((,class (:foreground ,blue-1)))) + `(company-tooltip-annotation ((,class (:foreground ,cyan-1)))) + + ;; AUCTeX + `(font-latex-sedate-face ((,class (:inherit font-lock-keyword-face)))) + + ;; Gnus + `(gnus-group-mail-3 ((,class (:foreground ,green-2)))) + + ;; org-mode + `(org-document-info-keyword ((,class (:foreground ,red-0)))) + `(org-document-title ((,class (:inherit org-document-info-keyword)))) + `(org-document-info ((,class (:inherit org-document-info-keyword)))) + `(org-meta-line ((,class (:inherit org-document-info-keyword)))) + `(org-archived ((,class (:slant italic)))) + `(org-checkbox ((,class (:background ,white-2 :foreground ,black-3 + :box (:line-width 1 :style released-button))))) + `(org-date ((,class (:foreground ,green-3 :underline t)))) + `(org-done ((,class (:foreground ,green-4 :background ,green-00 + :box (:line-width 1 :style none))))) + `(org-todo ((,class (:foreground ,red-3 :background ,orange-0 + :box (:line-width 1 :style none))))) + `(org-level-1 ((,class (:foreground ,purple-00)))) + `(org-level-2 ((,class (:foreground ,blue-0)))) + `(org-level-3 ((,class (:foreground ,cyan-3)))) + `(org-level-4 ((,class (:foreground ,green-02)))) + `(org-level-5 ((,class (:foreground ,red-2)))) + `(org-level-6 ((,class (:foreground ,orange-2)))) + `(org-level-7 ((,class (:foreground ,magenta-2)))) + `(org-level-8 ((,class (:foreground ,yellow-2)))) + `(org-tag ((,class (:background ,black-1 :foreground ,white-0)))) + `(org-column ((,class (:background ,yellow-00 :foreground ,black-3)))) + `(org-column-title ((,class (:background ,blue-0 :foreground ,black-5 :underline t)))) + `(org-agenda-structure ((,class (:foreground ,cyan-4 :background nil :bold nil)))) + `(org-deadline-announce ((,class (:foreground ,red-3)))) + `(org-scheduled ((,class (:foreground ,black-2)))) + `(org-scheduled-previously ((,class (:foreground ,red-1)))) + `(org-scheduled-today ((,class (:foreground ,blue-2)))) + `(org-special-keyword ((,class (:foreground ,green-3)))) + `(org-table ((,class (:background ,black-4 :foreground ,white-3)))) + ;; `(org-time-grid ((,class (:foreground ,white-4)))) + `(org-upcoming-deadline ((,class (:foreground ,red-3)))) + ;; `(org-warning ((,class (:foreground ,white-0 :background ,red-3)))) + `(org-warning ((,class (:foreground ,white-0 :background ,red-4)))) + `(org-formula ((,class (:foreground ,purple-2)))) + `(org-headline-done ((,class (:foreground ,green-2)))) + `(org-hide ((,class (:foreground ,LIGHT_BG)))) + `(org-code ((,class (:foreground ,blue-2 :background ,white-1)))) + ;; `(org-link ((,class (:foreground ,blue-2 :underline ,blue-2)))) + `(org-link ((,class (:inherit link)))) + `(org-footnote ((,class (:foreground ,magenta-3)))) + `(org-ellipsis ((,class (:foreground ,red-2)))) + `(org-agenda-clocking ((,class (:foreground ,blue-3 :background ,blue-0)))) + `(org-agenda-date ((,class (:foreground ,blue-1 :background nil :underline nil)))) + `(org-agenda-date-weekend ((,class (:foreground ,purple-2 :background nil :slant italic :bold nil)))) + `(org-agenda-date-today ((,class (:foreground ,blue-0 :background nil :underline t)))) + `(org-agenda-column-dateline ((,class (:foreground ,white-0 :background ,yellow-0 :underline t)))) + `(org-agenda-todo ((,class (:foreground ,white-0 :background ,red-2)))) + `(org-agenda-done ((,class (:foreground ,green-3 :background ,nil)))) + `(org-agenda-dimmed-todo-face ((,class (:foreground ,white-0 :background ,red-2)))) + `(org-priority ((,class (:foreground ,red-1 :background ,nil)))) + `(org-block ((,class (:foreground ,white-1 :background ,black-4 :extend t)))) + `(org-block-begin-line ((,class (:foreground ,black-3)))) + `(org-block-end-line ((,class (:foreground ,black-3)))) + `(org-block-background ((,class (:background ,white-1)))) + ;; `(org-block-begin-line ((,class (:foreground ,blue-3 :background ,blue-0)))) + ;; `(org-block-end-line ((,class (:foreground ,white-2 :background ,white-1)))) + `(org-quote ((,class (:foreground ,blue-3 :background ,blue-00)))) + `(org-mode-line-clock ((,class (:foreground ,blue-3 :background ,blue-0 :bold t)))) + `(org-mode-line-clock-overrun ((,class (:foreground ,white-0 :background ,red-1 :bold t)))) + ;; `(org-verbatim ((,class (:foreground ,blue-3 :background ,blue-00 :bold nil)))) + `(org-verbatim ((,class (:foreground ,blue-1 :background ,black-4)))) + + ;; erc + `(erc-input-face ((,class (:foreground ,white-1)))) + `(erc-button ((,class (:inherit link)))) + + ;; smartparens + `(sp-pair-overlay-face ((,class (:inherit default))))) + + (custom-theme-set-variables + 'chayote + `(ansi-color-names-vector [,black-5 ,red-0 ,green-0 ,yellow-1 + ,blue-1 ,purple-1 ,blue-0 ,white-1]))) + +(enable-theme 'chayote) -- cgit v1.3