From 9af70cbf60e78309a3902315a7d444877677fdfe Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Thu, 1 Apr 2021 16:41:41 -0500 Subject: Define `acdw/reindent-buffer' and hook into elisp Hopefully this will put a halt to all of my whitespace commits. Of course, this commit also includes whitespace-only diffs. --- early-init.el | 10 +++++----- init.el | 31 ++++++++++++++++--------------- lisp/acdw.el | 11 +++++++++-- 3 files changed, 30 insertions(+), 22 deletions(-) diff --git a/early-init.el b/early-init.el index 60889f8..f993d03 100644 --- a/early-init.el +++ b/early-init.el @@ -76,11 +76,11 @@ (defun hook--disable-ui-modes () "Disable frame UI using modes, for toggling later." (dolist (mode ;; each mode is of the form (MODE . FRAME-ALIST-VAR) - '((tool-bar-mode . tool-bar-lines) - (menu-bar-mode . menu-bar-lines) - (scroll-bar-mode . vertical-scroll-bars) - (horizontal-scroll-bar-mode . horizontal-scroll-bars) - )) + '((tool-bar-mode . tool-bar-lines) + (menu-bar-mode . menu-bar-lines) + (scroll-bar-mode . vertical-scroll-bars) + (horizontal-scroll-bar-mode . horizontal-scroll-bars) + )) (let ((setting (alist-get (cdr mode) default-frame-alist))) (when (or (not setting) (= 0 setting)) diff --git a/init.el b/init.el index 5d0bc1b..12f25a6 100644 --- a/init.el +++ b/init.el @@ -391,7 +391,7 @@ ;;;;; MWIM (setup (:straight mwim) (:global "C-a" mwim-beginning - "C-e" mwim-end)) + "C-e" mwim-end)) ;;;;; Expand-region (setup (:straight expand-region) @@ -400,20 +400,20 @@ ;;;;; CRUX (setup (:straight crux) (:global "M-o" crux-other-window-or-switch-buffer - "C-k" crux-kill-and-join-forward - "C-o" crux-smart-open-line-above - "C-S-o" crux-smart-open-line - "C-M-\\" crux-cleanup-buffer-or-region - "C-c i" crux-find-user-init-file) + "C-k" crux-kill-and-join-forward + "C-o" crux-smart-open-line-above + "C-S-o" crux-smart-open-line + "C-M-\\" crux-cleanup-buffer-or-region + "C-c i" crux-find-user-init-file) (crux-reopen-as-root-mode +1)) ;;;;; AVY ... & friends (setup (:straight avy) (:global "C-:" avy-goto-char - "C-'" avy-goto-char-timer - "M-g f" avy-goto-line - "M-g w" avy-goto-word-1 - "C-c C-j" avy-resume) + "C-'" avy-goto-char-timer + "M-g f" avy-goto-line + "M-g w" avy-goto-word-1 + "C-c C-j" avy-resume) (eval-after-load "isearch" '(define-key isearch-mode-map (kbd "C-'") #'avy-isearch))) @@ -435,7 +435,7 @@ call `zzz-to-char'." (add-to-list 'mode-line-misc-info '(:eval (anzu--update-mode-line))) (:global [remap query-replace] anzu-query-replace - [remap query-replace-regexp] anzu-query-replace-regexp) + [remap query-replace-regexp] anzu-query-replace-regexp) (:with-map isearch-mode-map (:bind [remap isearch-query-replace] anzu-isearch-query-replace [remap isearch-query-replace-regexp] @@ -446,7 +446,7 @@ call `zzz-to-char'." ;;;;; smart hungry delete (setup (:straight smart-hungry-delete) (:global "" smart-hungry-delete-backward-char - "C-d" smart-hungry-delete-forward-char) + "C-d" smart-hungry-delete-forward-char) (smart-hungry-delete-add-default-hooks)) ;;;; Functionality @@ -458,8 +458,8 @@ call `zzz-to-char'." ;;;;; Undo-fu (setup (:straight undo-fu) - (:global "C-/" undo-fu-only-undo - "C-?" undo-fu-only-redo)) + (:global "C-/" undo-fu-only-undo + "C-?" undo-fu-only-redo)) (setup (:straight undo-fu-session) (:option undo-fu-session-incompatible-files '("/COMMIT_EDITMSG\\'" @@ -733,7 +733,8 @@ if ripgrep is installed, otherwise `consult-grep'." (setup emacs-lisp-mode (:option eval-expression-print-length nil eval-expression-print-level nil - lisp-indent-function #'lisp-indent-function)) + lisp-indent-function #'lisp-indent-function) + (:local-hook before-save-hook acdw/reindent-buffer)) (setup (:straight macrostep) (define-key emacs-lisp-mode-map (kbd "C-c e") #'macrostep-expand)) diff --git a/lisp/acdw.el b/lisp/acdw.el index 6409f89..8096a70 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el @@ -58,6 +58,13 @@ Ready for use with `after-focus-change-function'." (run-at-time sunset-time (* 60 60 24) sunset-command) (run-at-time "12:00am" (* 60 60 24) sunset-command))) +;;;; Re-indent a buffer +(defun acdw/reindent-buffer () + "Call `indent-region' on the whole buffer." + (interactive) + (save-excursion + (indent-region (point-min) (point-max)))) + ;;; Garbage collection hacks (defconst acdw/gc-cons-threshold-basis (* 800 1024) @@ -97,7 +104,7 @@ directory." ;;; Reading mode (define-minor-mode acdw/reading-mode - "A mode for reading." + "A mode for reading." :init-value t :lighter " Read" (if acdw/reading-mode @@ -144,7 +151,7 @@ directory." "A keymap for my custom bindings.") (define-minor-mode acdw/mode - "A mode for `acdw/map'." + "A mode for `acdw/map'." :init-value t :lighter " acdw" :keymap acdw/map) -- cgit 1.4.1-21-gabe81