aboutsummaryrefslogtreecommitdiff
path: root/modules/ui-config.el
diff options
context:
space:
mode:
Diffstat (limited to 'modules/ui-config.el')
-rw-r--r--modules/ui-config.el69
1 files changed, 3 insertions, 66 deletions
diff --git a/modules/ui-config.el b/modules/ui-config.el
index 7afe528b2..32bd393f5 100644
--- a/modules/ui-config.el
+++ b/modules/ui-config.el
@@ -94,72 +94,9 @@ When `cj/enable-transparency' is nil, reset alpha to fully opaque."
(if cj/enable-transparency "enabled" "disabled")))
;; ----------------------------------- Cursor ----------------------------------
-;; set cursor color according to mode
-;;
-;; #f06a3f indicates a read-only document
-;; #c48702 indicates overwrite mode
-;; #64aa0f indicates insert and read/write mode
-
-(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/--buffer-cursor-state ()
- "Return the buffer-state symbol used to choose the cursor color.
-
-One of `read-only', `overwrite', `modified', or `unmodified' — keys
-of `cj/buffer-status-colors'.
-
-A live ghostel terminal (in `ghostel-mode' and an input mode that
-forwards keys — semi-char / char / line) reports `unmodified' even
-though the buffer is read-only: keystrokes go to the terminal process,
-so from the user's side the buffer is writeable and the read-only
-(orange) cursor would be misleading. ghostel's `copy' and `emacs'
-input modes are the exception — there the buffer really is a read-only
-Emacs buffer the user navigates, so it falls through to `read-only'
-and keeps the orange cursor."
- (cond
- ((and (eq major-mode 'ghostel-mode)
- (not (memq (bound-and-true-p ghostel--input-mode) '(copy emacs))))
- 'unmodified)
- (buffer-read-only 'read-only)
- (overwrite-mode 'overwrite)
- ((buffer-modified-p) 'modified)
- (t 'unmodified)))
-
-(defun cj/set-cursor-color-according-to-mode ()
- "Change cursor color according to buffer state (modified, read-only, overwrite).
-Only updates for real user buffers, not internal/temporary buffers.
-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*, etc.)
- (unless (string-prefix-p " " (buffer-name)) ; Internal buffers start with space
- (let ((color (alist-get (cj/--buffer-cursor-state) cj/buffer-status-colors)))
- ;; Only skip if BOTH color AND buffer are the same (optimization)
- ;; This allows color to update when buffer state changes
- (unless (and (string= color cj/-cursor-last-color)
- (string= (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 coloring (both the
+;; cursor and the modeline buffer-name) was removed -- changing color by buffer
+;; write state was more confusing than useful.
;; Don’t show a cursor in non-selected windows:
(setq cursor-in-non-selected-windows nil)