mirror of
https://github.com/larstvei/Focus.git
synced 2024-11-26 11:38:32 +00:00
Moved init/termination to separate functions
This commit is contained in:
parent
6040c744cc
commit
e691113e4b
@ -21,13 +21,7 @@
|
|||||||
(move-overlay focus-pre-overlay (point-min) pre)
|
(move-overlay focus-pre-overlay (point-min) pre)
|
||||||
(move-overlay focus-post-overlay post (point-max))))
|
(move-overlay focus-post-overlay post (point-max))))
|
||||||
|
|
||||||
;;;###autoload
|
(defun focus-init ()
|
||||||
(define-minor-mode focus-mode
|
|
||||||
"Dim the font color text in surrounding paragraphs."
|
|
||||||
:init-value nil
|
|
||||||
(if (not focus-mode)
|
|
||||||
(progn (mapc 'delete-overlay (list focus-pre-overlay focus-post-overlay))
|
|
||||||
(remove-hook 'post-command-hook 'focus-move-focus t))
|
|
||||||
(setq focus-pre-overlay (make-overlay (point-min) (point-min))
|
(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)))
|
||||||
(let ((color (focus-average-colors
|
(let ((color (focus-average-colors
|
||||||
@ -35,4 +29,14 @@
|
|||||||
(face-attribute 'default :background))))
|
(face-attribute 'default :background))))
|
||||||
(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))
|
||||||
|
|
||||||
|
(defun focus-terminate ()
|
||||||
|
(progn (mapc 'delete-overlay (list focus-pre-overlay focus-post-overlay))
|
||||||
|
(remove-hook 'post-command-hook 'focus-move-focus t)))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(define-minor-mode focus-mode
|
||||||
|
"Dim the font color text in surrounding paragraphs."
|
||||||
|
:init-value nil
|
||||||
|
(if focus-mode (focus-init) (focus-terminate)))
|
||||||
|
Loading…
Reference in New Issue
Block a user