Closed sjbach closed 4 years ago
Possible workaround (hacky): when updating the which-key
buffer, unless (display-graphic-p)
append a trailing space to each line of the content to be printed, fit the buffer as usual, and override the display of the $
truncation glyph:
(set-display-table-slot buffer-display-table 'truncation ?\ )
The lines will still be truncated, but invisibly, and the missing characters will just be the padding that we added.
Try (setq which-key-allow-imprecise-window-fit t)
Like you suggest it has something to do with how emacs shrinks the buffer using fit-window-to-buffer
, but I can't see what I'm doing wrong on the which-key side. Even if I try to trick which-key into making a bigger buffer, the fit-window-to-buffer
routine undoes it and yields the same result.
Yep, which-key-allow-imprecise-window-fit
appears to be a better option for terminal Emacs.
I agree which-key is blameless (in spirit) - this is assuredly an Emacs wart. Just one that is unlikely to go away.
Thanks for your work, by the way. This is an excellent package.
In that case, I think I will make it the default in the terminal, since it doesn't sacrifice much.
Thanks!
See #113 for context and a screenshot.
I believe there's a further interaction here, as even with an ASCII separator,
which-key
consistently under-reserves side window width by one column in terminal Emacs (for me).This results from the missing fringe in the terminal: "... when fringes are not available, Emacs uses the leftmost and rightmost character cells to indicate continuation and truncation ... . This reduces the width available for displaying text on each line, because the character cells used for truncation and continuation indicators are reserved for that purpose."
And then in the docstring for
window-body-width
, which underliesfit-window-to-buffer
(which is called bywhich-key--show-buffer-side-window
): "Note that the returned value includes the column reserved for the continuation glyph."So it sounds like
window-body-width
is kind-of misleading in a terminal, as its count includes the reserved$
glyph column even though content can't be shown there.It's pretty simple to demonstrate this:
And note that the "fitted" window truncates at least one of the lines in
*Help*
by one column. I'm supposing the mis-fit of thewhich-key
buffer is the same phenomenon.