about summary refs log tree commit diff
path: root/emacs
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2020-09-07T15·12+0100
committerWilliam Carroll <wpcarro@gmail.com>2020-09-07T15·14+0100
commit0f2a13a32ac63dce6506965d735ca8a36f477740 (patch)
treeb8a2fbb41b2e9b8db4b11864a38d2d7d35d65d5d /emacs
parent3dc10f167bc61ba58fefa141078dc4693101bf9b (diff)
Vertically align search results conditionally
Only when `window-system` is set.
Diffstat (limited to 'emacs')
-rw-r--r--emacs/.emacs.d/wpc/keybindings.el23
1 files changed, 13 insertions, 10 deletions
diff --git a/emacs/.emacs.d/wpc/keybindings.el b/emacs/.emacs.d/wpc/keybindings.el
index 722042445f2b..a9f902ab9819 100644
--- a/emacs/.emacs.d/wpc/keybindings.el
+++ b/emacs/.emacs.d/wpc/keybindings.el
@@ -107,16 +107,19 @@
 (global-evil-surround-mode 1)
 
 ;; Ensure the Evil search results get centered vertically.
-(progn
-  (defadvice isearch-update
-      (before advice-for-isearch-update activate)
-    (evil-scroll-line-to-center (line-number-at-pos)))
-  (defadvice evil-search-next
-      (after advice-for-evil-search-next activate)
-    (evil-scroll-line-to-center (line-number-at-pos)))
-  (defadvice evil-search-previous
-      (after advice-for-evil-search-previous activate)
-    (evil-scroll-line-to-center (line-number-at-pos))))
+;; When Emacs is run from a terminal, this forces Emacs to redraw itself, which
+;; is visually disruptive.
+(when window-system
+  (progn
+    (defadvice isearch-update
+        (before advice-for-isearch-update activate)
+      (evil-scroll-line-to-center (line-number-at-pos)))
+    (defadvice evil-search-next
+        (after advice-for-evil-search-next activate)
+      (evil-scroll-line-to-center (line-number-at-pos)))
+    (defadvice evil-search-previous
+        (after advice-for-evil-search-previous activate)
+      (evil-scroll-line-to-center (line-number-at-pos)))))
 
 (key-chord-mode 1)
 (key-chord-define evil-insert-state-map "jk" 'evil-normal-state)