branch: externals/cursory
commit adfa085b9ff8edd38b3d4bcc597a09ed02870f06
Author: Protesilaos Stavrou <i...@protesilaos.com>
Commit: Protesilaos Stavrou <i...@protesilaos.com>

    Persist cursor color by relying on the enable-theme-functions
---
 cursory.el | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/cursory.el b/cursory.el
index 1f51fb332e..bb8dcd24af 100644
--- a/cursory.el
+++ b/cursory.el
@@ -6,7 +6,7 @@
 ;; Maintainer: Protesilaos Stavrou <i...@protesilaos.com>
 ;; URL: https://github.com/protesilaos/cursory
 ;; Version: 1.1.0
-;; Package-Requires: ((emacs "27.1"))
+;; Package-Requires: ((emacs "29.1"))
 ;; Keywords: convenience, cursor
 
 ;; This file is NOT part of GNU Emacs.
@@ -414,18 +414,26 @@ Can be assigned to `kill-emacs-hook'."
               (insert-file-contents file)
               (read (current-buffer)))))))
 
+(defun cursory-set-faces (&rest _)
+  "Set Cursory faces.
+Add this to the `enable-theme-functions'."
+  (when-let* ((last cursory-last-selected-preset)
+              (styles (cursory--get-preset-properties last))
+              (color-value (plist-get styles :cursor-color)))
+    (cursory--set-cursor color-value)))
+
 ;;;###autoload
 (define-minor-mode cursory-mode
-  "Persist Cursory presets.
-Arrange to store and restore the current Cursory preset when
-closing and restarting Emacs."
+  "Persist Cursory presets and other styles."
   :global t
   (if cursory-mode
       (progn
         (add-hook 'kill-emacs-hook #'cursory-store-latest-preset)
-        (add-hook 'cursory-set-preset-hook #'cursory-store-latest-preset))
+        (add-hook 'cursory-set-preset-hook #'cursory-store-latest-preset)
+        (add-hook 'enable-theme-functions #'cursory-set-faces))
     (remove-hook 'kill-emacs-hook #'cursory-store-latest-preset)
-    (remove-hook 'cursory-set-preset-hook #'cursory-store-latest-preset)))
+    (remove-hook 'cursory-set-preset-hook #'cursory-store-latest-preset)
+    (remove-hook 'enable-theme-functions #'cursory-set-faces)))
 
 (provide 'cursory)
 ;;; cursory.el ends here

Reply via email to