I would like to use normal modes commands like d
c
x
etc without the content being copied to clipboard.
I want to make emacs so that only y
command will write anything to the clipboard. Other commands like d
should only delete the content without writing anything to the clipboard.
As suggested by Gordon Gustafson use arround advice
. evil-delete
is what used by emacs for all kinds of delete, so making that to delete to a blackhole register fixed the issue. Just add the following to your .emacs
(defun bb/evil-delete (orig-fn beg end &optional type _ &rest args)
(apply orig-fn beg end type ?_ args))
(advice-add 'evil-delete :around 'bb/evil-delete)
This is a step in the right direction:
(evil-define-operator evil-change-into-null-register (beg end type register yank-handler)
"Change text from BEG to END with TYPE. Do not save it in any register."
(interactive "<R><x><y>")
(evil-change beg end type ?_ yank-handler))
(evil-define-operator evil-delete-into-null-register (beg end type register yank-handler)
"Delete text from BEG to END with TYPE. Do not save it in any register."
(interactive "<R><x><y>")
(evil-delete beg end type ?_ yank-handler))
(define-key evil-normal-state-map "c" 'evil-change-into-null-register)
(define-key evil-normal-state-map "d" 'evil-delete-into-null-register)
However, C
, D
, s
, S
, x
, X
, and potentially several others would also need to be rebound, and this doesn't seem to work properly for x
(it still expects a motion):
(evil-define-operator evil-delete-char-into-null-register (beg end type register yank-handler)
"Delete text from BEG to END with TYPE. Do not save it in any register."
(interactive "<R><x>")
(evil-delete-char beg end type ?_ yank-handler))
(define-key evil-normal-state-map "x" 'evil-delete-char-into-null-register)
Your best bet is add around advice around evil-delete
and always pass it the ?_
register (sorry, I don't have time to do that now, but I thought I'd post what I had).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With