branch: externals/cursory commit 1b271486e28a299ad489d151a92eaa1788c7dd41 Author: Protesilaos Stavrou <i...@protesilaos.com> Commit: Protesilaos Stavrou <i...@protesilaos.com>
Add cursory-set-preset-hook --- README.org | 6 ++++++ cursory.el | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.org b/README.org index 6b02f30c85..55b8c3649c 100644 --- a/README.org +++ b/README.org @@ -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. diff --git a/cursory.el b/cursory.el index 23c013036b..97b92d7251 100644 --- a/cursory.el +++ b/cursory.el @@ -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))) ;;;###autoload