1b271486e28a299ad489d151a92eaa1788c7dd41 — Protesilaos Stavrou 7 months ago a91da4e
Add cursory-set-preset-hook
2 files changed, 14 insertions(+), 1 deletions(-)

M cursory.el
M README.org => README.org +6 -0
@@ 85,6 85,12 @@ The user option ~cursory-presets~ holds the presets.  The command
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}}}. ]

Presets consist of an arbitrary symbol broadly described the style set
followed by a list of properties that govern the cursor type in the
active and inactive windows, as well as cursor blinking variables.

M cursory.el => cursory.el +8 -1
@@ 253,6 253,12 @@ Saving is done by the `cursory-store-latest-preset' function."
  :package-version '(cursory . "0.1.0")
  :group 'cursory)

(defcustom cursory-set-preset-hook nil
  "Normal hook that runs after `cursory-set-preset'."
  :type 'hook
  :package-version '(cursory . "1.1.0")
  :group 'cursory)

(defvar cursory--style-hist '()
  "Minibuffer history of `cursory--set-cursor-prompt'.")

@@ 332,7 338,8 @@ current buffer."
                        blink-cursor-delay delay)
          ;; We only want to save global values in `cursory-store-latest-preset'.
          (add-to-history 'cursory--style-hist (format "%s" preset)))
        (blink-cursor-mode (plist-get styles :blink-cursor-mode)))
        (blink-cursor-mode (plist-get styles :blink-cursor-mode))
        (run-hooks 'cursory-set-preset-hook))
    (user-error "Cannot determine styles of preset `%s'" preset)))