[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/nano-theme 7e23364 3/4: Code refactoring
From: |
ELPA Syncer |
Subject: |
[elpa] externals/nano-theme 7e23364 3/4: Code refactoring |
Date: |
Tue, 5 Oct 2021 10:57:20 -0400 (EDT) |
branch: externals/nano-theme
commit 7e23364973fcd556a1c7b4c88f4214d94872144f
Author: Nicolas P. Rougier <Nicolas.Rougier@inria.fr>
Commit: Nicolas P. Rougier <Nicolas.Rougier@inria.fr>
Code refactoring
---
nano-dark-theme.el | 16 +-------
nano-light-theme.el | 94 ++++++++++++++++++++++++++++---------------
nano-theme.el | 113 +++++++++++++++++++++++++++++-----------------------
3 files changed, 127 insertions(+), 96 deletions(-)
diff --git a/nano-dark-theme.el b/nano-dark-theme.el
index 128aff4..8502809 100644
--- a/nano-dark-theme.el
+++ b/nano-dark-theme.el
@@ -39,25 +39,13 @@
(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)
+(when load-file-name
(add-to-list 'custom-theme-load-path
(file-name-as-directory (file-name-directory load-file-name))))
diff --git a/nano-light-theme.el b/nano-light-theme.el
index a3c22b5..d003c96 100644
--- a/nano-light-theme.el
+++ b/nano-light-theme.el
@@ -1,35 +1,65 @@
+;;; nano-light-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-light
+ "N Λ N O light theme")
+
+(set-foreground-color nano-light-foreground)
+(set-background-color nano-light-background)
+(nano-theme 'light)
+
+
+(defun nano-light ()
+ "Nano theme light"
-(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)
+ (set-foreground-color nano-light-foreground)
+ (set-background-color nano-light-background)
+ (load-theme 'nano-light t))
+
+;;;###autoload
+(when load-file-name
+ (add-to-list 'custom-theme-load-path
+ (file-name-as-directory (file-name-directory load-file-name))))
+
+(provide-theme 'nano-light)
+;;; nano-light-theme.el ends here
+
+
+
diff --git a/nano-theme.el b/nano-theme.el
index 8b47b86..9d03592 100644
--- a/nano-theme.el
+++ b/nano-theme.el
@@ -404,61 +404,26 @@ background color that is barely perceptible."
;; (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))
+;; (setq frame-background-mode 'light)
+;; (set-foreground-color nano-light-foreground)
+;; (set-background-color nano-light-background)
+;; (nano-theme 'light))
;; (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)
+;; (setq frame-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))
+;; (set-foreground-color nano-dark-foreground)
+;; (set-background-color nano-dark-background)
+;; (nano-theme 'dark))
;; (defun inherit (face &optional inherit)
@@ -479,12 +444,56 @@ background color that is barely perceptible."
;; properties)))
-(defun nano-theme (mode)
+(defun nano-new-frame (&optional mode)
+ "This funcion creates a new frame in light or dark 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))
+
+(defun nano-dark ()
+ "Load the nano dark theme on current frame."
+
+ (interactive)
+ (set-foreground-color nano-dark-foreground)
+ (set-background-color nano-dark-background)
+ (load-theme 'nano-dark t))
- (set-frame-parameter nil 'background-mode mode)
- (setq frame-background-mode mode)
- (frame-set-background-mode (selected-frame))
+(defun nano-light ()
+ "Load the nano light theme on current frame."
+ (interactive)
+ (set-foreground-color nano-light-foreground)
+ (set-background-color nano-light-background)
+ (load-theme 'nano-light t))
+
+
+(defun nano-theme (mode)
+ "Apply the nano theme according to MODE which can be 'dark or 'light."
(let ((light '((background light)))
(dark '((background dark)))
@@ -492,6 +501,10 @@ background color that is barely perceptible."
'nano-dark
'nano-light)))
+ (set-frame-parameter nil 'background-mode mode)
+ (setq frame-background-mode mode)
+ (frame-set-background-mode (selected-frame))
+
(if nano-fonts-use
(custom-theme-set-faces theme
`(default ((,light (:foreground ,nano-light-foreground