Remap C-w to backward-kill-word if the region isn't active
This commit is contained in:
parent
388dc3c704
commit
9e0e42554e
3
init.el
3
init.el
|
@ -568,7 +568,8 @@
|
||||||
attempt-orderly-shutdown-on-fatal-signal nil
|
attempt-orderly-shutdown-on-fatal-signal nil
|
||||||
find-function-C-source-directory (acdw/find-emacs-source))
|
find-function-C-source-directory (acdw/find-emacs-source))
|
||||||
|
|
||||||
(:global "M-=" count-words)
|
(:global "M-=" count-words
|
||||||
|
"C-w" acdw/kill-region-or-backward-word)
|
||||||
|
|
||||||
;; Remap C-h to DEL -- <f1> can be the "help" key
|
;; Remap C-h to DEL -- <f1> can be the "help" key
|
||||||
(define-key key-translation-map [?\C-h] [?\C-?])
|
(define-key key-translation-map [?\C-h] [?\C-?])
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
|
|
||||||
|
|
||||||
;;; Utility functions
|
;;; Utility functions
|
||||||
|
;; I don't prefix these because ... reasons. Honestly I probably should prefix
|
||||||
|
;; them.
|
||||||
|
|
||||||
(defun dos2unix (buffer)
|
(defun dos2unix (buffer)
|
||||||
"Replace \r\n with \n in 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)
|
,@(dolist (hook hook-list hook-defun-add-hook-list)
|
||||||
(push `(add-hook ',hook #',func-name) 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)
|
(defmacro when-unfocused (name &rest forms)
|
||||||
"Define a function NAME, executing FORMS, that fires when Emacs
|
"Define a function NAME, executing FORMS, that fires when Emacs
|
||||||
is unfocused."
|
is unfocused."
|
||||||
|
|
Loading…
Reference in New Issue