Bring in backward-kill-word-or-kill-region from my config

This experience is still not as good as just using helm is. (Because
the C-l feature of helm-ff is killer)

(not to mention a properly working helm-resume)
This commit is contained in:
Vedang Manerikar 2024-11-17 12:29:17 +05:30
parent c8592e414b
commit 6ba4dbea44
2 changed files with 49 additions and 0 deletions

View file

@ -1185,6 +1185,34 @@ These are modifications to basic configuration I use on my Mac OSX machine.
(setq find-function-C-source-directory (expand-file-name "~/src/emacs/src/"))))
#+end_src
** The =unravel-essentials.el= section for ~simple.el~ changes
:PROPERTIES:
:CUSTOM_ID: h:6B18F988-DBAD-458C-97BE-129D1FF988F4
:END:
#+begin_src emacs-lisp :tangle "unravel-modules/unravel-essentials.el"
(defun vedang/backward-kill-word-or-kill-region (&optional arg)
"Rebind `C-w' to work differently based on whether a region is active.
If the region is selected, retain the original behaviour, otherwise call
`backward-kill-word' instead. ARG is passed to `backward-kill-word'."
(interactive "p")
(if (region-active-p)
(kill-region (region-beginning) (region-end))
(backward-kill-word arg)))
(use-package simple
:ensure nil
:after vertico ; so that we can bind to vertico-map
:bind
;; Rebind `C-w' to work differently based on whether a region is
;; active.
( :map global-map
("C-w" . vedang/backward-kill-word-or-kill-region)
:map vertico-map
("C-l" . vedang/backward-kill-word-or-kill-region)))
#+end_src
** Finally, we provide the =unravel-essentials.el= module
:PROPERTIES:
:CUSTOM_ID: h:c8b2f021-fe5a-4f6b-944c-20340f764fb2

View file

@ -152,4 +152,25 @@ word. Fall back to regular `expreg-expand'."
(setq source-directory (expand-file-name "~/src/emacs/src/"))
(setq find-function-C-source-directory (expand-file-name "~/src/emacs/src/"))))
(defun vedang/backward-kill-word-or-kill-region (&optional arg)
"Rebind `C-w' to work differently based on whether a region is active.
If the region is selected, retain the original behaviour, otherwise call
`backward-kill-word' instead. ARG is passed to `backward-kill-word'."
(interactive "p")
(if (region-active-p)
(kill-region (region-beginning) (region-end))
(backward-kill-word arg)))
(use-package simple
:ensure nil
:after vertico ; so that we can bind to vertico-map
:bind
;; Rebind `C-w' to work differently based on whether a region is
;; active.
( :map global-map
("C-w" . vedang/backward-kill-word-or-kill-region)
:map vertico-map
("C-l" . vedang/backward-kill-word-or-kill-region)))
(provide 'unravel-essentials)