ui/fci: conform to conventions; minor refactor

This commit is contained in:
Henrik Lissner 2018-10-31 16:07:22 -04:00 committed by GitHub
parent 1c5080315a
commit 0af32e0c52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -22,9 +22,9 @@ Changes to this variable do not take effect until `fci-mode' is restarted.")
(add-hook 'org-mode-hook #'turn-off-fci-mode) (add-hook 'org-mode-hook #'turn-off-fci-mode)
;; turn off fci if the window is narrow than fill column ;; turn off fci if the window is narrow than fill column
(defun fci-conditional (window) (defun +fci-toggle-maybe (window)
(let ((fci-enabled (symbol-value 'fci-mode)) (let ((fci-enabled (symbol-value 'fci-mode))
(fci-column (if fci-rule-column fci-rule-column fill-column))) (fci-column (or fci-rule-column fill-column)))
(with-selected-window window (with-selected-window window
(if (and (eq fci-enabled nil) (if (and (eq fci-enabled nil)
(< fci-column (< fci-column
@ -32,11 +32,11 @@ Changes to this variable do not take effect until `fci-mode' is restarted.")
(turn-on-fci-mode) (turn-on-fci-mode)
(turn-off-fci-mode))))) (turn-off-fci-mode)))))
(defun fci-width-workaround (&rest _) (defun +fci|width-workaround (&rest _)
(walk-windows #'fci-conditional 'no-minibuf)) (walk-windows #'+fci-toggle-maybe 'no-minibuf))
(add-hook 'window-size-change-functions 'fci-width-workaround) (add-hook 'window-size-change-functions #'+fci|width-workaround)
(add-hook 'window-configuration-change-hook 'fci-width-workaround) (add-hook 'window-configuration-change-hook #'+fci|width-workaround)
(defun +fci|set-color () (defun +fci|set-color ()
"Automatically change `fci-rule-color' based on `+fci-rule-color-function's "Automatically change `fci-rule-color' based on `+fci-rule-color-function's