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

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

[elpa] externals/nano-theme afa83dc 1/4: Light / Dark WIP


From: ELPA Syncer
Subject: [elpa] externals/nano-theme afa83dc 1/4: Light / Dark WIP
Date: Tue, 5 Oct 2021 10:57:19 -0400 (EDT)

branch: externals/nano-theme
commit afa83dc4f2d710b89ba957762b50851729a9f30d
Author: Nicolas P. Rougier <Nicolas.Rougier@inria.fr>
Commit: Nicolas P. Rougier <Nicolas.Rougier@inria.fr>

    Light / Dark WIP
---
 nano-dark-theme.el  |  65 ++++++++++++
 nano-light-theme.el |  35 +++++++
 nano-theme.el       | 291 +++++++++++++++++++++++++++-------------------------
 3 files changed, 250 insertions(+), 141 deletions(-)

diff --git a/nano-dark-theme.el b/nano-dark-theme.el
new file mode 100644
index 0000000..128aff4
--- /dev/null
+++ b/nano-dark-theme.el
@@ -0,0 +1,65 @@
+;;; nano-dark-theme.el --- N Λ N O theme -*- lexical-binding: t -*-
+
+;; Copyright (C) 2021 Free Software Foundation, Inc.
+
+;; Maintainer: Nicolas P. Rougier <Nicolas.Rougier@inria.fr>
+;; URL: https://github.com/rougier/nano-theme
+;; Version: 0.1
+;; Package-Requires: ((emacs "27.1"))
+;; Keywords: theme, dark, light
+
+;; This file is not part of GNU Emacs.
+
+;; This file is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+
+;; This file is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; For a full copy of the GNU General Public License
+;; see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+;; N Λ N O theme is a consistent theme that comes in two flavors:
+;;  - a light theme that is based on Material (https://material.io/)
+;;  - a dark theme that is based on Nord (https://www.nordtheme.com/).
+;;
+;; A theme is fully defined by a set of (1+6) faces as explained in
+;; "On the Design of Text Editors" / https://arxiv.org/abs/2008.06030
+;;
+
+;;; Code:
+(require 'nano-theme)
+
+(deftheme nano-dark
+  "N Λ N O dark theme")
+
+(set-foreground-color nano-dark-foreground)
+(set-background-color nano-dark-background)
+(nano-theme 'dark)
+
+;; (set-frame-parameter nil 'background-mode 'dark)
+;; (set frame-background-mode 'dark)
+;; (frame-set-background-mode (selected-frame))
+
+;; (nano-theme 'dark) 
+
+;; (dolist (buffer (list " *Minibuf-0*" " *Echo Area 0*"
+;;                       " *Minibuf-1*" " *Echo Area 1*"))
+;;   (when (get-buffer buffer)
+;;     (with-current-buffer buffer
+;;       (face-remap-add-relative 'default 'nano-faded))))
+
+
+;;;###autoload
+(when (and (boundp 'custom-theme-load-path) load-file-name)
+  (add-to-list 'custom-theme-load-path
+               (file-name-as-directory (file-name-directory load-file-name))))
+
+(provide-theme 'nano-dark)
+;;; nano-dark-theme.el ends here
diff --git a/nano-light-theme.el b/nano-light-theme.el
new file mode 100644
index 0000000..a3c22b5
--- /dev/null
+++ b/nano-light-theme.el
@@ -0,0 +1,35 @@
+
+(defun nano-new-frame (&optional mode)
+  (interactive)
+  (let ((mode (or mode (frame-parameter nil 'background-mode)))
+        (background-mode frame-background-mode)
+        (selected-frame (selected-frame))
+        (new-frame nil))
+
+    ;; Set mode
+    (setq frame-background-mode mode)
+    (setq new-frame (make-frame-command))
+    (select-frame new-frame)
+
+    ;; This forces recomputation of faces on the new frame
+    (frame-set-background-mode (selected-frame))
+           
+    (when (eq mode 'light)
+      (set-foreground-color nano-light-foreground)
+      (set-background-color nano-light-background))
+
+    (when (eq mode 'dark)
+      (set-foreground-color nano-dark-foreground)
+      (set-background-color nano-dark-background))
+
+    ;; Restore background mode
+    (setq frame-background-mode background-mode)
+    (frame-set-background-mode selected-frame)
+    
+    new-frame))
+
+
+(nano-new-frame 'light)
+(nano-new-frame 'dark)
+(nano-new-frame)
+
diff --git a/nano-theme.el b/nano-theme.el
index 04979e5..17be6c2 100644
--- a/nano-theme.el
+++ b/nano-theme.el
@@ -93,129 +93,132 @@
 ;; Version 0.1
 ;; - Submission to ELPA
 
-
 ;;; Code:
 (require 'disp-table)
 
-(deftheme nano
-  "N Λ N O Theme")
-
 (defgroup nano nil
   "N Λ N O"
   :group 'convenience)
 
-(defgroup nano-light nil
-  "Light theme color palette" :group 'nano)
+(defgroup nano-theme nil
+  "Theme"
+  :group 'nano)
+
+(defgroup nano-theme-light nil
+  "Light color palette"
+  :group 'nano-theme)
 
-(defgroup nano-dark nil
-  "Dark theme color palette" :group 'nano)
+(defgroup nano-theme-dark nil
+  "Dark color palette"
+  :group 'nano-theme)
 
-(defgroup nano-fonts nil
-  "Dark & Light theme fonts" :group 'nano)
+(defgroup nano-theme-fonts nil
+  "Font stack"
+  :group 'nano-theme)
 
 (defcustom nano-fonts-use nil
   "Whether to use font stack"
-  :type 'boolean :group 'nano-fonts)
+  :type 'boolean :group 'nano-theme-fonts)
 
 (defface nano-mono
   '((t (:family "Roboto Mono"
         :height 140
         :weight light)))
   "Default monospaced font (Roboto Mono Light, 14pt)."
-  :group 'nano-fonts)
+  :group 'nano-theme-fonts)
 
 (defface nano-mono-alt
   '((t (:family "Fira Code"
         :height 140
         :weight light)))
   "Alternative monospaced font (Fira Code Light, 14pt)."
-  :group 'nano-fonts)
+  :group 'nano-theme-fonts)
 
 (defface nano-sans
   '((t (:family "Roboto"
         :height 140
         :weight light)))
   "Default proportional sans font (Roboto Light, 14pt)."
-  :group 'nano-fonts)
+  :group 'nano-theme-fonts)
 
 (defface nano-serif
   '((t (:family "Roboto Slab"
         :height 140
         :weight light)))
   "Default proportional serif font (Roboto Slab Light, 14pt)."
-  :group 'nano-fonts)
+  :group 'nano-theme-fonts)
 
 (defcustom nano-light-foreground "#37474F" ;; Blue Grey / L800
   "Default foreground color"
-  :type 'color :group 'nano-light)
+  :type 'color :group 'nano-theme-light)
 
 (defcustom nano-light-background "#FFFFFF" ;; White
   "Default background color"
-  :type 'color :group 'nano-light)
+  :type 'color :group 'nano-theme-light)
 
 (defcustom nano-light-highlight "#FAFAFA" ;; Very Light Grey
   "Highlight color is used to highlight part of the screen."
-  :type 'color :group 'nano-light)
+  :type 'color :group 'nano-theme-light)
 
 (defcustom nano-light-subtle "#ECEFF1" ;; Blue Grey / L50
   "Subtle color is used to suggest a physical area on the screen."
-  :type 'color :group 'nano-light)
+  :type 'color :group 'nano-theme-light)
 
 (defcustom nano-light-faded "#B0BEC5" ;; Blue Grey / L200
   "Faded face is for information that are less important."
-  :type 'color :group 'nano-light)
+  :type 'color :group 'nano-theme-light)
 
 (defcustom nano-light-salient "#673AB7" ;; Deep Purple / L500
   "Salient color is used for information that are important."
-  :type 'color :group 'nano-light)
+  :type 'color :group 'nano-theme-light)
 
 (defcustom nano-light-strong "#000000" ;; Black
   "Strong color is used for information of a structural nature."
-  :type 'color :group 'nano-light)
+  :type 'color :group 'nano-theme-light)
 
 (defcustom nano-light-popout "#FFAB91" ;; Deep Orange / L200
   "Popout colour is used for information that needs attention."
-  :type 'color :group 'nano-light)
+  :type 'color :group 'nano-theme-light)
 
 (defcustom nano-light-critical "#FF6F00" ;; Amber / L900
   "Critical face is for information that requires immediate action."
-  :type 'color :group 'nano-light)
+  :type 'color :group 'nano-theme-light)
 
 (defcustom nano-dark-foreground "#ECEFF4" ;; Snow Storm 3  / nord  6
   "Default foreground color"
-  :type 'color :group 'nano-dark)
+  :type 'color :group 'nano-theme-dark)
 
 (defcustom nano-dark-background "#2E3440" ;; Polar Night 0 / nord  0
   "Default background color"
-  :type 'color :group 'nano-dark)
+  :type 'color :group 'nano-theme-dark)
 
 (defcustom nano-dark-highlight "#3B4252" ;; Polar Night 1 / nord  1
   "Highdark color is used to highdark part of the screen."
-  :type 'color :group 'nano-dark)
+  :type 'color :group 'nano-theme-dark)
 
 (defcustom nano-dark-subtle "#434C5E" ;; Polar Night 2 / nord  2
   "Subtle color is used to suggest a physical area on the screen."
-  :type 'color :group 'nano-dark)
+  :type 'color :group 'nano-theme-dark)
 
 (defcustom nano-dark-faded "#677691" ;;
   "Faded face is for information that are less important."
-  :type 'color :group 'nano-dark)
+  :type 'color :group 'nano-theme-dark)
 
 (defcustom nano-dark-salient "#81A1C1" ;; Frost         / nord  9 
   "Salient color is used for information that are important."
-  :type 'color :group 'nano-dark)
+  :type 'color :group 'nano-theme-dark)
 
 (defcustom nano-dark-strong "#FFFFFF" ;; White
   "Strong color is used for information of a structural nature."
-  :type 'color :group 'nano-dark)
+  :type 'color :group 'nano-theme-dark)
 
 (defcustom nano-dark-popout "#D08770" ;; Aurora        / nord 12
   "Popout colour is used for information that needs attention."
-  :type 'color :group 'nano-dark)
+  :type 'color :group 'nano-theme-dark)
 
 (defcustom nano-dark-critical  "#EBCB8B" ;; Aurora        / nord 11
   "Critical face is for information that requires immediate action."
-  :type 'color :group 'nano-dark)
+  :type 'color :group 'nano-theme-dark)
 
 (defface nano-critical nil
   "Critical face is for information that requires immediate action.
@@ -225,7 +228,8 @@ color, typically a shade of red. It must be used scarcely."
   :group nil)
 
 (defface nano-critical-i nil
-  "Critical face inversed." :group nil)
+  "Critical face inversed."
+  :group nil)
 
 (defface nano-popout nil
   "Popout face is used for information that needs attention.
@@ -235,7 +239,8 @@ attention through the popout effect."
   :group nil)
 
 (defface nano-popout-i nil
-  "Popout face inversed." :group nil)
+  "Popout face inversed."
+  :group nil)
 
 (defface nano-strong nil
   "Strong face is used for information of a structural nature.
@@ -246,7 +251,8 @@ directory, etc."
   :group nil)
 
 (defface nano-strong-i nil
-  "Strong face inversed." :group nil)
+  "Strong face inversed."
+  :group nil)
 
 (defface nano-salient nil
   "Salient face is used for information that are important.
@@ -256,7 +262,8 @@ intensity as the default face. This is typically used for 
links."
   :group nil)
 
 (defface nano-salient-i nil
-  "Strong face inversed." :group nil)
+  "Strong face inversed."
+  :group nil)
 
 (defface nano-faded nil
   "Faded face is for information that are less important.
@@ -267,7 +274,8 @@ abused anyway)."
   :group nil)
 
 (defface nano-faded-i nil
-  "Faded face inversed." :group nil)
+  "Faded face inversed."
+  :group nil)
 
 (defface nano-subtle nil
   "Subtle face is used to suggest a physical area on the screen.
@@ -277,13 +285,16 @@ background color that is barely perceptible."
   :group nil)
 
 (defface nano-subtle-i nil
-  "Subtle face inversed." :group nil)
+  "Subtle face inversed."
+  :group nil)
 
 (defface nano-default nil
-  "Default face." :group nil)
+  "Default face."
+  :group nil)
 
 (defface nano-default-i nil
-  "Default face inversed." :group nil)
+  "Default face inversed."
+  :group nil)
 
 (defun nano-setup ()
   "Defaults settings for nano (optional)"
@@ -356,7 +367,7 @@ background color that is barely perceptible."
 
   ;; No toolbar
   (if (fboundp 'tool-bar-mode)
-      (tool-bar-mode nil))
+      (tool-bar-mode -1))
 
   ;; Default frame settings
   (setq default-frame-alist
@@ -391,63 +402,63 @@ background color that is barely perceptible."
       (message "Roboto Mono Nerd font has not been found on your system"))))
 
 
-(defun nano-light ()
-  "Nano theme light"
+;; (defun nano-light ()
+;;   "Nano theme light"
   
-  (interactive)
-  (setq widget-image-enable nil)
-  (setq x-underline-at-descent-line t)
-  (set-foreground-color nano-light-foreground)
-  (set-face-background 'internal-border nano-light-background (selected-frame))
-  (custom-set-variables '(frame-background-mode 'light))
-  (load-theme 'nano t)
-  (set-frame-parameter nil 'background-mode 'light)
-  (if (assq 'background-color default-frame-alist)
-      (setcdr (assq 'background-color default-frame-alist)
-              nano-light-background)
-    (add-to-list 'default-frame-alist
-                 `(background-color . ,nano-light-background)))
-  (if (assq 'background-mode default-frame-alist)
-      (setcdr (assq 'background-mode default-frame-alist) 'light)
-    (add-to-list 'default-frame-alist '(background-mode . light)))
-
-  (dolist (buffer (list " *Minibuf-0*" " *Echo Area 0*"
-                        " *Minibuf-1*" " *Echo Area 1*"))
-    (when (get-buffer buffer)
-      (with-current-buffer buffer
-        (face-remap-add-relative 'default 'nano-faded))))
-  (frame-set-background-mode (selected-frame))
-  (set-background-color nano-light-background))
-
-
-(defun nano-dark ()
-  "Nano theme dark"
+;;   (interactive)
+;;   (setq widget-image-enable nil)
+;;   (setq x-underline-at-descent-line t)
+;;   (set-foreground-color nano-light-foreground)
+;;   (set-face-background 'internal-border nano-light-background 
(selected-frame))
+;;   (custom-set-variables '(frame-background-mode 'light))
+;;   (load-theme 'nano t)
+;;   (set-frame-parameter nil 'background-mode 'light)
+;;   (if (assq 'background-color default-frame-alist)
+;;       (setcdr (assq 'background-color default-frame-alist)
+;;               nano-light-background)
+;;     (add-to-list 'default-frame-alist
+;;                  `(background-color . ,nano-light-background)))
+;;   (if (assq 'background-mode default-frame-alist)
+;;       (setcdr (assq 'background-mode default-frame-alist) 'light)
+;;     (add-to-list 'default-frame-alist '(background-mode . light)))
+
+;;   (dolist (buffer (list " *Minibuf-0*" " *Echo Area 0*"
+;;                         " *Minibuf-1*" " *Echo Area 1*"))
+;;     (when (get-buffer buffer)
+;;       (with-current-buffer buffer
+;;         (face-remap-add-relative 'default 'nano-faded))))
+;;   (frame-set-background-mode (selected-frame))
+;;   (set-background-color nano-light-background))
+
+
+;; (defun nano-dark ()
+;;   "Nano theme dark"
   
-  (interactive)
-  (setq widget-image-enable nil)
-  (setq x-underline-at-descent-line t)
-  (set-foreground-color nano-dark-foreground)
-  (set-face-background 'internal-border nano-dark-background (selected-frame))
-  (custom-set-variables '(frame-background-mode 'dark))
-  (load-theme 'nano t)
-  (set-frame-parameter nil 'background-mode 'dark)
-
-  (if (assq 'background-color default-frame-alist)
-      (setcdr (assq 'background-color default-frame-alist)
-              nano-dark-background)
-    (add-to-list 'default-frame-alist
-                 `(background-color . ,nano-dark-background)))
-  (if (assq 'background-mode default-frame-alist)
-      (setcdr (assq 'background-mode default-frame-alist) 'dark)
-    (add-to-list 'default-frame-alist '(background-mode . dark)))
-
-  (dolist (buffer (list " *Minibuf-0*" " *Echo Area 0*"
-                        " *Minibuf-1*" " *Echo Area 1*"))
-    (when (get-buffer buffer)
-      (with-current-buffer buffer
-        (face-remap-add-relative 'default 'nano-faded))))
-  (frame-set-background-mode (selected-frame))
-  (set-background-color nano-dark-background))
+;;   (interactive)
+;;   (setq widget-image-enable nil)
+;;   (setq x-underline-at-descent-line t)
+;;   (set-foreground-color nano-dark-foreground)
+;;   (set-face-background 'internal-border nano-dark-background 
(selected-frame))
+;;   (custom-set-variables '(frame-background-mode 'dark))
+;;   (load-theme 'nano t)
+;;   (set-frame-parameter nil 'background-mode 'dark)
+
+;;   (if (assq 'background-color default-frame-alist)
+;;       (setcdr (assq 'background-color default-frame-alist)
+;;               nano-dark-background)
+;;     (add-to-list 'default-frame-alist
+;;                  `(background-color . ,nano-dark-background)))
+;;   (if (assq 'background-mode default-frame-alist)
+;;       (setcdr (assq 'background-mode default-frame-alist) 'dark)
+;;     (add-to-list 'default-frame-alist '(background-mode . dark)))
+
+;;   (dolist (buffer (list " *Minibuf-0*" " *Echo Area 0*"
+;;                         " *Minibuf-1*" " *Echo Area 1*"))
+;;     (when (get-buffer buffer)
+;;       (with-current-buffer buffer
+;;         (face-remap-add-relative 'default 'nano-faded))))
+;;   (frame-set-background-mode (selected-frame))
+;;   (set-background-color nano-dark-background))
 
 
 ;; (defun inherit (face &optional inherit)
@@ -468,44 +479,44 @@ background color that is barely perceptible."
 ;;       properties)))
 
 
-;; ---  Theme ----------------------------------------------------------
-(let ((light     '((background light)))
-      (dark      '((background dark)))
-      ;; (tty-light '((type tty) (background light)))
-      ;; (tty-dark  '((type tty) (background dark)))
-      )
-
-  ;; Enforce nano fonts
-  (if nano-fonts-use
-      (custom-theme-set-faces
-       'nano
-       `(default ((,light (:foreground ,nano-light-foreground
-                           :weight     ,(face-attribute 'nano-mono :weight)
-                           :height     ,(face-attribute 'nano-mono :height)
-                           :family     ,(face-attribute 'nano-mono :family)))
-                  (,dark  (:foreground ,nano-dark-foreground
-                           :weight     ,(face-attribute 'nano-mono :weight)
-                           :height     ,(face-attribute 'nano-mono :height)
-                           :family     ,(face-attribute 'nano-mono :family)))))
-       `(nano-strong ((,light (:weight normal))
-                      (,dark  (:weight normal))))
-       `(variable-pitch  ((t (:weight ,(face-attribute 'nano-sans :weight)
-                              :height ,(face-attribute 'nano-sans :height)
-                              :family ,(face-attribute 'nano-sans 
:family)))))))
-
-    ;; Enforce nano fonts
-  (if (not nano-fonts-use)
-      (custom-theme-set-faces
-       'nano
-       `(default ((,light (:foreground ,nano-light-foreground))
-                  (,dark  (:foreground ,nano-dark-foreground))))
-       `(nano-strong ((,light (:weight bold))
-                      (,dark  (:weight bold))))))
+(defun nano-theme (mode)
+
+  (set-frame-parameter nil 'background-mode mode)
+  (set frame-background-mode mode)
+  (frame-set-background-mode (selected-frame))
+
 
+  (let ((light     '((background light)))
+        (dark      '((background dark)))
+        (theme      (if (eq mode 'dark)
+                       'nano-dark
+                     'nano-light)))
+
+    (if nano-fonts-use
+        (custom-theme-set-faces theme
+         `(default ((,light (:foreground ,nano-light-foreground
+                             :weight     ,(face-attribute 'nano-mono :weight)
+                             :height     ,(face-attribute 'nano-mono :height)
+                             :family     ,(face-attribute 'nano-mono :family)))
+                    (,dark  (:foreground ,nano-dark-foreground
+                             :weight     ,(face-attribute 'nano-mono :weight)
+                             :height     ,(face-attribute 'nano-mono :height)
+                             :family     ,(face-attribute 'nano-mono 
:family)))))
+         `(nano-strong ((,light (:weight normal))
+                        (,dark  (:weight normal))))
+         `(variable-pitch  ((t (:weight ,(face-attribute 'nano-sans :weight)
+                                :height ,(face-attribute 'nano-sans :height)
+                                :family ,(face-attribute 'nano-sans 
:family)))))))
+
+    (if (not nano-fonts-use)
+        (custom-theme-set-faces theme
+         `(default ((,light (:foreground ,nano-light-foreground))
+                    (,dark  (:foreground ,nano-dark-foreground))))
+         `(nano-strong ((,light (:weight bold))
+                        (,dark  (:weight bold))))))
 
   
-  (custom-theme-set-faces
-   'nano
+  (custom-theme-set-faces theme
    
    ;; --- Base ---------------------------------------------------------   
    `(cursor ((,light (:foreground ,nano-light-background
@@ -835,7 +846,6 @@ background color that is barely perceptible."
    '(message-mml                    ((t (:inherit nano-popout))))
    '(message-separator              ((t (:inherit nano-faded))))
 
-   
    ;; --- Outline ------------------------------------------------------
    '(outline-1                      ((t (:inherit nano-strong))))
    '(outline-2                      ((t (:inherit nano-strong))))
@@ -971,7 +981,6 @@ background color that is barely perceptible."
    '(mu4e-warning-face                      ((t (:inherit nano-popout))))
 
    ;; --- GNUS ---------------------------------------------------------
-
    '(gnus-button                            ((t (:inherit nano-salient))))
    '(gnus-cite-1                            ((t (:inherit nano-faded)))) 
    '(gnus-cite-10                           ((t (:inherit nano-faded))))
@@ -1087,7 +1096,6 @@ background color that is barely perceptible."
     '(rst-reference                         ((t (:inherit nano-salient))))
     '(rst-transition                        ((t (:inherit nano-default))))
 
-
     ;; --- Markdown ----------------------------------------------------
     '(markdown-blockquote-face              ((t (:inherit nano-default))))
     '(markdown-bold-face                     ((t (:inherit nano-strong))))
@@ -1132,7 +1140,6 @@ background color that is barely perceptible."
     '(markdown-table-face                   ((t (:inherit nano-default))))
     '(markdown-url-face                     ((t (:inherit nano-salient))))
 
-
     ;; --- Terminal ----------------------------------------------------
     '(term-bold        ((t (:inherit nano-strong))))
     '(term-color-black ((t (:inherit default))))
@@ -1150,10 +1157,12 @@ background color that is barely perceptible."
                              :background "#FFF9C4"))))  ;; material color 
yellow L100
     ))
 
-;;;###autoload
-(when (and (boundp 'custom-theme-load-path) load-file-name)
-  (add-to-list 'custom-theme-load-path
-               (file-name-as-directory (file-name-directory load-file-name))))
+  (dolist (buffer (list " *Minibuf-0*" " *Echo Area 0*"
+                        " *Minibuf-1*" " *Echo Area 1*"))
+    (when (get-buffer buffer)
+      (with-current-buffer buffer
+        (face-remap-add-relative 'default 'nano-faded)))))
+
 
-(provide-theme 'nano)
+(provide 'nano-theme)
 ;;; nano-theme.el ends here



reply via email to

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