emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/gotham-theme 474787af00 011/214: Fix bug #1 and #2


From: ELPA Syncer
Subject: [nongnu] elpa/gotham-theme 474787af00 011/214: Fix bug #1 and #2
Date: Fri, 7 Jan 2022 17:58:36 -0500 (EST)

branch: elpa/gotham-theme
commit 474787af00bdc9ddc28b431370ab10c599975ba7
Author: Vasilij Schneidermann <v.schneidermann@gmail.com>
Commit: Vasilij Schneidermann <v.schneidermann@gmail.com>

    Fix bug #1 and #2
---
 gotham-theme.el | 242 ++++++++++++++++++++++++++++++++++----------------------
 1 file changed, 148 insertions(+), 94 deletions(-)

diff --git a/gotham-theme.el b/gotham-theme.el
index ec0534417e..49fd5ea745 100644
--- a/gotham-theme.el
+++ b/gotham-theme.el
@@ -29,124 +29,178 @@
 ;; theming support.
 
 ;;; Credits:
+
 ;; Andrea Leopardi created the original Vim theme on which this port
 ;; is based, it can be found under
 ;; <https://github.com/whatyouhide/vim-gotham>
 
 ;;; Code:
 
+(defgroup gotham nil
+  "A very dark Emacs theme"
+  :prefix "gotham-")
+
 (deftheme gotham "The Gotham color theme")
 
-;; TODO 16-color support for terminals
-;; TODO offer 256 color switch?
 ;; TODO test with ruby, python, tex, c, html
 
-(let ((base0   "#0c1014")
-      (base1   "#11151c")
-      (base2   "#091f2e")
-      (base3   "#0a3749")
-      (base4   "#245361")
-      (base5   "#599cab")
-      (base6   "#99d1ce")
-      (base7   "#d3ebe9")
-
-      (red     "#c23127")
-      (orange  "#d26937")
-      (yellow  "#edb443")
-      (magenta "#888ca6")
-      (violet  "#4e5166")
-      (blue    "#195466")
-      (cyan    "#33859e")
-      (green   "#2aa889"))
-
-  (custom-theme-set-faces
-   'gotham
-   `(default ((t (:foreground ,base6 :background ,base0))))
-   `(button ((t (:foreground ,base4 :box t))))
-   `(shadow ((t (:foreground ,base4))))
-   `(highlight ((t (:background ,base2))))
-   `(link ((t (:foreground ,orange))))
-   `(link-visited ((t (:foreground ,yellow))))
-   `(cursor ((t (:background ,base6))))
-   `(region ((t (:foreground unspecified :background ,base3))))
-   `(secondary-selection ((t (:foreground unspecified :background ,base4))))
-   `(hl-line ((t (:background ,base1))))
-   `(linum ((t (:foreground ,base4 :background ,base1))))
-   `(fringe ((t (:foreground ,base6 :background ,base1))))
-   `(vertical-border ((t (:foreground ,base4))))
-   `(tooltip ((t (:foreground ,base6 :background ,base0))))
-   `(trailing-whitespace ((t (:background ,red))))
+(defcustom gotham-tty-extended-palette-p nil
+  "Use the extended 256-color palette in the terminal?
+When t, assume a regular 256-color palette, otherwise assume a
+customized 16-color palette."
+  :type '(boolean (const :tag "16 colors" nil)
+                  (const :tag "256 colors" t))
+  :group 'gotham)
+
+(setq gotham-tty-switch 'extended)
+(defvar gotham-color-alist
+  `((base0   "#0c1014" ,(if gotham-tty-extended-palette-p "color-232" "black"))
+    (base1   "#11151c" ,(if gotham-tty-extended-palette-p "color-233" 
"brightblack"))
+    (base2   "#091f2e" ,(if gotham-tty-extended-palette-p "color-17"  
"brightgreen"))
+    (base3   "#0a3749" ,(if gotham-tty-extended-palette-p "color-18"  
"brightblue"))
+    (base4   "#245361" ,(if gotham-tty-extended-palette-p "color-24"  
"brightyellow"))
+    (base5   "#599cab" ,(if gotham-tty-extended-palette-p "color-81"  
"brightcyan"))
+    (base6   "#99d1ce" ,(if gotham-tty-extended-palette-p "color-122" "white"))
+    (base7   "#d3ebe9" ,(if gotham-tty-extended-palette-p "color-194" 
"brightwhite"))
+
+    (red     "#c23127" ,(if gotham-tty-extended-palette-p "color-124" "red"))
+    (orange  "#d26937" ,(if gotham-tty-extended-palette-p "color-166" 
"brightred"))
+    (yellow  "#edb443" ,(if gotham-tty-extended-palette-p "color-214" 
"yellow"))
+    (magenta "#888ca6" ,(if gotham-tty-extended-palette-p "color-67"  
"brightmagenta"))
+    (violet  "#4e5166" ,(if gotham-tty-extended-palette-p "color-60"  
"magenta"))
+    (blue    "#195466" ,(if gotham-tty-extended-palette-p "color-24"  "blue"))
+    (cyan    "#33859e" ,(if gotham-tty-extended-palette-p "color-44"  "cyan"))
+    (green   "#2aa889" ,(if gotham-tty-extended-palette-p "color-78"  
"green")))
+  "List of colors the theme consists of.")
+
+(defun gotham-set-faces (faces)
+  "Helper function that sets the faces of the theme to a list of FACES.
+See `gotham-transform-face' for the transformation, see
+`gotham-transform-spec' for the rules."
+  (apply #'custom-theme-set-faces 'gotham
+         (mapcar #'gotham-transform-face faces)))
+
+(defun gotham-transform-face (face)
+  "Helper function that transforms a FACE to all variants.
+FACE is a list where the first element is the name of the
+affected face and the remaining elements specify the face
+attributes which are transformed into face attributes for both
+graphical and terminal displays. See `gotham-transform-spec' for
+the rules that are applied to the face attributes."
+  (let* ((name (car face))
+         (spec (cdr face))
+         (graphic-spec (gotham-transform-spec spec 'graphic))
+         (tty-spec (gotham-transform-spec spec 'tty)))
+    `(,name ((((type graphic)) ,@graphic-spec)
+             (((type tty)) ,@tty-spec)))))
+
+(defun gotham-transform-spec (spec display)
+  "Helper function that transforms SPEC for DISPLAY.
+DISPLAY is either 'graphic or 'tty, SPEC is a property list where
+the values are substituted with colors from `gotham-color-alist'
+depending on DISPLAY for keys which are either :foreground or
+:background.  All other key-value combinations remain unchanged."
+  (let (output)
+    (while spec
+      (let* ((key (car spec))
+             (value (cadr spec))
+             (index (cond ((eq display 'graphic) 1)
+                          ((eq display 'tty) 2)))
+             (color (nth index (assoc value gotham-color-alist))))
+        (cond
+         ((or (eq key :foreground) (eq key :background))
+          (setq output (append output (list key color))))
+         (t (setq output (append output (list key value))))))
+      (setq spec (cddr spec)))
+    output))
+
+(gotham-set-faces
+ '((default :foreground base6 :background base0)
+   (button :foreground base4 :box t)
+   (shadow :foreground base4)
+   (highlight :background base2)
+   (link :foreground orange)
+   (link-visited :foreground yellow)
+   (cursor :background base6)
+   (region :foreground unspecified :background base3)
+   (secondary-selection :foreground unspecified :background base4)
+   (hl-line :background base1)
+   (linum :foreground base4 :background base1)
+   (fringe :foreground base6 :background base1)
+   (vertical-border :foreground base4)
+   (tooltip :foreground base6 :background base0)
+   (trailing-whitespace :background red)
 
    ;; font-lock
-   `(escape-glyph ((t (:foreground ,orange :weight bold))))
-   `(font-lock-builtin-face ((t (:foreground ,orange))))
-   `(font-lock-comment-face ((t (:foreground ,base4))))
-   `(font-lock-comment-delimiter-face ((t (:foreground ,base4))))
-   `(font-lock-constant-face ((t (:foreground ,magenta))))
-   `(font-lock-doc-face ((t (:foreground ,green))))
-   `(font-lock-function-name-face ((t (:foreground ,base5))))
-   `(font-lock-keyword-face ((t (:foreground ,blue))))
-   `(font-lock-negation-char-face ((t (:foreground ,red))))
-   `(font-lock-preprocessor-face ((t (:foreground ,red))))
-   `(font-lock-regexp-grouping-construct)
-   `(font-lock-regexp-grouping-backslash)
-   `(font-lock-string-face ((t (:foreground ,green))))
-   `(font-lock-type-face ((t (:foreground ,orange))))
-   `(font-lock-variable-name-face ((t (:foreground ,base5))))
-   `(font-lock-warning-face ((t (:foreground ,red))))
-   `(success ((t (:foreground ,green))))
-   `(warning ((t (:foreground ,red))))
+   (escape-glyph :foreground orange :weight bold)
+   (font-lock-builtin-face :foreground orange)
+   (font-lock-comment-face :foreground base4)
+   (font-lock-comment-delimiter-face :foreground base4)
+   (font-lock-constant-face :foreground cyan :weight bold)
+   (font-lock-doc-face :foreground green)
+   (font-lock-function-name-face :foreground base5)
+   (font-lock-keyword-face :foreground blue :weight bold)
+   (font-lock-negation-char-face :foreground red)
+   (font-lock-preprocessor-face :foreground red)
+   (font-lock-regexp-grouping-construct)
+   (font-lock-regexp-grouping-backslash)
+   (font-lock-string-face :foreground green)
+   (font-lock-type-face :foreground orange)
+   (font-lock-variable-name-face :foreground base5)
+   (font-lock-warning-face :foreground red)
+   (success :foreground green)
+   (warning :foreground red)
 
    ;; search and highlighting
-   `(match ((t (:background ,base5))))
-   `(isearch ((t (:inverse-video t))))
-   `(isearch-fail ((t (:foreground ,red))))
-   `(lazy-highlight ((t (:foreground ,base2 :background ,yellow))))
-   `(show-paren-match ((t (:foreground ,base1 :background ,orange))))
-   `(show-paren-mismatch ((t (:foreground ,base1 :background ,red))))
+   (match :background base5)
+   (isearch :inverse-video t)
+   (isearch-fail :foreground red)
+   (lazy-highlight :foreground base2 :background yellow)
+   (show-paren-match :foreground base1 :background orange)
+   (show-paren-mismatch :foreground base1 :background red)
 
    ;; mode and header lines
-   `(minibuffer-prompt ((t (:foreground ,cyan))))
-   `(header-line ((t (:foreground ,base5 :background ,base2))))
-   `(menu ((t (:background ,base3 :foreground ,base6))))
-   `(mode-line ((t (:foreground ,base5 :background ,base2 :box nil))))
-   `(mode-line-inactive ((t (:foreground ,base4 :background ,base1 :box nil))))
-   `(mode-line-highlight ((t (:foreground ,base6))))
-   `(mode-line-buffer-id ((t (:weight bold))))
+   (minibuffer-prompt :foreground cyan)
+   (header-line :foreground base5 :background base2)
+   (menu :background base3 :foreground base6)
+   (mode-line :foreground base5 :background base2 :box nil)
+   (mode-line-inactive :foreground base4 :background base1 :box nil)
+   (mode-line-highlight :foreground base6)
+   (mode-line-buffer-id :weight bold)
 
    ;; customize
-   `(custom-button ((t (:foreground ,base4 :box t))))
-   `(custom-button-mouse ((t (:foreground ,base5 :box t))))
-   `(custom-group-tag ((t (:inherit fixed-pitch :foreground ,magenta))))
+   (custom-button :foreground base4 :box t)
+   (custom-button-mouse :foreground base5 :box t)
+   (custom-group-tag :inherit fixed-pitch :foreground magenta)
 
    ;; external packages
 
    ;; enh-ruby-mode
-   `(enh-ruby-heredoc-delimiter-face ((t (:foreground ,green :weight bold))))
-   `(enh-ruby-op-face ((t (:foreground ,magenta))))
-   `(enh-ruby-regexp-face ((t (:foreground ,green))))
-   `(enh-ruby-regexp-delimiter-face ((t (:foreground ,green :weight bold))))
-   `(enh-ruby-string-delimiter-face ((t (:foreground ,green))))
-   `(erm-syn-errline ((t (:foreground ,red))))
-   `(erm-syn-warnline ((t (:foreground ,orange))))
+   (enh-ruby-heredoc-delimiter-face :foreground green :weight bold)
+   (enh-ruby-op-face :foreground magenta)
+   (enh-ruby-regexp-face :foreground green)
+   (enh-ruby-regexp-delimiter-face :foreground green :weight bold)
+   (enh-ruby-string-delimiter-face :foreground green)
+   (erm-syn-errline :foreground red)
+   (erm-syn-warnline :foreground orange)
 
    ;; auctex
-   `(font-latex-bold-face ((t (:inherit bold))))
-   `(font-latex-doctex-documentation-face ((t (:inherit highlight))))
-   `(font-latex-doctex-preprocessor-face ((t (:inherit highlight :foreground 
,red))))
-   `(font-latex-italic-face ((t (:inherit italic))))
-   `(font-latex-math-face ((t (:foreground ,base5))))
-   `(font-latex-sectioning-0-face ((t (:inherit bold :foreground ,yellow))))
-   `(font-latex-sectioning-1-face ((t (:inherit bold :foreground ,yellow))))
-   `(font-latex-sectioning-2-face ((t (:inherit bold :foreground ,yellow))))
-   `(font-latex-sectioning-3-face ((t (:inherit bold :foreground ,yellow))))
-   `(font-latex-sectioning-4-face ((t (:inherit bold :foreground ,yellow))))
-   `(font-latex-sectioning-5-face ((t (:inherit bold :foreground ,yellow))))
-   `(font-latex-sedate-face ((t (:foreground ,orange))))
-   `(font-latex-slide-title-face ((t (:inherit bold :foreground ,orange))))
-   `(font-latex-string-face ((t (:inherit font-lock-string-face))))
-   `(font-latex-verbatim-face ((t (:inherit font-lock-string-face))))
-   `(font-latex-warning-face ((t (:inherit warning))))
+   (font-latex-bold-face :inherit bold)
+   (font-latex-doctex-documentation-face :inherit highlight)
+   (font-latex-doctex-preprocessor-face :inherit highlight :foreground red)
+   (font-latex-italic-face :inherit italic)
+   (font-latex-math-face :foreground base5)
+   (font-latex-sectioning-0-face :inherit bold :foreground yellow)
+   (font-latex-sectioning-1-face :inherit bold :foreground yellow)
+   (font-latex-sectioning-2-face :inherit bold :foreground yellow)
+   (font-latex-sectioning-3-face :inherit bold :foreground yellow)
+   (font-latex-sectioning-4-face :inherit bold :foreground yellow)
+   (font-latex-sectioning-5-face :inherit bold :foreground yellow)
+   (font-latex-sedate-face :foreground orange)
+   (font-latex-slide-title-face :inherit bold :foreground orange)
+   (font-latex-string-face :inherit font-lock-string-face)
+   (font-latex-verbatim-face :inherit font-lock-string-face)
+   (font-latex-warning-face :inherit warning)
    ))
 
 ;;;###autoload



reply via email to

[Prev in Thread] Current Thread [Next in Thread]