25 aug. 2025 kl. 22.31 skrev Daniel Mendler <[email protected]>:
> When using Unicode glyphs, org-habit-build-graph breaks due to a recent > change in Emacs master. Emacs master disallows resizing unibyte strings > to multibyte strings. > > (setq org-habit-overdue-glyph ?• > org-habit-alert-glyph ?• > org-habit-today-glyph ?• > org-habit-completed-glyph ?◦) Interesting, thank you for reporting it! I've seen this kind of code only once before, in ruler-mode.el, and a simple fix is to work on a vector instead and convert it to a string at the end. String properties can be gathered and applied afterwards. The attached patch (untested!) shows how this might be done. No doubt it can be improved. If you are happy with it, I'll push it to Emacs master. (By the way, did the old code work if you used the glyph `·`?) > Instead of mutating strings, a better approach in org-habit-build-graph > could be to concatenate a new string? A vector can be a straightforward one-to-one replacement in cases like this. Building a string from smaller pieces is generally a good solution, and lends itself to a mutation-free coding style that makes code easy to read and reason about. Another way is to use a temporary buffer. > It seems the goal of upstream Emacs is to move away from string mutations? Only very slowly. Almost all modern languages have immutable strings and for good reasons, but the goal right now is to do away with the rare kinds of mutation that cause the most harm, in this case a feature whose mere existence imposes extra costs on code that does not use it.
org-habit.diff
Description: Binary data
