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

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

[nongnu] elpa/moe-theme b0ca7d3d54 111/352: Fix screen flashing in GUI v


From: ELPA Syncer
Subject: [nongnu] elpa/moe-theme b0ca7d3d54 111/352: Fix screen flashing in GUI version Emacs.
Date: Fri, 7 Jan 2022 03:59:11 -0500 (EST)

branch: elpa/moe-theme
commit b0ca7d3d543469e04712b0ba0d20892492ae2bad
Author: kuanyui <azazabc123@gmail.com>
Commit: kuanyui <azazabc123@gmail.com>

    Fix screen flashing in GUI version Emacs.
---
 moe-theme-switcher.el | 30 ++++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)

diff --git a/moe-theme-switcher.el b/moe-theme-switcher.el
index 309d4321a3..0c83c04798 100644
--- a/moe-theme-switcher.el
+++ b/moe-theme-switcher.el
@@ -21,10 +21,25 @@ Take Keelung, Taiwan(25N,121E) for example, you can set 
like this:
        (setq calendar-longitude +121)"
 )
 
+(defvar moe-now nil
+  "Variable recording which theme (moe-dark or light) is being used.")
+
+(defun moe-load-theme (switch-to)
+  "Avoid unnecessary load-theme and screen flashing in GUI version Emacs"
+  (cond ((equal switch-to "light")
+         (if (not (equal moe-now "light"))
+           (progn (load-theme 'moe-light t)
+                  (setq moe-now "light"))))
+        ((equal switch-to "dark")
+         (if (not (equal moe-now "dark"))
+           (progn (load-theme 'moe-dark t)
+                  (setq moe-now "dark"))))))
+
 (defun switch-at-fixed-time ()
   (let ((now (string-to-int (format-time-string "%H"))))
     (if (and (>= now 06) (<= now 18))
-        (load-theme 'moe-light t) (load-theme 'moe-dark t))
+        (moe-load-theme "light")
+      (moe-load-theme "dark"))
     nil))
 
 ;; (Thanks for letoh!)
@@ -77,9 +92,9 @@ Take Keelung, Taiwan(25N,121E) for example, you can set like 
this:
 ;; Excute every minute.
 (defun switch-by-locale ()
   (if (equal 24h/sunrise 'polar-night)  ;If polar-night...moe-dark!
-      (load-theme 'moe-dark t)
+      (moe-load-theme "dark")
     (if (equal 24h/sunrise 'midnight-sun) ;If midnight-sun...moe-light!
-        (load-theme 'moe-light t)
+        (moe-load-theme "light")
       (progn
        (let ((now (list (string-to-number (format-time-string "%H"))
                         (string-to-number (format-time-string "%M")))))
@@ -93,11 +108,12 @@ Take Keelung, Taiwan(25N,121E) for example, you can set 
like this:
                    (and 
                     (= (car now) (car 24h/sunset)) 
                     (< (second now) (second 24h/sunset)))))
-             (load-theme 'moe-light t)
-           (load-theme 'moe-dark t)
+             (moe-load-theme "light")
+           (moe-load-theme "dark")
            ))))))
 
 (defun moe-theme-auto-switch ()
+  "Automatically switch between dark and light moe-theme."
   (interactive)
   (if (boundp '24h/sunrise)
       (switch-by-locale)
@@ -117,9 +133,7 @@ Take Keelung, Taiwan(25N,121E) for example, you can set 
like this:
 
 (moe-theme-auto-switch)
 
-(run-with-timer 0 (* 1 60) 'moe-theme-auto-switch) 
+(run-with-timer 0 (* 1 60) 'moe-theme-auto-switch)
 
 (provide 'moe-theme-switcher)
 
-
-



reply via email to

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