Use delegate function

As suggested by Henrik I changed it to use a delegate function, which reduces
code duplication and makes things cleaner
This commit is contained in:
Steven vanZyl 2020-10-05 10:08:51 -04:00
parent 67c1e7c3f9
commit 3f28411f64
4 changed files with 15 additions and 15 deletions

View file

@ -266,10 +266,8 @@
;;; <leader> t --- toggle
(:prefix-map ("t" . "toggle")
:desc "Big mode" "b" #'doom-big-font-mode
(:when (and (featurep! :ui fill-column) EMACS27+)
:desc "Fill Column Indicator" "c" #'display-fill-column-indicator-mode)
(:when (and (featurep! :ui fill-column) (not EMACS27+))
:desc "Fill Column Indicator" "c" #'hl-fill-column-mode)
(:when (featurep! :ui fill-column)
:desc "Fill Column Indicator" "c" #'+fill-column-enable-h)
:desc "Flymake" "f" #'flymake-mode
:desc "Frame fullscreen" "F" #'toggle-frame-fullscreen
:desc "Indent style" "I" #'doom/toggle-indent-style

View file

@ -650,10 +650,8 @@
;;; <leader> t --- toggle
(:prefix-map ("t" . "toggle")
:desc "Big mode" "b" #'doom-big-font-mode
(:when (and (featurep! :ui fill-column) EMACS27+)
:desc "Fill Column Indicator" "c" #'display-fill-column-indicator-mode)
(:when (and (featurep! :ui fill-column) (not EMACS27+))
:desc "Fill Column Indicator" "c" #'hl-fill-column-mode)
(:when (featurep! :ui fill-column)
:desc "Fill Column Indicator" "c" #'+fill-column-enable-h)
:desc "Flymake" "f" #'flymake-mode
(:when (featurep! :checkers syntax)
:desc "Flycheck" "f" #'flycheck-mode)

View file

@ -5,8 +5,12 @@
;;;###autoload
;; Emacs 27 introduced `display-fill-column-indicator-mode' which should be
;; used instead of `hl-fill-column-mode'
(if EMACS27+
(add-hook! '(text-mode-hook prog-mode-hook conf-mode-hook)
#'display-fill-column-indicator-mode)
(add-hook! '(text-mode-hook prog-mode-hook conf-mode-hook)
#'hl-fill-column-mode))
(defun +fill-column-enable-h (&optional arg)
(interactive "p")
(if (fboundp 'display-fill-column-indicator-mode)
(display-fill-column-indicator-mode arg)
(hl-fill-column-mode arg)))
;;;###autoload
(add-hook! '(text-mode-hook prog-mode-hook conf-mode-hook)
#'+fill-column-enable-h)

View file

@ -2,5 +2,5 @@
;;; ui/fill-column/packages.el
;; `hl-fill-column' is only used on Emacs versions before 27
(unless EMACS27+
(unless (fboundp 'display-fill-column-indicator-mode)
(package! hl-fill-column :pin "5782a91ba0182c4e562fa0db6379ff9dd472856b"))