From 9e0e42554e0c2619fcb4ce8a8b48da4288c44298 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Tue, 4 May 2021 17:27:36 -0500 Subject: Remap C-w to backward-kill-word if the region isn't active --- lisp/acdw.el | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lisp/acdw.el') diff --git a/lisp/acdw.el b/lisp/acdw.el index f297691..a798069 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el @@ -29,6 +29,8 @@ ;;; Utility functions +;; I don't prefix these because ... reasons. Honestly I probably should prefix +;; them. (defun dos2unix (buffer) "Replace \r\n with \n in BUFFER." @@ -58,6 +60,13 @@ each hook in HOOKS." ,@(dolist (hook hook-list hook-defun-add-hook-list) (push `(add-hook ',hook #',func-name) hook-defun-add-hook-list))))) +(defun kill-region-or-backward-word (arg) + "Kill region if active, or backward word if not." + (interactive "p") + (if (region-active-p) + (kill-region (region-beginning) (region-end)) + (backward-kill-word arg))) + (defmacro when-unfocused (name &rest forms) "Define a function NAME, executing FORMS, that fires when Emacs is unfocused." -- cgit 1.4.1-21-gabe81