diff options
| author | Craig Jennings <c@cjennings.net> | 2025-11-14 01:53:30 -0600 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2025-11-14 01:53:30 -0600 |
| commit | fd1a5d308e730bad2936adb2384897bb620458be (patch) | |
| tree | 75f8e12a157421728a38e91f4d9bd64e86c822cb /modules/modeline-config.el | |
| parent | 1534be5b365431c885c4c5c09c7f157d94a9f942 (diff) | |
feat(ui): Add buffer modification state to color indicators
Change modeline filename and cursor colors to indicate buffer
modification status, not just read-only/overwrite state.
Color scheme changes:
- White (#ffffff): Unmodified writeable buffer
- Green (#64aa0f): Modified writeable buffer (unsaved changes)
- Red (#f06a3f): Read-only buffer
- Gold (#c48702): Overwrite mode active
Previously: All writeable buffers were green regardless of modification
Now: White when clean, green when dirty (better visual feedback)
Implementation:
- Updated cj/buffer-status-colors in user-constants.el:
- Changed 'normal' → 'unmodified' (white)
- Added new 'modified' state (green)
- Updated state detection in modeline-config.el:
- Now checks (buffer-modified-p) before defaulting to unmodified
- Updated cursor color logic in ui-config.el:
- Same state detection as modeline for consistency
- Added after-change-functions hook for real-time updates
- Added after-save-hook to update on save
Priority order (highest to lowest):
1. Read-only (red) - takes precedence over everything
2. Overwrite mode (gold) - takes precedence over modified state
3. Modified (green) - buffer has unsaved changes
4. Unmodified (white) - default for clean writeable buffers
Tests:
- 18 comprehensive tests in test-ui-buffer-status-colors.el
- Tests state detection logic and priority order
- Tests color constant definitions and mappings
- Tests integration with cursor and modeline
- All tests passing
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'modules/modeline-config.el')
| -rw-r--r-- | modules/modeline-config.el | 11 |
1 files changed, 6 insertions, 5 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 |
