Skip to content

Add ghostel-readonly-change-hook - #737

Merged
dakra merged 2 commits into
mainfrom
feat/readonly-change-hook
Oct 13, 2026
Merged

dakra merged 2 commits into
mainfrom
feat/readonly-change-hook

Conversation

@dakra

@dakra dakra commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Summary

  • New ghostel-readonly-change-hook, run from ghostel--sync-read-only whenever buffer-read-only actually flips: process spawn and exit, and every input-mode switch. Gives state-driven integrations (cursor shape keyed on read-only state, mode-line indicators) a supported trigger instead of advising internals.
  • Line-mode entry and teardown and buffer reinit wrote buffer-read-only directly between two syncs. The writes were redundant (the code in between binds inhibit-read-only) and would have hidden the copy↔line flips from the hook, so they now go through the sync.

Closes #719.

Test plan

  • make -j8 all clean (build, lint, elisp + native tests).
  • New ERT test ghostel-test-readonly-change-hook-fires-on-change-only: fires on t→nil and nil→t, not on a no-op resync.
  • Live in a sandboxed Emacs with zsh, logging (input-mode read-only) per firing:
    • spawn → (semi-char nil)
    • copy → line → copy → line → (copy t) (line nil) (copy t) (line nil)
    • line → semi-char → line → char → no firing (all writable)
    • char → emacs → semi-char → (emacs t) (semi-char nil)
    • exit in semi-char → (semi-char t); exit in line mode → none (line mode stays writable)
    • ghostel-exec reinit of a dead line-mode buffer → (semi-char t) (semi-char nil)

Run a hook from ghostel--sync-read-only whenever buffer-read-only
actually flips, so integrations that derive state from it (cursor
shape, mode-line indicators) have a supported trigger for the spawn,
process exit and input-mode transitions instead of advising internals.

Line-mode entry and teardown and buffer reinit wrote buffer-read-only
directly between two syncs; those writes were redundant (the code in
between binds inhibit-read-only) and would have hidden the copy<->line
flips from the hook, so they now go through the sync as well.

Closes #719.
An interactive ghostel-compile run is writable until the process exits,
and finalize switched to the compilation-derived major mode without
syncing, so ghostel-readonly-change-hook never saw the exit.  Sync right
after the terminal teardown.

During a compilation-style run the buffer keeps ghostel-mode but uses
ghostel-compile-view-mode-map, which lacked the C-x C-q remap, so
read-only-mode toggled buffer-read-only underneath the renderer.  Remap
it to ghostel-readonly-enter while the buffer is still ghostel-mode; the
finished compilation buffer keeps plain read-only-mode.
@dakra
dakra merged commit 2c78633 into main Oct 13, 2026
33 checks passed
@dakra
dakra deleted the feat/readonly-change-hook branch October 13, 2026 12:57

This branch was previously deployed

1 inactive deployment
github-pages — 2c786335 Deployed Oct 13, 2026 by dakra via deploy #220
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ghostel-post-spawn-hook

1 participant