[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/focus a84ade00a2 61/82: Addresses #13
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/focus a84ade00a2 61/82: Addresses #13 |
Date: |
Tue, 6 Sep 2022 04:58:58 -0400 (EDT) |
branch: elpa/focus
commit a84ade00a2b57e47430d5b2df5246069f197356f
Author: Lars Tveito <larstvei@ifi.uio.no>
Commit: Lars Tveito <larstvei@ifi.uio.no>
Addresses #13
The source of the error was not keeping track of which buffer focus should
operate on.
Also ensured that all hooks are local, which might also effect #13.
---
focus.el | 40 ++++++++++++++++++++++++----------------
1 file changed, 24 insertions(+), 16 deletions(-)
diff --git a/focus.el b/focus.el
index c2bb6d48d1..80cda30f5e 100644
--- a/focus.el
+++ b/focus.el
@@ -76,6 +76,9 @@ Things that are defined include `symbol', `list', `sexp',
(defvar focus-current-thing nil
"Overrides the choice of thing dictated by `focus-mode-to-thing' if set.")
+(defvar focus-buffer nil
+ "Local reference to the buffer focus functions operate on.")
+
(defvar focus-pre-overlay nil
"The overlay that dims the text prior to the current-point.")
@@ -89,6 +92,7 @@ The timer calls `focus-read-only-hide-cursor' after
;; Use make-local-variable for backwards compatibility.
(dolist (var '(focus-current-thing
+ focus-buffer
focus-pre-overlay
focus-post-overlay
focus-read-only-blink-timer))
@@ -138,9 +142,10 @@ argument."
If `focus-mode' is enabled, this command fires after each
command."
- (let* ((bounds (focus-bounds)))
- (when bounds
- (focus-move-overlays (car bounds) (cdr bounds)))))
+ (with-current-buffer focus-buffer
+ (let* ((bounds (focus-bounds)))
+ (when bounds
+ (focus-move-overlays (car bounds) (cdr bounds))))))
(defun focus-move-overlays (low high)
"Move `focus-pre-overlay' and `focus-post-overlay'."
@@ -155,12 +160,13 @@ overlays; these are invisible until `focus-move-focus' is
run. It
adds `focus-move-focus' to `post-command-hook'."
(unless (or focus-pre-overlay focus-post-overlay)
(setq focus-pre-overlay (make-overlay (point-min) (point-min))
- focus-post-overlay (make-overlay (point-max) (point-max)))
+ focus-post-overlay (make-overlay (point-max) (point-max))
+ focus-buffer (current-buffer))
(let ((color (focus-make-dim-color)))
(mapc (lambda (o) (overlay-put o 'face (cons 'foreground-color color)))
(list focus-pre-overlay focus-post-overlay)))
(add-hook 'post-command-hook 'focus-move-focus nil t)
- (add-hook 'change-major-mode-hook 'focus-terminate)))
+ (add-hook 'change-major-mode-hook 'focus-terminate nil t)))
(defun focus-terminate ()
"This function is run when command `focus-mode' is disabled.
@@ -223,11 +229,11 @@ if active."
(interactive "p")
(focus-next-thing (- n)))
-(defun focus-read-only-hide-cursor (&optional buffer)
+(defun focus-read-only-hide-cursor ()
"Hide the cursor.
This function is triggered by the `focus-read-only-blink-timer',
when `focus-read-only-mode' is activated."
- (with-current-buffer (or buffer (current-buffer))
+ (with-current-buffer focus-buffer
(when (and focus-read-only-mode (not (null focus-read-only-blink-timer)))
(setq focus-read-only-blink-timer nil)
(setq cursor-type nil))))
@@ -236,13 +242,14 @@ when `focus-read-only-mode' is activated."
"Make the cursor visible for `focus-read-only-blink-seconds'.
This is added to the `pre-command-hook' when
`focus-read-only-mode' is active."
- (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 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)))))
+ (with-current-buffer focus-buffer
+ (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 focus-cursor-type)
+ (setq focus-read-only-blink-timer
+ (run-at-time focus-read-only-blink-seconds nil
+ 'focus-read-only-hide-cursor)))))
(defun focus-read-only-init ()
"Run when `focus-read-only-mode' is activated.
@@ -250,9 +257,10 @@ 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)
+ (setq cursor-type nil
+ focus-buffer (current-buffer))
(add-hook 'pre-command-hook 'focus-read-only-cursor-blink nil t)
- (add-hook 'kill-buffer-hook 'focus-read-only-terminate t))
+ (add-hook 'kill-buffer-hook 'focus-read-only-terminate nil t))
(defun focus-read-only-terminate ()
"Run when `focus-read-only-mode' is deactivated.
- [nongnu] elpa/focus a723f78dc4 37/82: Added function for hiding the cursor, (continued)
- [nongnu] elpa/focus a723f78dc4 37/82: Added function for hiding the cursor, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus d5631db0b6 73/82: Remove `face`-suffix from faces, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 5bddbbb7d3 22/82: Remove newline, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus cfb1672fca 76/82: Merge pull request #22 from larstvei/focus-face, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus ffd97a5a36 56/82: Fix bug related to `post-command-hook`, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 045ee6175e 63/82: Remove focus-any and simply apply derived-mode-p, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 0f2a9945e9 66/82: Fixed some flycheck warnings., ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 1423efbd25 42/82: Don't assume bounds are found, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 19b3c7b348 70/82: Just use a face for customizing the unfocused region, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus bfb6aaf8ad 57/82: Don't persist focus mode across major mode change, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus a84ade00a2 61/82: Addresses #13,
ELPA Syncer <=
- [nongnu] elpa/focus f193014150 15/82: Did not work, back to static width, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus ef5f7fc892 45/82: Cleaned up `focus-next-thing' and `focus-prev-thing', ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus e9e841aed4 78/82: Remove sentence, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus f058bd163d 64/82: Fixed compile warnings., ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 5f3f20e7f2 80/82: Bump version, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 155da77a32 60/82: Fixes #14, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus cbba87b062 74/82: Trim candidate list of *things*, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 0a6e9624ea 49/82: Allow for changing the current thing interactively, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 90806dc7ea 18/82: Added custom variable for setting dimness, ELPA Syncer, 2022/09/06
- [nongnu] elpa/focus 704db49988 82/82: Merge pull request #24 from phikal/master, ELPA Syncer, 2022/09/06