dandavison / dandavison/xenops
xenops does not "work" until buffer is (re)fontified
- Dominant language
- Emacs Lisp
- Stars
- 346
- Forks
- 15
- PR merge metrics
- No merged PRs in 30d
Description
Steps to reproduce:
First, create a simple `test.tex` file with content
```latex
\documentclass{article}
\begin{document}
Here is math: $x^2$.
\end{document}
```
1. In a fresh emacs session, open `test.tex`
2. Turn on xenops-mode: `M-x xenops-mode`
3. Put cursor inside the math: `$x^2$`
4. Move cursor outside the math
5. Nothing happens (expected: math would render)
However, the following works as expected
1. In a fresh emacs session, open `test.tex`
2. Turn on xenops-mode: `M-x xenops-mode RET`
3. `M-x font-lock-update RET`
4. Put cursor inside the math: `$x^2$`
5. Move cursor outside the math
7. Yay! The math renders!
Step 3 can be replaced with many alternatives that indirectly will cause the buffer to be refontified, e.g., saving, editing, etc.
As far as I can tell, this is because during activation, `xenops-mode` [adds some font-lock keywords that should trigger rendering on cursor moving using `cursor-sensor-mode`](https://github.com/dandavison/xenops/blob/4d75c1cd5ee7afba62af3a39a1f43432b295c29c/lisp/xenops-math.el#L102-L103), but it doesn't actually cause these new font-lock keywords to be "applied."
I imagine this can be fixed by explicitly calling `font-lock-fontify-buffer` when mode is activated.
This is easy enough to work around, but it caused a lot of confusion for me when I followed the tutorial, which [at one point suggests that the user open a file, turn on `xenops-mode`, move the cursor in and out of math, and see a render result](https://github.com/dandavison/xenops/tree/master?tab=readme-ov-file#31-rendering-math-tables-and-tikz-content).
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the issue with the test.tex example, xenops-mode, and cursor movement, then inspect lisp/xenops-math.el around the font-lock keywords at lines 102-103. Compare activation with the manual font-lock-update workaround and verify that enabling xenops-mode alone renders the math without saving or editing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- emacs-lisp, latex
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 65/100