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

    Define cursory-set-last-or-fallback function
---
 cursory.el | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/cursory.el b/cursory.el
index 988edc45a5..81c7934cd3 100644
--- a/cursory.el
+++ b/cursory.el
@@ -396,6 +396,21 @@ Call `cursory-set-preset-hook' as a final step."
       (cursory--set-preset-subr preset)
     (user-error "Cannot determine preset `%s'" preset)))
 
+;;;###autoload
+(defun cursory-set-last-or-fallback ()
+  "Set the `cursory-last-selected-preset' or fall back to whatever known 
values.
+This function is useful when starting up Emacs, such as in the
+`after-init-hook'."
+  (cursory-set-preset
+   (cond
+    ((when-let* ((last-preset (cursory-restore-latest-preset))
+                 (_ (cursory--preset-p last-preset)))
+       last-preset))
+    ((cursory--preset-p 'box)
+     'box)
+    (t
+     'cursory-defaults))))
+
 ;;;###autoload
 (defun cursory-store-latest-preset ()
   "Write latest cursor state to `cursory-latest-state-file'.

Reply via email to