I\'d like to just delete some text so I can yank some other text instead of it. How can I do that? C-w cuts the selected text to kill ring and I end up with
Most kill functions use kill-region to do the actual work of killing text. I use a lisp macro to create delete functions from kill functions.
(defmacro jpk/delete-instead-of-kill (&rest body)
"Replaces `kill-region' with `delete-region' in BODY."
`(cl-letf (((symbol-function 'kill-region)
(lambda (beg end &optional yank-handler)
(delete-region beg end))))
,@body))
(defun jpk/delete-word (arg)
"Like `kill-word', but does not save to the `kill-ring'."
(interactive "*p")
(jpk/delete-instead-of-kill (kill-word arg)))