While on a brink of sanity I’m wondering how clipboard should work in doom emacs. You can’t put EVERY word into clipboard that gets deleted…
But putting this (setq x-select-enable-clipboard nil)
makes X11 clipboard not work at all…
While on a brink of sanity I’m wondering how clipboard should work in doom emacs. You can’t put EVERY word into clipboard that gets deleted…
But putting this (setq x-select-enable-clipboard nil)
makes X11 clipboard not work at all…
My current solution is to disable clipboard/kill-ring transfers AND bind Ctrl+Shift+C and Ctrl+Shift+v to copy/paste selected blocks to X11 clipboard.
;; don't put deleted strings to X11 clipboard
(setq select-enable-clipboard nil)
;; copying and pasting selected blocks in visual mode to and from X11 clipboard
(map! "S-C-c" #'clipboard-kill-ring-save)
(map! "S-C-v" #'clipboard-yank)
Could this be considered a sane default?
I know I’m late to this, but I think it looks perfectly sensible! Not sure about as a default though.
If you just want word deletions to not copy then you could rebind kill-word
to a delete-word command, something like this:
(defun delete-word (arg)
"Kill characters forward until encountering the end of a word.
With argument ARG, do this that many times."
(interactive "p")
(delete-region (point) (progn (forward-word arg) (point))))
(map! "<remap> <kill-word>" #'delete-word
"<remap> <kill-backward-word" #'doom/delete-backward-word)
For what it’s worth, here’s my approach to try & make Emacs’ copy/paste fit my mental model a bit better: dotfiles/stow/emacs/.doom.d/mine/clipboard.el at 003042fbc99e1c3233f6f3a4714495b38d7be580 · jdelStrother/dotfiles · GitHub
I use simpleclip-mode to disconnect emacs’ kill ring from the system pasteboard by default, and then add some bindings so that user-activated copy operations (eg selecting a region and hitting y
) still get synced with the system pasteboard.
If you replace simpleclip with manually setting select-enable-clipboard
to nil
, and re-enabling it during relevant commands (through let
in a rebind), then it should work in emacs-everywhere.
I checked and simpleclip also does this, but it also disables x-select-enable-clipboard
(presumably to support older versions), and temporarily replaces the interprogram-*-functions. I’m guessing the last part is what breaks emacs-everywhere.
I use "+y
to yank to clipboard, although in the future I may to rebind somehow like JdelStrother does. Note that the advice is needed for these +default
commands, because they presently don’t accept a register (and I can’t imagine not wanting them in my clipboard manager anyhow).
(after! evil
(setq select-enable-clipboard nil)
(defadvice! my-force-enable-clipboard (orig-fun &rest args)
"enables clipboard sync for commands that benefit from it.
E.g. for commands that copy particularly useful text."
:around '(+default/yank-buffer-path
+default/yank-buffer-contents
+default/yank-buffer-path-relative-to-project)
(let ((select-enable-clipboard t))
(apply orig-fun args))))
(the (after! evil
is unnecessary, I just assume I’ll find clipboard sync more useful if evil isn’t available, since I won’t have "+
)
apologies if I came across as rude or pushy w/ my suggestion!
(evil-define-operator jds-evil-yank-to-system (beg end type register yank-handler)
"Save the characters in motion into the kill-ring."
:move-point nil
:repeat nil
(interactive "<R><x><y>")
(let ((select-enable-clipboard t))
(evil-yank beg end type register yank-handler)))
thanks, I’ll give it a try. After over a year since posting it (and after recovering my sanity) I’ve grown used to having two separate clipboarde to stash different information. However, y
keybinding is much easier to use than ctrl shfit c
, so I may still come around.
Nice, thankyou! I’ve dropped simpleclip-mode and updated my dotfiles with your suggestion: dotfiles/stow/emacs/.doom.d/mine/clipboard.el at 6e14f350500bd3bc1b0b79f25b9a0330840faf19 · jdelStrother/dotfiles · GitHub