[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/moe-theme 9373bdc918 093/352: Fixed so that the theme won'
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/moe-theme 9373bdc918 093/352: Fixed so that the theme won't be reapplied if it was the last theme to be applied. |
Date: |
Fri, 7 Jan 2022 03:59:09 -0500 (EST) |
branch: elpa/moe-theme
commit 9373bdc918df5d3262c07691b17e7eb819466bee
Author: Tobias J <toja92@gmail.com>
Commit: Tobias J <toja92@gmail.com>
Fixed so that the theme won't be reapplied if it was the last theme to be
applied.
Fixed a syntax error (oops). The code now also compiles without errors.
I've not tested if polar night or midnight sun works as intended.
---
moe-theme-switcher.el | 61 +++++++++++++++++++++++++++------------------------
1 file changed, 32 insertions(+), 29 deletions(-)
diff --git a/moe-theme-switcher.el b/moe-theme-switcher.el
index a10317b7a0..94ebd9bb4f 100644
--- a/moe-theme-switcher.el
+++ b/moe-theme-switcher.el
@@ -23,13 +23,13 @@ Take Keelung, Taiwan(25N,121E) for example, you can set
like this:
(setq calendar-longitude +121)"
)
-(defun switch-at-fixed-time ()
+(defun moe-theme-switch-at-fixed-time ()
(let ((now (string-to-number (format-time-string "%H"))))
(if (and (>= now 06) (<= now 18))
(load-theme 'moe-light t) (load-theme 'moe-dark t))
nil))
-(defun float-to-time-list (time)
+(defun moe-theme-float-to-time-list (time)
"Converts time represented as a float to a list
Example:
> (float-to-time-list 4.5)
@@ -41,37 +41,40 @@ Example:
(list hours minutes)))
;; Excute every minute.
-(defun switch-by-locale ()
+(defun moe-theme-switch-by-locale ()
(let* ((sunrise-sunset (solar-sunrise-sunset (calendar-current-date)))
- (length-of-day (mapcar
- (lambda (x) (string-to-number x))
- (split-string (car (cddr sunrise-sunset ":"))))))
- (progn
- (if (equal length-of-day '(0 0)) ; Polar night
- (load-theme 'moe-dark t)
- (if (equal length-of-day '(24 0)) ; Midnight sun
- (load-theme 'moe-light t)
- (let ((now (list (string-to-number (format-time-string "%H"))
- (string-to-number (format-time-string "%M"))))
- (sunrise (float-to-time-list (caar sunrise-sunset)))
- (sunset (float-to-time-list (car (cadr sunrise-sunset)))))
- (if (and
- (or (> (car now) (car sunrise))
- (and (= (car now) (car sunrise))
- (>= (cdr now) (cdr sunrise))))
- (or (< (car now) (car sunset))
- (and (= (car now) (car sunset))
- (< (cdr now) (cdr sunset)))))
- (load-theme 'moe-light t)
- (load-theme 'moe-dark t))))))))
+ (length-of-day (mapcar
+ (lambda (x) (string-to-number x))
+ (split-string (car (cddr sunrise-sunset)) ":"))))
+ (if (equal length-of-day '(0 0)) ; Polar night
+ (load-theme 'moe-dark t)
+ (if (equal length-of-day '(24 0)) ; Midnight sun
+ (load-theme 'moe-light t)
+ (let ((now (list (string-to-number (format-time-string "%H"))
+ (string-to-number (format-time-string "%M"))))
+ (sunrise (moe-theme-float-to-time-list (caar sunrise-sunset)))
+ (sunset (moe-theme-float-to-time-list (car (cadr
sunrise-sunset)))))
+ ;;Check that the time is between sunrise and sunset
+ (if (and
+ (or (> (car now) (car sunrise))
+ (and (= (car now) (car sunrise))
+ (>= (cdr now) (cdr sunrise))))
+ (or (< (car now) (car sunset))
+ (and (= (car now) (car sunset))
+ (< (cdr now) (cdr sunset)))))
+ (load-theme 'moe-light t)
+ (load-theme 'moe-dark t)))))))
(defun moe-theme-auto-switch ()
(interactive)
- (if (and moe-theme-switch-by-sunrise-and-sunset
- (boundp 'calendar-longitude)
- (boundp 'calendar-latitude))
- (switch-by-locale)
- (switch-at-fixed-time)))
+ ;; Only do something if the theme is not the last applied theme
+ (if (not (or (equal '(moe-light) (last custom-enabled-themes))
+ (equal '(moe-dark) (last custom-enabled-themes))))
+ (if (and moe-theme-switch-by-sunrise-and-sunset
+ (boundp 'calendar-longitude)
+ (boundp 'calendar-latitude))
+ (moe-theme-switch-by-locale)
+ (moe-theme-switch-at-fixed-time))))
(moe-theme-auto-switch)
- [nongnu] elpa/moe-theme 5d20807ce4 056/352: 1. I didn't know that it's "kyun" instead of "chu" @A@... http://tinyurl.com/ozsu6bb, (continued)
- [nongnu] elpa/moe-theme 5d20807ce4 056/352: 1. I didn't know that it's "kyun" instead of "chu" @A@... http://tinyurl.com/ozsu6bb, ELPA Syncer, 2022/01/07
- [nongnu] elpa/moe-theme e8f80c670f 057/352: ......";;; Code"?, ELPA Syncer, 2022/01/07
- [nongnu] elpa/moe-theme 94a1569a15 059/352: 1. Add installation guide for MELPA repository. 2. Update information for package.el, ELPA Syncer, 2022/01/07
- [nongnu] elpa/moe-theme 3bafb27084 062/352: 1. Add full Eshell support ; -) 2. Improve gnus., ELPA Syncer, 2022/01/07
- [nongnu] elpa/moe-theme da8fe2e095 068/352: Add face for hlinum.el., ELPA Syncer, 2022/01/07
- [nongnu] elpa/moe-theme 308c42f4d3 071/352: [Fix #4] Remove faulty local variables, ELPA Syncer, 2022/01/07
- [nongnu] elpa/moe-theme f99a55d62a 072/352: Merge pull request #5 from lunaryorn/patch-1, ELPA Syncer, 2022/01/07
- [nongnu] elpa/moe-theme bce815a9ac 074/352: More light faces for Agenda., ELPA Syncer, 2022/01/07
- [nongnu] elpa/moe-theme 250a228517 080/352: Fix wrong bg-color of "org-agenda-date" on Org-mode 8.2.3c., ELPA Syncer, 2022/01/07
- [nongnu] elpa/moe-theme 21f83424b1 089/352: Complete redone of the theme switcher., ELPA Syncer, 2022/01/07
- [nongnu] elpa/moe-theme 9373bdc918 093/352: Fixed so that the theme won't be reapplied if it was the last theme to be applied.,
ELPA Syncer <=
- [nongnu] elpa/moe-theme ab9cb998a3 091/352: Match comint mode colours with eshell., ELPA Syncer, 2022/01/07
- [nongnu] elpa/moe-theme ce01e0af47 094/352: Switch to gray tables in the dark theme., ELPA Syncer, 2022/01/07
- [nongnu] elpa/moe-theme 96d21bbf58 097/352: Merge pull request #15 from ToJa92/master, ELPA Syncer, 2022/01/07
- [nongnu] elpa/moe-theme 72efc3bfd3 099/352: Lighter green for arguments in js2 mode., ELPA Syncer, 2022/01/07
- [nongnu] elpa/moe-theme 0de97171e1 098/352: What am I doing...orz, ELPA Syncer, 2022/01/07
- [nongnu] elpa/moe-theme 5f5d77802f 012/352: 1. Modified README and improve the themes., ELPA Syncer, 2022/01/07
- [nongnu] elpa/moe-theme 43f162a68d 013/352: 1. Fix flaw in twmode when switch moe-dark and moe-light., ELPA Syncer, 2022/01/07
- [nongnu] elpa/moe-theme c9273d4c12 016/352: 1.Fix invisible org-special-keyword when switch from moe-dark from moe light., ELPA Syncer, 2022/01/07
- [nongnu] elpa/moe-theme a4f9e0bbc1 017/352: 1. Add "auto-switch-theme" instructions in README.md., ELPA Syncer, 2022/01/07
- [nongnu] elpa/moe-theme 7a87892887 019/352: 1. Fix invisible secondary-selection and smerge., ELPA Syncer, 2022/01/07