<feed xmlns='http://www.w3.org/2005/Atom'>
<title>dotemacs.git/tests/test-ui-cursor-color-integration.el, branch v0.7.2</title>
<subtitle>my Emacs configuration
</subtitle>
<id>https://git.cjennings.net/dotemacs.git/atom?h=v0.7.2</id>
<link rel='self' href='https://git.cjennings.net/dotemacs.git/atom?h=v0.7.2'/>
<link rel='alternate' type='text/html' href='https://git.cjennings.net/dotemacs.git/'/>
<updated>2025-11-14T08:25:19+00:00</updated>
<entry>
<title>fix(ui): Fix cursor color updates with post-command-hook</title>
<updated>2025-11-14T08:25:19+00:00</updated>
<author>
<name>Craig Jennings</name>
<email>c@cjennings.net</email>
</author>
<published>2025-11-14T08:25:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.cjennings.net/dotemacs.git/commit/?id=7b982b1984dd37af42a2dfc9f4c3e52b27102860'/>
<id>urn:sha1:7b982b1984dd37af42a2dfc9f4c3e52b27102860</id>
<content type='text'>
The cursor color was not updating correctly when switching buffers
or modifying files. The original implementation used window-buffer-change
and other specific hooks, but these were insufficient and internal
buffers were interfering with cursor color updates.

Root cause:
- Cursor color is global (one cursor for all of Emacs)
- Previous hooks fired in internal buffer contexts (*Echo Area*, *temp*)
- This caused cursor to be set to white (unmodified) even when in
  read-only buffers like dashboard

Solution:
- Use post-command-hook which runs after every command in current buffer
- Ignore internal buffers (names starting with space)
- Cache optimization prevents redundant set-cursor-color calls

Behavior now:
- Dashboard (read-only): Red cursor
- Unmodified file: White cursor
- Modified file: Green cursor
- After save: White cursor

Tests:
- Added 9 integration tests in test-ui-cursor-color-integration.el
- Tests verify hook installation, buffer switching, modification tracking
- All 27 tests passing (18 unit + 9 integration)

Integration tests catch issues that unit tests miss:
- Unit tests verified state detection logic (✓)
- Integration tests verify hooks fire at right times (✓ now)
- Integration tests verify real buffer switching behavior (✓ now)

Cleanup:
- Removed debug code from init.el
- Removed debug-cursor-color.el temporary file

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude &lt;noreply@anthropic.com&gt;
</content>
</entry>
</feed>
