summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/modeline-config.el11
-rw-r--r--modules/ui-config.el13
-rw-r--r--modules/user-constants.el7
3 files changed, 19 insertions, 12 deletions
diff --git a/modules/modeline-config.el b/modules/modeline-config.el
index f2b80561..a5e23dd0 100644
--- a/modules/modeline-config.el
+++ b/modules/modeline-config.el
@@ -56,9 +56,10 @@ Example: `my-very-long-name.el' → `my-ver...me.el'"
(defvar-local cj/modeline-buffer-name
'(:eval (let* ((state (cond
- (buffer-read-only 'read-only)
- (overwrite-mode 'overwrite)
- (t 'normal)))
+ (buffer-read-only 'read-only)
+ (overwrite-mode 'overwrite)
+ ((buffer-modified-p) 'modified)
+ (t 'unmodified)))
(color (alist-get state cj/buffer-status-colors))
(name (buffer-name))
(truncated-name (cj/modeline-string-cut-middle name)))
@@ -73,8 +74,8 @@ Example: `my-very-long-name.el' → `my-ver...me.el'"
(define-key map [mode-line mouse-1] 'previous-buffer)
(define-key map [mode-line mouse-3] 'next-buffer)
map))))
- "Buffer name colored by read-only/read-write status.
-Green = writeable, Red = read-only, Gold = overwrite.
+ "Buffer name colored by modification and read-only status.
+White = unmodified, Green = modified, Red = read-only, Gold = overwrite.
Truncates in narrow windows. Click to switch buffers.")
(defvar-local cj/modeline-position
diff --git a/modules/ui-config.el b/modules/ui-config.el
index 3922ce2a..3e065370 100644
--- a/modules/ui-config.el
+++ b/modules/ui-config.el
@@ -97,11 +97,12 @@ When `cj/enable-transparency' is nil, reset alpha to fully opaque."
"Last buffer name where cursor color was applied.")
(defun cj/set-cursor-color-according-to-mode ()
- "Change cursor color according to \\='buffer-read-only or \\='overwrite state."
+ "Change cursor color according to buffer state (modified, read-only, overwrite)."
(let* ((state (cond
- (buffer-read-only 'read-only)
- (overwrite-mode 'overwrite)
- (t 'normal)))
+ (buffer-read-only 'read-only)
+ (overwrite-mode 'overwrite)
+ ((buffer-modified-p) 'modified)
+ (t 'unmodified)))
(color (alist-get state cj/buffer-status-colors)))
(unless (and (string= color cj/-cursor-last-color)
(string= (buffer-name) cj/-cursor-last-buffer))
@@ -114,6 +115,10 @@ When `cj/enable-transparency' is nil, reset alpha to fully opaque."
(lambda (_window) (cj/set-cursor-color-according-to-mode)))
(add-hook 'read-only-mode-hook #'cj/set-cursor-color-according-to-mode)
(add-hook 'overwrite-mode-hook #'cj/set-cursor-color-according-to-mode)
+;; Add hook to update cursor color when buffer is modified/saved
+(add-hook 'after-change-functions
+ (lambda (&rest _) (cj/set-cursor-color-according-to-mode)))
+(add-hook 'after-save-hook #'cj/set-cursor-color-according-to-mode)
;; Don’t show a cursor in non-selected windows:
(setq cursor-in-non-selected-windows nil)
diff --git a/modules/user-constants.el b/modules/user-constants.el
index 2a6d0ca2..eafd08e8 100644
--- a/modules/user-constants.el
+++ b/modules/user-constants.el
@@ -41,9 +41,10 @@ Example: (setq cj/debug-modules '(org-agenda mail))
;; ---------------------------- Buffer Status Colors ---------------------------
(defconst cj/buffer-status-colors
- '((read-only . "#f06a3f") ; red – buffer is read-only
- (overwrite . "#c48702") ; gold – overwrite mode
- (normal . "#64aa0f")) ; green – insert & read/write
+ '((read-only . "#f06a3f") ; red – buffer is read-only
+ (overwrite . "#c48702") ; gold – overwrite mode
+ (modified . "#64aa0f") ; green – modified & writeable
+ (unmodified . "#ffffff")) ; white – unmodified & writeable
"Alist mapping buffer states to their colors.
Used by cursor color, modeline, and other UI elements.")