Moved init/termination to separate functions

This commit is contained in:
Lars Tveito 2015-05-12 01:12:32 +02:00
parent 6040c744cc
commit e691113e4b

View File

@ -21,13 +21,7 @@
(move-overlay focus-pre-overlay (point-min) pre)
(move-overlay focus-post-overlay post (point-max))))
;;;###autoload
(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))
(defun focus-init ()
(setq focus-pre-overlay (make-overlay (point-min) (point-min))
focus-post-overlay (make-overlay (point-max) (point-max)))
(let ((color (focus-average-colors
@ -35,4 +29,14 @@
(face-attribute 'default :background))))
(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 '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)))