[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/focus fe94e0de69 43/82: Split activation/deactivation into
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/focus fe94e0de69 43/82: Split activation/deactivation into functions |
Date: |
Tue, 6 Sep 2022 04:58:56 -0400 (EDT) |
branch: elpa/focus
commit fe94e0de69dd8085eaaa71d1ca73dffa6f7a40a8
Author: Lars Tveito <larstvei@ifi.uio.no>
Commit: Lars Tveito <larstvei@ifi.uio.no>
Split activation/deactivation into functions
---
focus.el | 30 +++++++++++++++++++++++-------
1 file changed, 23 insertions(+), 7 deletions(-)
diff --git a/focus.el b/focus.el
index 578243ac34..31e4b2b53c 100644
--- a/focus.el
+++ b/focus.el
@@ -197,6 +197,28 @@ This is added to the `pre-command-hook' when
(run-at-time focus-read-only-blink-seconds nil
'focus-read-only-hide-cursor (current-buffer)))))
+(defun focus-read-only-init ()
+ "Run when `focus-read-only-mode' is activated.
+Enables `read-only-mode', hides the cursor and adds
+`focus-read-only-cursor-blink' to `pre-command-hook'. Also
+`focus-read-only-terminate' is added to the `kill-buffer-hook'."
+ (read-only-mode 1)
+ (setq cursor-type nil)
+ (add-hook 'pre-command-hook 'focus-read-only-cursor-blink nil t)
+ (add-hook 'kill-buffer-hook 'focus-read-only-terminate t))
+
+(defun focus-read-only-terminate ()
+ "Run when `focus-read-only-mode' is deactivated.
+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)
+ (when focus-read-only-blink-timer
+ (cancel-timer focus-read-only-blink-timer))
+ (setq focus-read-only-blink-timer nil)
+ (remove-hook 'pre-command-hook 'focus-read-only-cursor-blink t)
+ (remove-hook 'kill-buffer-hook 'focus-read-only-terminate t))
+
(defun turn-off-focus-read-only-mode ()
"Turn off `focus-read-only-mode'."
(interactive)
@@ -223,13 +245,7 @@ This is added to the `pre-command-hook' when
(define-key map (kbd "i") 'turn-off-focus-read-only-mode)
(define-key map (kbd "q") 'turn-off-focus-read-only-mode)
map)
- (read-only-mode (if focus-read-only-mode 1 -1))
- (when focus-read-only-blink-timer (cancel-timer focus-read-only-blink-timer))
- (setq cursor-type (not focus-read-only-mode))
- (setq focus-read-only-blink-timer nil)
- (remove-hook 'pre-command-hook 'focus-read-only-cursor-blink t)
- (when focus-read-only-mode
- (add-hook 'pre-command-hook 'focus-read-only-cursor-blink nil t)))
+ (if focus-read-only-mode (focus-read-only-init) (focus-read-only-terminate)))
(provide 'focus)
;;; focus.el ends here
- [nongnu] elpa/focus 663205443c 21/82: Forgot to rename variables everywhere, (continued)
- [nongnu] elpa/focus 663205443c 21/82: Forgot to rename variables everywhere, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 4d31363bf9 54/82: Use cl-lib function instead of cl.el, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus af9fbfd9cb 06/82: Changed name and added header, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 02cec3494d 01/82: Initial commit, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus e691113e4b 03/82: Moved init/termination to separate functions, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 284a1240ce 33/82: Cleaned up doc in `focus-average-colors', ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 58a91b29aa 34/82: Split focus-bounds into two functions, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus ac711fe13a 35/82: Whitespace cleanup, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 35f3cf5d52 20/82: Use things as defined in thingatpt as bounds, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 871f3c60ce 48/82: Fixed matching parenthesis, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus fe94e0de69 43/82: Split activation/deactivation into functions,
ELPA Syncer <=
- [nongnu] elpa/focus 2fbf024c53 79/82: Fix bug introduced in d5631db, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 6add57b887 59/82: Fix indentation, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 563a3bd188 47/82: Updated README, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus d1bd81ee4d 39/82: Added focus-read-only-mode, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 4c8391ea32 29/82: Fixed bug in defgroup, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus b21341bd40 38/82: Added function for briefly showing the cursor, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 246eaeb8d1 72/82: Define faces for the unfocused and focused regions, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus b90cfb3c27 50/82: Fix #4, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus f590761dac 46/82: focus-read-only-mode calls for version bump, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 01a7a95334 27/82: Changed paragraph to section in README, ELPA Syncer, 2022/09/06