diff options
| author | Craig Jennings <c@cjennings.net> | 2026-06-15 22:38:46 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-06-15 22:39:18 -0500 |
| commit | 50d1b1c0a8d026d3b74d36f2e59b2471db728754 (patch) | |
| tree | 8e4653423bb9507e44ddd9147e8fef45973b861e /modules | |
| parent | 35c0d683574f1d705f8dfffd260baa626ddbf116 (diff) | |
| download | dotemacs-50d1b1c0a8d026d3b74d36f2e59b2471db728754.tar.gz dotemacs-50d1b1c0a8d026d3b74d36f2e59b2471db728754.zip | |
refactor(ui-config): drop buffer-state cursor coloring
A cursor that changed color by buffer state was confusing. Remove cj/set-cursor-color-according-to-mode, its two cache defvars, and the post-command / server-after-make-frame hook registrations; the cursor now uses the theme cursor face. The cj/buffer-status-state / cj/buffer-status-color classifier stays in user-constants.el for the modeline buffer-name indicator. Delete the cursor-function integration test; keep the classifier tests.
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/ui-config.el | 49 |
1 files changed, 4 insertions, 45 deletions
diff --git a/modules/ui-config.el b/modules/ui-config.el index 86670b29d..05448b3c5 100644 --- a/modules/ui-config.el +++ b/modules/ui-config.el @@ -94,51 +94,10 @@ When `cj/enable-transparency' is nil, reset alpha to fully opaque." (if cj/enable-transparency "enabled" "disabled"))) ;; ----------------------------------- Cursor ---------------------------------- -;; Set the cursor color from the active theme's faces according to buffer state. -;; The state classifier and the state->face map live in user-constants.el -;; (cj/buffer-status-state / cj/buffer-status-faces, colored via the theme's -;; error / warning / success faces) and are shared with the modeline buffer-name -;; indicator, so the cursor and the modeline stay in sync. - -(defvar cj/-cursor-last-color nil - "Last color applied by `cj/set-cursor-color-according-to-mode'.") -(defvar cj/-cursor-last-buffer nil - "Last buffer name where cursor color was applied.") - -(defun cj/set-cursor-color-according-to-mode () - "Set the cursor color from the active theme according to buffer state. -The state and its theme face come from `cj/buffer-status-state' and -`cj/buffer-status-color' (shared with the modeline), so the color follows the -loaded theme. Only updates real user buffers, not internal/temporary ones; a -no-op on non-graphical frames -- TTY/batch sessions have no cursor color to set." - (when (display-graphic-p) - ;; Only update cursor for real buffers (not internal ones like *temp*, *Echo Area*). - (unless (string-prefix-p " " (buffer-name)) ; internal buffers start with a space - (let ((color (cj/buffer-status-color (cj/buffer-status-state)))) - ;; Skip only when BOTH color and buffer are unchanged (so the color still - ;; updates when the buffer state changes). - (when (and color - (not (and (equal color cj/-cursor-last-color) - (equal (buffer-name) cj/-cursor-last-buffer)))) - (set-cursor-color color) - (setq cj/-cursor-last-color color - cj/-cursor-last-buffer (buffer-name))))))) - -;; Use post-command-hook to update cursor color after every command -;; This ensures cursor color always matches the current buffer's state. -;; The hook only registers under a graphical session so batch / TTY runs -;; don't pay per-command overhead for a no-op. -(when (display-graphic-p) - (add-hook 'post-command-hook #'cj/set-cursor-color-according-to-mode)) -;; Daemon mode: the first frame may be created after this module loads. -;; Re-attempt the hook install once a GUI frame appears. -(add-hook 'server-after-make-frame-hook - (lambda () - (when (and (display-graphic-p) - (not (memq #'cj/set-cursor-color-according-to-mode - post-command-hook))) - (add-hook 'post-command-hook - #'cj/set-cursor-color-according-to-mode)))) +;; The cursor uses the theme's cursor face. Buffer-state cursor coloring was +;; removed -- a cursor that changed color by buffer state was confusing. The +;; cj/buffer-status-state / cj/buffer-status-color classifier stays in +;; user-constants.el; the modeline buffer-name indicator still uses it. ;; Don’t show a cursor in non-selected windows: (setq cursor-in-non-selected-windows nil) |
