Skip to content

Commit

Permalink
refactor: simplify use-package's :hook forms
Browse files Browse the repository at this point in the history
  • Loading branch information
abougouffa committed Jun 17, 2023
1 parent f6e6baa commit cd75b1b
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 44 deletions.
70 changes: 39 additions & 31 deletions modules/me-editor.el
Original file line number Diff line number Diff line change
Expand Up @@ -88,49 +88,57 @@
(push unicode-font-family (cadr unicode-block))))
(unicode-fonts-setup))))))

(when (and (>= emacs-major-version 28) (+emacs-features-p 'harfbuzz 'cairo))
(use-package ligature
:straight t
:after minemacs-loaded
:hook (prog-mode . ligature-mode)
:config
;; Enable the "www" ligature in every possible major mode
(ligature-set-ligatures 't '("www"))
;; Enable traditional ligature support in eww-mode, if the
;; `variable-pitch' face supports it
(ligature-set-ligatures 'eww-mode '("ff" "fi" "ffi"))
;; Enable all "Cascadia Code" ligatures in programming modes
(ligature-set-ligatures
'prog-mode
'("|||>" "<|||" "<==>" "<!--" "####" "~~>" "***" "||=" "||>"
":::" "::=" "=:=" "===" "==>" "=!=" "=>>" "=<<" "=/=" "!=="
"!!." ">=>" ">>=" ">>>" ">>-" ">->" "->>" "-->" "---" "-<<"
"<~~" "<~>" "<*>" "<||" "<|>" "<$>" "<==" "<=>" "<=<" "<->"
"<--" "<-<" "<<=" "<<-" "<<<" "<+>" "</>" "###" "#_(" "..<"
"..." "+++" "/==" "///" "_|_" "www" "&&" "^=" "~~" "~@" "~="
"~>" "~-" "**" "*>" "*/" "||" "|}" "|]" "|=" "|>" "|-" "{|"
"[|" "]#" "::" ":=" ":>" ":<" "$>" "==" "=>" "!=" "!!" ">:"
">=" ">>" ">-" "-~" "-|" "->" "--" "-<" "<~" "<*" "<|" "<:"
"<$" "<=" "<>" "<-" "<<" "<+" "</" "#{" "#[" "#:" "#=" "#!"
"##" "#(" "#?" "#_" "%%" ".=" ".-" ".." ".?" "+>" "++" "?:"
"?=" "?." "??" ";;" "/*" "/=" "/>" "//" "__" "~~" "(*" "*)"
"\\\\" "://"))))
(unless (and (>= emacs-major-version 28) (+emacs-features-p 'harfbuzz 'cairo))
(push 'ligature minemacs-disabled-packages))

(use-package ligature
:straight t
:after minemacs-loaded
:hook prog-mode
:config
;; Enable the "www" ligature in every possible major mode
(ligature-set-ligatures 't '("www"))
;; Enable traditional ligature support in eww-mode, if the
;; `variable-pitch' face supports it
(ligature-set-ligatures 'eww-mode '("ff" "fi" "ffi"))
;; Enable all "Cascadia Code" ligatures in programming modes
(ligature-set-ligatures
'prog-mode
'("|||>" "<|||" "<==>" "<!--" "####" "~~>" "***" "||=" "||>"
":::" "::=" "=:=" "===" "==>" "=!=" "=>>" "=<<" "=/=" "!=="
"!!." ">=>" ">>=" ">>>" ">>-" ">->" "->>" "-->" "---" "-<<"
"<~~" "<~>" "<*>" "<||" "<|>" "<$>" "<==" "<=>" "<=<" "<->"
"<--" "<-<" "<<=" "<<-" "<<<" "<+>" "</>" "###" "#_(" "..<"
"..." "+++" "/==" "///" "_|_" "www" "&&" "^=" "~~" "~@" "~="
"~>" "~-" "**" "*>" "*/" "||" "|}" "|]" "|=" "|>" "|-" "{|"
"[|" "]#" "::" ":=" ":>" ":<" "$>" "==" "=>" "!=" "!!" ">:"
">=" ">>" ">-" "-~" "-|" "->" "--" "-<" "<~" "<*" "<|" "<:"
"<$" "<=" "<>" "<-" "<<" "<+" "</" "#{" "#[" "#:" "#=" "#!"
"##" "#(" "#?" "#_" "%%" ".=" ".-" ".." ".?" "+>" "++" "?:"
"?=" "?." "??" ";;" "/*" "/=" "/>" "//" "__" "~~" "(*" "*)"
"\\\\" "://")))

(use-package rainbow-delimiters
:straight t
:hook (prog-mode . rainbow-delimiters-mode))
:hook prog-mode)

(use-package highlight-numbers
:straight t
:hook ((prog-mode conf-mode) . highlight-numbers-mode)
:hook prog-mode conf-mode
:config
;; Original "\\_<[[:digit:]].*?\\_>"
(setq highlight-numbers-generic-regexp "\\_<[[:digit:]]+\\(?:\\.[0-9]*\\)?\\_>"))

(use-package smartparens
:straight t
:hook (prog-mode . smartparens-mode)
:hook prog-mode
:hook (smartparens-mode . +smartparens--disable-navigate-skip-match-h)
:config
(defun +smartparens--disable-navigate-skip-match-h ()
;; From Doom Emacs, disable expensive navigation features.
(setq sp-navigate-skip-match nil
sp-navigate-consider-sgml-tags nil))

(with-eval-after-load 'evil-mc
;; Make evil-mc cooperate with smartparens better
(let ((vars (cdr (assq :default evil-mc-cursor-variables))))
Expand All @@ -151,7 +159,7 @@

(use-package goggles
:straight t
:hook ((prog-mode text-mode) . goggles-mode)
:hook prog-mode text-mode
:config
;; Pulse for evil commands
(goggles-define undo primitive-undo evil-undo)
Expand Down
2 changes: 1 addition & 1 deletion modules/me-extra.el
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

(use-package better-jumper
:straight t
:hook (minemacs-after-startup . better-jumper-mode)
:hook minemacs-after-startup
:config
;; Map extra mouse buttons to jump forward/backward
(keymap-global-set "<mouse-8>" 'better-jumper-jump-backward)
Expand Down
2 changes: 1 addition & 1 deletion modules/me-lisp.el
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
:custom
(parinfer-rust-library-directory (concat minemacs-local-dir "parinfer-rust/"))
(parinfer-rust-auto-download (eq sys/arch 'x86_64))
:hook (emacs-lisp-mode clojure-mode scheme-mode lisp-mode racket-mode hy-mode)
:hook emacs-lisp-mode clojure-mode scheme-mode lisp-mode racket-mode hy-mode
:config
(defvar-local +parinter-rust--was-enabled-p nil)

Expand Down
2 changes: 1 addition & 1 deletion modules/me-natural-langs.el
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
:preface
(defconst +aspell-available-p (executable-find "aspell"))
:when +aspell-available-p
:hook (text-mode . spell-fu-mode)
:hook text-mode
:hook (spell-fu-mode . +spell-fu--init-excluded-faces-h)
:custom
(spell-fu-directory (+directory-ensure minemacs-local-dir "spell-fu/"))
Expand Down
8 changes: 4 additions & 4 deletions modules/me-org.el
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@
;; Other Org features
(use-package org-appear
:straight t
:hook (org-mode . org-appear-mode)
:hook org-mode
:custom
(org-appear-inside-latex t)
(org-appear-autokeywords t)
Expand All @@ -247,7 +247,7 @@

(use-package org-modern
:straight t
:hook (org-mode . org-modern-mode)
:hook org-mode
:hook (org-agenda-finalize . org-modern-agenda)
:custom-face
;; Force monospaced font for tags
Expand Down Expand Up @@ -293,7 +293,7 @@
;; For latex fragments
(use-package org-fragtog
:straight t
:hook (org-mode . org-fragtog-mode)
:hook org-mode
:custom
(org-fragtog-preview-delay 0.2))

Expand Down Expand Up @@ -351,7 +351,7 @@

(use-package evil-org
:straight t
:hook (org-mode . evil-org-mode))
:hook org-mode)

(use-package evil-org-agenda
:after evil-org
Expand Down
6 changes: 3 additions & 3 deletions modules/me-prog.el
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

(use-package combobulate
:straight t
:hook (python-ts-mode js-ts-mode css-ts-mode yaml-ts-mode typescript-ts-mode tsx-ts-mode)
:hook python-ts-mode js-ts-mode css-ts-mode yaml-ts-mode typescript-ts-mode tsx-ts-mode
:custom
(combobulate-key-prefix "C-c o")))

Expand Down Expand Up @@ -271,7 +271,7 @@ the children of class at point."

(use-package editorconfig
:straight t
:hook (prog-mode . editorconfig-mode)
:hook prog-mode
:init
(+map!
"fc" '(editorconfig-find-current-editorconfig :wk "Find current EditorConfig")
Expand Down Expand Up @@ -361,7 +361,7 @@ the children of class at point."

(use-package hl-todo
:straight (:host github :repo "tarsius/hl-todo")
:hook (prog-mode . hl-todo-mode)
:hook prog-mode
:config
(setq hl-todo-keyword-faces
(append
Expand Down
4 changes: 2 additions & 2 deletions modules/me-ui.el
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@

(use-package page-break-lines
:straight t
:hook ((prog-mode text-mode special-mode) . page-break-lines-mode))
:hook prog-mode text-mode special-mode)

(use-package focus
:straight t
Expand All @@ -78,7 +78,7 @@

(use-package nerd-icons-ibuffer
:straight t
:hook (ibuffer-mode . nerd-icons-ibuffer-mode))
:hook ibuffer-mode)


(provide 'me-ui)
Expand Down
2 changes: 1 addition & 1 deletion modules/me-workspaces.el
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@

(use-package tab-bar
:straight (:type built-in)
:hook (minemacs-after-startup . tab-bar-mode)
:hook minemacs-after-startup
:custom
(tab-bar-format '(tab-bar-format-history
tab-bar-format-tabs
Expand Down

0 comments on commit cd75b1b

Please sign in to comment.