From 118f0c416a7e530fd2f3472fb9612a3fb0301610 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 9 Aug 2022 18:09:26 +0200 Subject: [PATCH] refactor(evil): replace evil-visual-update-x-selection advice With the new evil-visual-update-x-selection-p setting. Also adds a more descriptive comment to this design choice. --- modules/editor/evil/config.el | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/modules/editor/evil/config.el b/modules/editor/evil/config.el index a7e603cf6..091385603 100644 --- a/modules/editor/evil/config.el +++ b/modules/editor/evil/config.el @@ -63,11 +63,15 @@ directives. By default, this only recognizes C directives.") :config (evil-select-search-module 'evil-search-module 'evil-search) - ;; stop copying each visual state move to the clipboard: - ;; https://github.com/emacs-evil/evil/issues/336 - ;; grokked from: - ;; http://stackoverflow.com/questions/15873346/elisp-rename-macro - (advice-add #'evil-visual-update-x-selection :override #'ignore) + ;; PERF: Stop copying the selection to the clipboard each time the cursor + ;; moves in visual mode. Why? Because on most non-X systems (and in terminals + ;; with clipboard plugins like xclip.el active), Emacs will spin up a new + ;; process to communicate with the clipboard for each movement. On Windows, + ;; older versions of macOS (pre-vfork), and Waylang (without pgtk), this is + ;; super expensive and can lead to freezing and/or zombie processes. + ;; + ;; UX: It also clobbers clipboard managers (see emacs-evil/evil#336). + (setq evil-visual-update-x-selection-p nil) ;; Start help-with-tutorial in emacs state (advice-add #'help-with-tutorial :after (lambda (&rest _) (evil-emacs-state +1)))