Fix xclip-mode to not print an error when there is no selection

This commit is contained in:
Alexander Rosenberg 2024-11-06 16:51:48 -08:00
parent 738cd67f00
commit 2cd476d2b1
Signed by: Zander671
GPG Key ID: 5FD0394ADBD72730

24
init.el
View File

@ -633,7 +633,27 @@ in the region and indents once)."
;; allow copy from terminal
(use-package xclip
:config
(xclip-mode 1))
(xclip-mode 1)
(defun my/-xclip-detect-wl-paste-error (oldfun type)
(if (eq xclip-method 'wl-copy)
;; Direct from `xclip-get-selection'
(when (and (getenv "WAYLAND_DISPLAY")
(memq type '(clipboard CLIPBOARD primary PRIMARY)))
(let* ((exit-code 0)
(output
(with-output-to-string
(setq exit-code
(apply #'call-process (replace-regexp-in-string
"\\(.*\\)copy" "\\1paste"
xclip-program 'fixedcase)
nil standard-output nil
"-n" (if (memq type '(primary PRIMARY))
'("-p")))))))
(if (zerop exit-code)
output
"")))
(funcall oldfun type)))
(advice-add 'xclip-get-selection :around 'my/-xclip-detect-wl-paste-error))
;; which-key
(use-package which-key
@ -1939,6 +1959,8 @@ If no name is given, list all bookmarks instead."
(use-package proced
:bind ("C-x j" . proced)
:init
(evil-define-key '(motion visual normal) proced-mode-map
"u" 'proced-unmark)
(setq proced-auto-update-flag t
proced-auto-update-interval 1)
(defun my/-setup-proced-mode ()