Skip to content

Let Lisp IMEs compose in read-only ghostel buffers - #510

Merged
dakra merged 1 commit into
dakra:mainfrom
junghan0611:fix/lisp-ime-readonly-compose
Jul 6, 2026
Merged

dakra merged 1 commit into
dakra:mainfrom
junghan0611:fix/lisp-ime-readonly-compose

Conversation

@junghan0611

Copy link
Copy Markdown
Contributor

Context

Thank you for the continued work on ghostel — it has become the terminal
integration I reach for daily, running Emacs -nw in a terminal with the
built-in Korean input method (hangul2-input-method). This is a corner that is
easy to never encounter unless you type CJK through Emacs' Lisp IMEs, so I hope a
small report from that corner is useful.

This follows up on #343 (the IME-forward + redraw-guard work you kindly merged).
That infrastructure still works — this is a narrow interaction with a later
change.

The regression

9e8460a ("Make ghostel buffers read-only") interacts with the IME-commit path
from #343. Several Lisp IMEs gate composition on buffer-read-only directly,
not through inhibit-read-only. hangul2-input-method (and the 3-Bulsik
variants) open with:

(if (or buffer-read-only ...) (list key) ...)

so they return the raw key untranslated whenever the buffer is read-only. The
commit-forward wrapper binds inhibit-read-only around the input method, which
lifts the modification barrier but leaves buffer-read-only set — so the IME
never composes in a protected ghostel buffer, and the un-composed keystroke is
forwarded to the PTY instead of the committed syllable. In practice, Korean input
stopped composing entirely in ghostel after buffers became read-only.

The fix

Bind buffer-read-only to nil alongside inhibit-read-only around the
input-method call in ghostel-ime--wrap-input-method, so the IME sees a writable
buffer. The transient insertion is still removed once the call returns
(buffer-read-only is restored), and the committed text is forwarded to the PTY
exactly as before — behavior is unchanged for every other path.

Scope is deliberately minimal: one functional line in ghostel-ime.el, plus a
characterization test with a fake IME that mirrors hangul's read-only gate (it
fails without the change). ghostel.el core is untouched.

Verification

Rebased cleanly onto current main (v0.41.0 + 3 commits) — the touched files
were byte-identical from v0.38 through v0.41, so this replays without conflict.
All green locally:

  • make test (elisp) — pass
  • make test-native — pass
  • make byte-compile with byte-compile-error-on-warn — no warnings
  • make checkdoc on the changed file — clean

I keep this rebased against upstream continuously, so I'm happy to trim, reshape,
or fold it however fits your taste — no rush on your end. Thanks again for the
care you put into this project.

Comment thread lisp/ghostel-ime.el Outdated
(eq original #'list))
(list key)
(let ((events (let ((inhibit-read-only t))
;; Bind `buffer-read-only' to nil, not just `inhibit-read-only', around

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably make that code comment a one or two-liner.
For more details the future dev can always check the test or 'git blame'.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call — trimmed it to two lines (1c70fc9). The full rationale now lives in the test docstring and git blame, as you suggested. Thanks for the quick look!

Since ghostel buffers became read-only, Korean (and other Lisp IMEs that
gate on the variable directly) stopped composing.  hangul2-input-method
and the 3-Bulsik variants open with

  (if (or buffer-read-only ...) (list key) ...)

and return the key untranslated whenever buffer-read-only is non-nil.
The commit-forward wrapper bound inhibit-read-only around the input
method, which lifts the modification barrier but leaves buffer-read-only
set, so the IME never composed and the raw keystroke was forwarded
instead of the committed syllable.

Bind buffer-read-only to nil as well around the input-method call so the
IME sees a writable buffer.  The transient insertion is still deleted
(buffer-read-only is restored once the call returns) and forwarded to
the PTY exactly as before.

Add a characterization test with a fake IME mirroring hangul's read-only
gate; it fails without this change.
@junghan0611
junghan0611 force-pushed the fix/lisp-ime-readonly-compose branch from adf2f02 to 1c70fc9 Compare July 6, 2026 09:09
@dakra
dakra merged commit 1c70fc9 into dakra:main Jul 6, 2026
41 of 42 checks passed
@dakra

dakra commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Thanks. Merged.

This branch was previously deployed

1 inactive deployment
github-pages — 1c70fc98 Deployed Jul 6, 2026 by dakra via deploy #80
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.

2 participants