diff options
author | Case Duckworth | 2021-04-01 16:53:49 -0500 |
---|---|---|
committer | Case Duckworth | 2021-04-01 16:55:40 -0500 |
commit | e535ec0a4b55bebe5bc364c3379b964d5021bfd1 (patch) | |
tree | 5ace43755f9b36c15d73595b7adc91410da81c00 | |
parent | Break "Programming languages" out into its own section (diff) | |
download | emacs-e535ec0a4b55bebe5bc364c3379b964d5021bfd1.tar.gz emacs-e535ec0a4b55bebe5bc364c3379b964d5021bfd1.zip |
Add function `dumb-auto-format' that checks with apheleia first
In adding `dumb-auto-format', I've removed `acdw/reformat-buffer' because it's not complex enough or stand-alone enough to keep as its own function. 21 guns.
-rw-r--r-- | init.el | 13 | ||||
-rw-r--r-- | lisp/acdw.el | 7 |
2 files changed, 10 insertions, 10 deletions
diff --git a/init.el b/init.el index 0f235b3..023faa3 100644 --- a/init.el +++ b/init.el | |||
@@ -729,14 +729,21 @@ if ripgrep is installed, otherwise `consult-grep'." | |||
729 | ;;;;; Formatting | 729 | ;;;;; Formatting |
730 | (setup (:straight (apheleia :host github | 730 | (setup (:straight (apheleia :host github |
731 | :repo "raxod502/apheleia")) | 731 | :repo "raxod502/apheleia")) |
732 | (apheleia-global-mode +1)) | 732 | (apheleia-global-mode +1) |
733 | |||
734 | ;; Use a dumb formatter on modes that `apheleia' doesn't work for. | ||
735 | (defun dumb-auto-format () | ||
736 | "Run `indent-region' in buffers that don't have an | ||
737 | `apheleia' formatter set." | ||
738 | (unless (apheleia--get-formatter-command) | ||
739 | (indent-region (point-min) (point-max)))) | ||
740 | (add-hook 'before-save-hook #'dumb-auto-format)) | ||
733 | 741 | ||
734 | ;;;;; Emacs lisp | 742 | ;;;;; Emacs lisp |
735 | (setup emacs-lisp-mode | 743 | (setup emacs-lisp-mode |
736 | (:option eval-expression-print-length nil | 744 | (:option eval-expression-print-length nil |
737 | eval-expression-print-level nil | 745 | eval-expression-print-level nil |
738 | lisp-indent-function #'lisp-indent-function) | 746 | lisp-indent-function #'lisp-indent-function)) |
739 | (:local-hook before-save-hook acdw/reindent-buffer)) | ||
740 | 747 | ||
741 | (setup (:straight macrostep) | 748 | (setup (:straight macrostep) |
742 | (define-key emacs-lisp-mode-map (kbd "C-c e") #'macrostep-expand)) | 749 | (define-key emacs-lisp-mode-map (kbd "C-c e") #'macrostep-expand)) |
diff --git a/lisp/acdw.el b/lisp/acdw.el index 8096a70..0203f3b 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el | |||
@@ -58,13 +58,6 @@ Ready for use with `after-focus-change-function'." | |||
58 | (run-at-time sunset-time (* 60 60 24) sunset-command) | 58 | (run-at-time sunset-time (* 60 60 24) sunset-command) |
59 | (run-at-time "12:00am" (* 60 60 24) sunset-command))) | 59 | (run-at-time "12:00am" (* 60 60 24) sunset-command))) |
60 | 60 | ||
61 | ;;;; Re-indent a buffer | ||
62 | (defun acdw/reindent-buffer () | ||
63 | "Call `indent-region' on the whole buffer." | ||
64 | (interactive) | ||
65 | (save-excursion | ||
66 | (indent-region (point-min) (point-max)))) | ||
67 | |||
68 | ;;; Garbage collection hacks | 61 | ;;; Garbage collection hacks |
69 | 62 | ||
70 | (defconst acdw/gc-cons-threshold-basis (* 800 1024) | 63 | (defconst acdw/gc-cons-threshold-basis (* 800 1024) |