diff options
| author | Craig Jennings <c@cjennings.net> | 2026-05-12 06:07:20 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-05-12 06:07:20 -0500 |
| commit | 1c5c8bd4df3bd4fd71fad13b2b57e670a4e74355 (patch) | |
| tree | 4637ff8bb00cdaca337b8a31f3741bfee67f6fe3 /modules/selection-framework.el | |
| parent | a032f45fe30ce300163bc052257c3c5c993c85d5 (diff) | |
| download | dotemacs-1c5c8bd4df3bd4fd71fad13b2b57e670a4e74355.tar.gz dotemacs-1c5c8bd4df3bd4fd71fad13b2b57e670a4e74355.zip | |
fix(nov): rework the EPUB reading-width layout
`cj/nov--text-width-for-window' computed the target column as a percentage of `(window-body-width)'. But body width is the column count *after* the display margins. `cj/nov-update-layout' runs from `window-configuration-change-hook': it sets `visual-fill-column''s margins, which changes the body width, which fires the hook, which re-runs the layout against the now-narrower body, and so on. It's a shrinking feedback loop that bottoms out at `cj/nov-min-text-width' (40 columns) no matter what `cj/nov-margin-percent' is. That's why the column was a thin strip regardless of the margin setting.
The width is now computed from the window's *natural* column count (body width plus any margins already set), so re-running the layout is idempotent. The margin math moved into a pure `cj/nov--text-width' helper, which is what the unit tests drive, and there's a regression test that the result is the same whether or not margins are already in place.
Also:
- `+'/`=' (`cj/nov-widen-text') and `-'/`_' (`cj/nov-narrow-text') step `cj/nov-margin-percent' by `cj/nov-margin-step' and re-lay-out, reporting the new percentage. `cj/nov-margin-percent' is now clamped to 0..25, so the text column runs from 50% (the floor) to 100% (the full window).
- `cj/nov-margin-percent' default is 12 (≈76% text) for a comfortable starting width.
- `cj/nov-apply-preferences' re-renders the document at the end again. `b3b537f' removed that on the theory `visual-fill-column' would re-trigger the render. The first page came up off-center until a manual resize, so it's back.
- `cj/nov-update-layout' is now a command.
The visible result (a ~75% centered column on first open, `+`/`-` to adjust) needs a restart to confirm. The tests cover the width math and clamping, idempotency, the adjust commands and their keybindings, the command status, and the re-render.
Diffstat (limited to 'modules/selection-framework.el')
0 files changed, 0 insertions, 0 deletions
