summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2021-04-02 13:29:50 -0500
committerCase Duckworth2021-04-02 13:29:50 -0500
commitaa6002f07fa1ce1382a32499c266347219f71947 (patch)
tree122eaff04f10b60995bb7155a01784f78e0d208c
parentRemove commented code (diff)
downloademacs-aa6002f07fa1ce1382a32499c266347219f71947.tar.gz
emacs-aa6002f07fa1ce1382a32499c266347219f71947.zip
Change hook formatting
I like putting the `defun' form into the hook definition for tighter coupling.
The functions are just for the hooks, after all.

I'm sure this is somehow bad practice, but ... bleh.
-rw-r--r--init.el29
1 files changed, 14 insertions, 15 deletions
diff --git a/init.el b/init.el index 1e5826e..ad6efdc 100644 --- a/init.el +++ b/init.el
@@ -717,15 +717,14 @@ if ripgrep is installed, otherwise `consult-grep'."
717 "G" elpher-go-current) 717 "G" elpher-go-current)
718 (:hook acdw/reading-mode) 718 (:hook acdw/reading-mode)
719 719
720 ;; Make `eww' gemini/gopher aware. 720 ;; Make `eww' gemini/gopher aware. From Emacswiki.
721 ;; From Emacswiki. 721 (advice-add 'eww-browse-url :around
722 (defun elpher:eww-browse-url (original url &optional new-window) 722 (defun elpher:eww-browse-url (original url &optional new-window)
723 "Handle gemini and gopher links." 723 "Handle gemini and gopher links."
724 (cond ((string-match-p "\\`\\(gemini\\|gopher\\)://" url) 724 (cond ((string-match-p "\\`\\(gemini\\|gopher\\)://" url)
725 (require 'elpher) 725 (require 'elpher)
726 (elpher-go url)) 726 (elpher-go url))
727 (t (funcall original url new-window)))) 727 (t (funcall original url new-window))))))
728 (advice-add 'eww-browse-url :around #'elpher:eww-browse-url))
729 728
730(setup (:straight (gemini-mode 729(setup (:straight (gemini-mode
731 :host nil 730 :host nil
@@ -779,12 +778,12 @@ if ripgrep is installed, otherwise `consult-grep'."
779 (apheleia-global-mode +1) 778 (apheleia-global-mode +1)
780 779
781 ;; Use a dumb formatter on modes that `apheleia' doesn't work for. 780 ;; Use a dumb formatter on modes that `apheleia' doesn't work for.
782 (defun dumb-auto-format () 781 (add-hook 'before-save-hook
783 "Run `indent-region' in buffers that don't have an 782 (defun dumb-auto-format ()
784 `apheleia' formatter set." 783 "Run `indent-region' in buffers that don't have an `apheleia'
785 (unless (apheleia--get-formatter-command) 784 formatter set."
786 (indent-region (point-min) (point-max)))) 785 (unless (apheleia--get-formatter-command)
787 (add-hook 'before-save-hook #'dumb-auto-format)) 786 (indent-region (point-min) (point-max))))))
788 787
789;;;;; Eldoc 788;;;;; Eldoc
790(setup eldoc 789(setup eldoc