From 0165cc6bfc9905b5806ba879e7a7cdf0233d4351 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 29 Sep 2021 17:21:50 -0500 Subject: [PATCH] Change apheleia stupid indenting --- init.el | 26 +++++++++++--------------- lisp/acdw-apheleia.el | 25 +++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 15 deletions(-) create mode 100644 lisp/acdw-apheleia.el diff --git a/init.el b/init.el index c3cbb68..e294a95 100644 --- a/init.el +++ b/init.el @@ -964,30 +964,26 @@ specific to most general, they are these: (setup (:straight (apheleia :host github :repo "raxod502/apheleia")) - - (apheleia-global-mode +1) - ;; Use a dumb formatter on modes that `apheleia' doesn't work for. - (add-hook 'before-save-hook - (defun before-save@dumb-auto-format () - (setq stupid-modes '(makefile-mode - org-mode)) - ;; If there's no apheleia formatter for the mode, just indent the - ;; buffer. - (unless (or (apply #'derived-mode-p stupid-modes) - (and (fboundp 'apheleia--get-formatter-command) - (apheleia--get-formatter-command))) - (indent-region (point-min) (point-max)))))) + (:also-load acdw-apheleia) + (add-hook 'before-save-hook #'apheleia-dumb-auto-format) + + ;; Aphelia can't find prettier on Windows (though I + ;; installed it, I think), and it keeps trying to start + ;; new processes until Emacs runs out of subprocess space. + ;; So I just enable it at home. + (unless (acdw/system :work) + (apheleia-global-mode +1))) (setup (:straight async) (dired-async-mode +1)) (setup (:straight avy) - (:global "C-'" #'avy-goto-char-timer + (:global "M-j" #'avy-goto-char-timer "C-c C-j" #'avy-resume) (:with-feature isearch - (:bind "C-'" #'avy-isearch))) + (:bind "M-j" #'avy-isearch))) (setup (:straight circe) (require 'circe) diff --git a/lisp/acdw-apheleia.el b/lisp/acdw-apheleia.el new file mode 100644 index 0000000..1b646ef --- /dev/null +++ b/lisp/acdw-apheleia.el @@ -0,0 +1,25 @@ +;;; acdw-apheleia.el --- bespoke apheleia junk -*- lexical-binding: t -*- + +;;; Commentary: + +;;; Code: + +(require 'apheleia) + +(defcustom apheleia-stupid-modes '(makefile-mode + org-mode) + "List of stupid modes to not use `apheleia-global-mode' on." + :type '(repeat function) + :group 'apheleia) + +(defun apheleia-dumb-auto-format () + "Format a buffer dumbly." + ;; If there's no apheleia formatter for the mode, just indent the + ;; buffer. + (unless (or (apply #'derived-mode-p apheleia-stupid-modes) + (and (fboundp 'apheleia--get-formatter-command) + (apheleia--get-formatter-command))) + (indent-region (point-min) (point-max)))) + +(provide 'acdw-apheleia) +;;; acdw-apheleia ends here