[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/cursory 45a1d36e64 3/5: Document some examples to use t
From: |
ELPA Syncer |
Subject: |
[elpa] externals/cursory 45a1d36e64 3/5: Document some examples to use the cursory-set-preset-hook |
Date: |
Sat, 14 Sep 2024 03:58:04 -0400 (EDT) |
branch: externals/cursory
commit 45a1d36e642f23079682aeccebc9051cf8d7338f
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Document some examples to use the cursory-set-preset-hook
---
README.org | 37 +++++++++++++++++++++++++++++++++----
1 file changed, 33 insertions(+), 4 deletions(-)
diff --git a/README.org b/README.org
index 7a26d3634d..e253784ffb 100644
--- a/README.org
+++ b/README.org
@@ -84,10 +84,12 @@ minibuffer completion when there are multiple presets, else
sets the
single preset outright.
#+vindex: cursory-set-preset-hook
-The ~cursory-set-preset~ comman calls the ~cursory-set-preset-hook~
-as its final step. Use this to run other functions after changing the
-cursor (e.g. a function that checks the style Cursory used to apply an
-appropriate color). [ This hook is part of {{{development-version}}}. ]
+#+vindex: cursory-last-selected-preset
+The ~cursory-set-preset~ comman calls the ~cursory-set-preset-hook~ as
+its final step. Use this to run other functions after changing the
+cursor ([[#h:035c0942-3163-436a-b0e3-67b1b669d109][Example hooks after setting
a preset]]). The variable
+~cursory-last-selected-preset~ may prove useful. [ This hook is part
+of {{{development-version}}}. ]
Presets consist of an arbitrary symbol broadly described the style set
followed by a list of properties that govern the cursor type in the
@@ -215,6 +217,33 @@ Instead of manually storing the latest Cursory preset,
users can
enable the ~cursory-mode~. It arranges to track the latest preset each
time after using ~cursory-set-preset~ or Emacs is closed.
+** Example hooks after setting a preset
+:PROPERTIES:
+:CUSTOM_ID: h:035c0942-3163-436a-b0e3-67b1b669d109
+:END:
+
+The ~cursory-set-preset-hook~ is a normal hook (where functions are
+called without any arguments), which is called after the command
+~cursory-set-preset~. Here are some ideas on how to use it:
+
+#+begin_src emacs-lisp
+;; Imagine you have a preset where you want minimal cursor styles.
+;; You call this `focus' and want when you switch to it to change the
+;; cursor color.
+(defun my-cursory-change-color ()
+"Change to a subtle color when the `focus' Cursory preset is selected."
+ (if (eq cursory-last-selected-preset 'focus)
+ (set-face-background 'cursor "#999999")
+ (face-spec-recalc 'cursor nil)))
+
+(defun my-cursory-change-color-disable-line-numbers ()
+ "Disable line numbers if the Cursory preset is `presentation' or `focus'."
+ (when (member cursory-last-selected-preset '(presentation focus))
+ (display-line-numbers-mode -1)))
+#+end_src
+
+I am happy to include more examples here, if users have any questions.
+
* Installation
:PROPERTIES:
:CUSTOM_ID: h:6dd596f2-d98b-4275-b25e-495e2a0616bf