mirror of
				https://github.com/larstvei/Focus.git
				synced 2025-11-04 02:00:11 +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-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)))
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user