mirror of
https://github.com/larstvei/Focus.git
synced 2024-11-26 03:28:32 +00:00
Don't persist focus mode across major mode change
Addresses #11. Focus mode will no longer make any variables `permanent-local'. On major mode change `focus-terminate' is run so that the overlays are removed.
This commit is contained in:
parent
ffd97a5a36
commit
bfb6aaf8ad
16
focus.el
16
focus.el
@ -91,19 +91,6 @@ The timer calls `focus-read-only-hide-cursor' after
|
|||||||
focus-read-only-blink-timer))
|
focus-read-only-blink-timer))
|
||||||
(make-local-variable var))
|
(make-local-variable var))
|
||||||
|
|
||||||
;; Changing major-mode should not affect Focus mode.
|
|
||||||
(dolist (var '(focus-current-thing
|
|
||||||
focus-pre-overlay
|
|
||||||
focus-post-overlay
|
|
||||||
focus-mode
|
|
||||||
focus-read-only-mode))
|
|
||||||
(put var 'permanent-local t))
|
|
||||||
|
|
||||||
(dolist (var '(focus-read-only-cursor-blink
|
|
||||||
focus-read-only-terminate
|
|
||||||
focus-move-focus))
|
|
||||||
(put var 'permanent-local-hook t))
|
|
||||||
|
|
||||||
(defun focus-any (f lst)
|
(defun focus-any (f lst)
|
||||||
"Apply F to each element of LST and return first NON-NIL."
|
"Apply F to each element of LST and return first NON-NIL."
|
||||||
(when lst
|
(when lst
|
||||||
@ -169,7 +156,8 @@ adds `focus-move-focus' to `post-command-hook'."
|
|||||||
(let ((color (focus-make-dim-color)))
|
(let ((color (focus-make-dim-color)))
|
||||||
(mapc (lambda (o) (overlay-put o 'face (cons 'foreground-color color)))
|
(mapc (lambda (o) (overlay-put o 'face (cons 'foreground-color color)))
|
||||||
(list focus-pre-overlay focus-post-overlay)))
|
(list focus-pre-overlay focus-post-overlay)))
|
||||||
(add-hook 'post-command-hook 'focus-move-focus nil t)))
|
(add-hook 'post-command-hook 'focus-move-focus nil t)
|
||||||
|
(add-hook 'change-major-mode-hook 'focus-terminate)))
|
||||||
|
|
||||||
(defun focus-terminate ()
|
(defun focus-terminate ()
|
||||||
"This function is run when command `focus-mode' is disabled.
|
"This function is run when command `focus-mode' is disabled.
|
||||||
|
Loading…
Reference in New Issue
Block a user