[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/cursory 83402d4f3e 2/2: Define cursory-mode to store pr
From: |
ELPA Syncer |
Subject: |
[elpa] externals/cursory 83402d4f3e 2/2: Define cursory-mode to store presets |
Date: |
Thu, 25 Apr 2024 00:57:45 -0400 (EDT) |
branch: externals/cursory
commit 83402d4f3e1f11be27c166e11ced64ba2ec83377
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Define cursory-mode to store presets
---
README.org | 10 ++++++++--
cursory.el | 13 +++++++++++++
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/README.org b/README.org
index fc4aaf842f..91b2de719c 100644
--- a/README.org
+++ b/README.org
@@ -209,6 +209,12 @@ be restored with the ~cursory-restore-latest-preset~
function.
[[#h:b3c38cda-48d3-4715-9c46-6b9844a6da86][Sample configuration]].
+[ The following is part of {{{development-version}}}. ]
+
+Instead of manually storing the latest Cursory preset, users can
+enable the ~cursory-mode~. It arranges to track the latest preset
+after using ~cursory-set-preset~ or closing Emacs.
+
* Installation
:PROPERTIES:
:CUSTOM_ID: h:6dd596f2-d98b-4275-b25e-495e2a0616bf
@@ -280,8 +286,8 @@ Remember to read the doc string of each of these variables
or functions.
;; Set last preset or fall back to desired style from `cursory-presets'.
(cursory-set-preset (or (cursory-restore-latest-preset) 'bar))
-;; The other side of `cursory-restore-latest-preset'.
-(add-hook 'kill-emacs-hook #'cursory-store-latest-preset)
+;; Arrange to keep track of the latest Cursory preset.
+(cursory-mode 1)
;; We have to use the "point" mnemonic, because C-c c is often the
;; suggested binding for `org-capture'.
diff --git a/cursory.el b/cursory.el
index 1c6587832a..da7d7e56a6 100644
--- a/cursory.el
+++ b/cursory.el
@@ -390,5 +390,18 @@ Can be assigned to `kill-emacs-hook'."
(insert-file-contents file)
(read (current-buffer)))))))
+;;;###autoload
+(define-minor-mode cursory-mode
+ "Persist Cursory presets.
+Arrange to store and restore the current Cursory preset when
+closing and restarting Emacs."
+ :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))
+ (remove-hook 'kill-emacs-hook #'cursory-store-latest-preset)
+ (remove-hook 'cursory-set-preset-hook #'cursory-store-latest-preset)))
+
(provide 'cursory)
;;; cursory.el ends here