Build habit graph strings without aset - #12
Merged
Conversation
`make-string` returns a unibyte string, and Emacs 31 no longer lets `aset` widen it when storing a non-ASCII glyph such as the default ✓ or ☐; it signals "Attempt to store non-byte value into unibyte string". Passing the multibyte flag is not enough either, since Emacs 31 also rejects an `aset` that changes a character's byte length. Concatenate the glyphs up front and only attach text properties afterwards. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
org-window-habit-make-graph-stringallocated its buffer withmake-string, which returns a unibyte string, then wrote the glyphs in withaset. Emacs 30 silently widened the string to multibyte on the first non-ASCII store. Emacs 31 does not, and signals:Since the default glyphs are
✓(org-window-habit-completed-glyph) and☐(org-window-habit-completion-needed-today-glyph), this breaks habit rendering outright on Emacs 31. It took down every/agendarequest on a deployed org-agenda-api instance as soon as its container picked up Emacs 31.1.Passing the multibyte flag to
make-stringis not a fix either: Emacs 31 also rejects anasetthat changes a character's byte length.Fix
Build the string from the glyphs with
concatup front, then attach the face properties. No in-place character mutation.Testing
nix flake check(byte-compile, checkdoc, package-lint, 277 ERT tests) passes against both Emacs 30.2 and Emacs 31.1. Addedowh-test-make-graph-string-non-ascii-glyphs, which fails on the old implementation under Emacs 31 and asserts the glyphs, per-character faces, and the graph text property.🤖 Generated with Claude Code