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.
This commit is contained in:
Case Duckworth 2021-04-01 16:41:41 -05:00
parent 8bedff5f57
commit 9af70cbf60
3 changed files with 30 additions and 22 deletions

View File

@ -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))

31
init.el
View File

@ -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 "<backspace>" 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))

View File

@ -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)