diff options
-rw-r--r-- | init.el | 7 | ||||
-rw-r--r-- | lisp/+emacs.el | 11 |
2 files changed, 12 insertions, 6 deletions
diff --git a/init.el b/init.el index 6cfc405..6e45383 100644 --- a/init.el +++ b/init.el | |||
@@ -47,14 +47,11 @@ | |||
47 | ;; C-h deletes backward - see https://idiomdrottning.org/bad-emacs-defaults | 47 | ;; C-h deletes backward - see https://idiomdrottning.org/bad-emacs-defaults |
48 | (global-set-key (kbd "C-h") 'delete-backward-char) | 48 | (global-set-key (kbd "C-h") 'delete-backward-char) |
49 | (keyboard-translate ?\C-h ?\C-?) | 49 | (keyboard-translate ?\C-h ?\C-?) |
50 | ;; https://old.reddit.com/r/emacs/comments/rlli0u/whats_your_favorite_defadvice/hph14un/ | ||
50 | (define-advice keyboard-escape-quit (:around (fn &rest r)) | 51 | (define-advice keyboard-escape-quit (:around (fn &rest r)) |
51 | "Don't close splits on `keyboard-escape-quit'." | 52 | "Don't close splits on `keyboard-escape-quit'." |
52 | (let ((buffer-quit-function #'ignore)) | 53 | (let ((buffer-quit-function #'ignore)) |
53 | (apply fn r))) | 54 | (apply fn r)))) |
54 | (defun +yank@indent (&rest _) | ||
55 | (indent-region (min (point) (mark)) (max (point) (mark)))) | ||
56 | (advice-add 'yank :after '+yank@indent) | ||
57 | (advice-add 'yank-pop :after '+yank@indent)) | ||
58 | 55 | ||
59 | (setup (:require +init) | 56 | (setup (:require +init) |
60 | (:bind "C-c s" #'+init-sort-then-save) | 57 | (:bind "C-c s" #'+init-sort-then-save) |
diff --git a/lisp/+emacs.el b/lisp/+emacs.el index 2d63e82..39b064c 100644 --- a/lisp/+emacs.el +++ b/lisp/+emacs.el | |||
@@ -188,7 +188,7 @@ Do this only if the buffer is not visiting a file." | |||
188 | (add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p) | 188 | (add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p) |
189 | (add-hook 'minibuffer-setup-hook 'cursor-intangible-mode) | 189 | (add-hook 'minibuffer-setup-hook 'cursor-intangible-mode) |
190 | 190 | ||
191 | ;;; Better-default functions | 191 | ;;; Better-default functions ... |
192 | 192 | ||
193 | (defun +cycle-spacing (&optional n preserve-nl-back mode) | 193 | (defun +cycle-spacing (&optional n preserve-nl-back mode) |
194 | "Negate N argument on `cycle-spacing'. | 194 | "Negate N argument on `cycle-spacing'. |
@@ -214,6 +214,15 @@ kill without asking." | |||
214 | (save-buffers-kill-emacs)) | 214 | (save-buffers-kill-emacs)) |
215 | (server-save-buffers-kill-terminal nil))) | 215 | (server-save-buffers-kill-terminal nil))) |
216 | 216 | ||
217 | ;; ... and advice | ||
218 | |||
219 | ;; Indent the region after a yank. | ||
220 | (defun +yank@indent (&rest _) | ||
221 | "Indent the current region." | ||
222 | (indent-region (min (point) (mark)) (max (point) (mark)))) | ||
223 | (advice-add #'yank :after #'+yank@indent) | ||
224 | (advice-add #'yank-pop :after #'+yank@indent) | ||
225 | |||
217 | ;;; Bindings | 226 | ;;; Bindings |
218 | 227 | ||
219 | ;; I need to place these bindings under `+key-mode-map' so that they aren't | 228 | ;; I need to place these bindings under `+key-mode-map' so that they aren't |