From 2cd476d2b1428ea5e131d3de549f3090e23e8148 Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Wed, 6 Nov 2024 16:51:48 -0800 Subject: [PATCH] Fix xclip-mode to not print an error when there is no selection --- init.el | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/init.el b/init.el index 61c849d..c2096f9 100644 --- a/init.el +++ b/init.el @@ -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 ()