From d3747f71c45bec3d0c086b4a99588207bc04b3f5 Mon Sep 17 00:00:00 2001 From: Daneel Date: Sun, 22 Feb 2026 23:03:16 +0100 Subject: [PATCH] fix: magnifier cursor visible, line nums hidden, M-x/which-key safe --- config.el | 44 +++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/config.el b/config.el index 747f0d1..76754b4 100644 --- a/config.el +++ b/config.el @@ -850,21 +850,34 @@ Keeps the status bar and tab bar fully visible at any zoom level.") (defun my/mag--switch-source () "Switch magnifier to track the current buffer." - (let* ((new-source (current-buffer)) - (mag-name (format "*mag:%s*" (buffer-name new-source)))) - (my/mag--kill-indirect) - (setq my/mag--source new-source) - (setq my/mag--buffer (make-indirect-buffer new-source mag-name t)) - (when (and my/mag--window (window-live-p my/mag--window)) - (set-window-buffer my/mag--window my/mag--buffer) - (with-selected-window my/mag--window - (text-scale-set my/mag--zoom-level) - (setq-local cursor-type nil) - (setq-local scroll-margin 0))))) + (cl-block my/mag--switch-source + (let* ((new-source (current-buffer)) + (mag-name (format "*mag:%s*" (buffer-name new-source)))) + ;; Don't switch to transient/minibuffer buffers + (when (or (minibufferp new-source) + (string-prefix-p " " (buffer-name new-source))) + (cl-return-from my/mag--switch-source)) + (my/mag--kill-indirect) + (setq my/mag--source new-source) + (setq my/mag--buffer (make-indirect-buffer new-source mag-name t)) + (when (and my/mag--window (window-live-p my/mag--window)) + (set-window-buffer my/mag--window my/mag--buffer) + (with-selected-window my/mag--window + (text-scale-set my/mag--zoom-level) + (setq-local cursor-type 'box) + (setq-local scroll-margin 0) + (when (bound-and-true-p display-line-numbers-mode) + (display-line-numbers-mode -1)) + (when (bound-and-true-p hl-line-mode) + (hl-line-mode -1))))))) (defun my/mag--sync () "Sync magnified pane to current cursor position." (when my/mag--active + ;; Skip when minibuffer is active (M-x, vertico, which-key, etc.) + (when (or (active-minibuffer-window) + (window-minibuffer-p)) + (cl-return-from my/mag--sync)) ;; Ignore if we're in the magnifier pane itself (when (eq (selected-window) my/mag--window) (cl-return-from my/mag--sync)) @@ -884,6 +897,7 @@ Keeps the status bar and tab bar fully visible at any zoom level.") (defun my/mag--on-window-change () "Clean up if magnifier window was closed by user." (when (and my/mag--active + (not (active-minibuffer-window)) (not (and my/mag--window (window-live-p my/mag--window)))) (my/mag--disable))) @@ -904,8 +918,12 @@ Keeps the status bar and tab bar fully visible at any zoom level.") (set-window-buffer my/mag--window my/mag--buffer) (with-selected-window my/mag--window (text-scale-set my/mag--zoom-level) - (setq-local cursor-type nil) - (setq-local scroll-margin 0)) + (setq-local cursor-type 'box) + (setq-local scroll-margin 0) + (when (bound-and-true-p display-line-numbers-mode) + (display-line-numbers-mode -1)) + (when (bound-and-true-p hl-line-mode) + (hl-line-mode -1))) (setq my/mag--active t) (add-hook 'post-command-hook #'my/mag--sync) (add-hook 'window-configuration-change-hook #'my/mag--on-window-change)