about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2022-01-06 15:47:42 -0600
committerCase Duckworth2022-01-06 15:48:00 -0600
commit4dee486f1f1d39ebc523e03f61705656d8e9c326 (patch)
treeaa4b8bdcceb638d63d4ca06f5566c4385b5502bd
parentAdd user-save-mode (diff)
downloademacs-4dee486f1f1d39ebc523e03f61705656d8e9c326.tar.gz
emacs-4dee486f1f1d39ebc523e03f61705656d8e9c326.zip
Add +kill-word-backward-or-region
-rw-r--r--init.el11
-rw-r--r--lisp/+emacs.el9
2 files changed, 18 insertions, 2 deletions
diff --git a/init.el b/init.el index 5bf4dee..a822cb8 100644 --- a/init.el +++ b/init.el
@@ -34,10 +34,15 @@
34 "C-x 4 n" #'clone-buffer 34 "C-x 4 n" #'clone-buffer
35 "C-c v" #'visible-mode 35 "C-c v" #'visible-mode
36 "C-M-;" #'+lisp-comment-or-uncomment-sexp 36 "C-M-;" #'+lisp-comment-or-uncomment-sexp
37 "M-j" nil) 37 "M-j" nil
38 "C-x o" (lambda () (interactive) (switch-to-buffer nil))
39 "C-x C-o" #'+open-paragraph
40 "C-w" #'+kill-word-backward-or-region)
38 ;; C-h deletes backward - see https://idiomdrottning.org/bad-emacs-defaults 41 ;; C-h deletes backward - see https://idiomdrottning.org/bad-emacs-defaults
39 (global-set-key (kbd "C-h") 'delete-backward-char) 42 (global-set-key (kbd "C-h") 'delete-backward-char)
40 (keyboard-translate ?\C-h ?\C-?) 43 (keyboard-translate ?\C-h ?\C-?)
44 ;; Hooks
45 ;; Advice
41 ;; https://old.reddit.com/r/emacs/comments/rlli0u/whats_your_favorite_defadvice/hph14un/ 46 ;; https://old.reddit.com/r/emacs/comments/rlli0u/whats_your_favorite_defadvice/hph14un/
42 (define-advice keyboard-escape-quit (:around (fn &rest r)) 47 (define-advice keyboard-escape-quit (:around (fn &rest r))
43 "Don't close splits on `keyboard-escape-quit'." 48 "Don't close splits on `keyboard-escape-quit'."
@@ -1141,7 +1146,9 @@ See also `crux-reopen-as-root-mode'."
1141 1146
1142(setup (:straight paredit) 1147(setup (:straight paredit)
1143 (:bind "DEL" #'paredit-backward-delete 1148 (:bind "DEL" #'paredit-backward-delete
1144 "C-<backspace>" #'paredit-backward-kill-word) 1149 "C-<backspace>" #'paredit-backward-kill-word
1150 "C-w" (lambda (r) (interactive "P")
1151 (+kill-word-backward-or-region r #'paredit-backward-kill-word)))
1145 (dolist (hook '(emacs-lisp-mode-hook 1152 (dolist (hook '(emacs-lisp-mode-hook
1146 eval-expression-minibuffer-setup-hook 1153 eval-expression-minibuffer-setup-hook
1147 ielm-mode-hook 1154 ielm-mode-hook
diff --git a/lisp/+emacs.el b/lisp/+emacs.el index 7453913..ecdfeaa 100644 --- a/lisp/+emacs.el +++ b/lisp/+emacs.el
@@ -220,6 +220,15 @@ kill without asking."
220 (save-buffers-kill-emacs)) 220 (save-buffers-kill-emacs))
221 (delete-frame nil :force))) 221 (delete-frame nil :force)))
222 222
223(defun +kill-word-backward-or-region (&optional arg backward-kill-word-fn)
224 "Kill active region or ARG words backward.
225BACKWARD-KILL-WORD-FN is the function to call to kill a word
226backward. It defaults to `backward-kill-word'."
227 (interactive "P")
228 (call-interactively (if (region-active-p)
229 #'kill-region
230 (or backward-kill-word-fn #'backward-kill-word))))
231
223;; ... and advice 232;; ... and advice
224 233
225;; Indent the region after a yank. 234;; Indent the region after a yank.