From 155da77a324f28fd37f6167d5c843c491dc3327d Mon Sep 17 00:00:00 2001 From: Lars Tveito Date: Sat, 20 May 2017 17:55:40 +0200 Subject: [PATCH] Fixes #14 In `focus-read-only-mode` the `cursor-type` was unconditionally set to `t`, and did not restore the users customized cursor type. This is fixed by storing the original value of `cursor-type` in `focus-cursor-type`. --- focus.el | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/focus.el b/focus.el index b22a05f..c2bb6d4 100644 --- a/focus.el +++ b/focus.el @@ -70,6 +70,9 @@ Things that are defined include `symbol', `list', `sexp', :type '(float) :group 'focus) +(defvar focus-cursor-type cursor-type + "Used to restore the users `cursor-type'") + (defvar focus-current-thing nil "Overrides the choice of thing dictated by `focus-mode-to-thing' if set.") @@ -236,7 +239,7 @@ This is added to the `pre-command-hook' when (when (and focus-read-only-mode (not (member last-command '(focus-next-thing focus-prev-thing)))) (when focus-read-only-blink-timer (cancel-timer focus-read-only-blink-timer)) - (setq cursor-type t) + (setq cursor-type focus-cursor-type) (setq focus-read-only-blink-timer (run-at-time focus-read-only-blink-seconds nil 'focus-read-only-hide-cursor (current-buffer))))) @@ -256,7 +259,7 @@ Enables `read-only-mode', hides the cursor and adds Disables `read-only-mode' and shows the cursor again. It cleans up the `focus-read-only-blink-timer' and hooks." (read-only-mode -1) - (setq cursor-type t) + (setq cursor-type focus-cursor-type) (when focus-read-only-blink-timer (cancel-timer focus-read-only-blink-timer)) (setq focus-read-only-blink-timer nil) @@ -293,6 +296,8 @@ up the `focus-read-only-blink-timer' and hooks." (define-key map (kbd "i") 'turn-off-focus-read-only-mode) (define-key map (kbd "q") 'turn-off-focus-read-only-mode) map) + (when cursor-type + (setq focus-cursor-type cursor-type)) (if focus-read-only-mode (focus-read-only-init) (focus-read-only-terminate))) (provide 'focus)