Re: Position buffer contents at bottom of window

Joost Kremers <[email protected]> Thu, 25 Jun 2026 00:04:39 +0200
Newsgroups gmane.emacs.help
Message-ID <[email protected]>
On Wed, Jun 24 2026, Eli Zaretskii wrote:
>> From: Joost Kremers <[email protected]>
>> Cc: [email protected]
>> Date: Wed, 24 Jun 2026 15:40:21 +0200
>> 
>> On Wed, Jun 24 2026, Eli Zaretskii wrote:
>> > Btw, why don't you use recenter-top-bottom?
>> 
>> My first idea was to use `(recenter -1)`, which works predictably, but it
>> often leaves a one-line gap between the bottom window edge and the last
>> buffer line. I'm trying to get rid of that gap.
>
> Please show the case where this gap happens.  This works for me with
> buffers that have the last line end in a newline:
>
>   (progn
>     (goto-char (1- (point-max)))
>     (recenter -1 t))

I'll need to see if I can come up with a minimal example, because I cannot
show the actual code, unfortunately. However, the buffer contains a series
of images, one per line, with newlines in between. The images are higher
than the frame's character height, though I don't know if that's relevant.
They also all have `:ascent` set to 100, so they sit on the base line.

The last line of the buffer has a single newline without additional text.
Placing point at `(1- (point-max))` puts it right after the last image, so
`(recenter -1)` should, IIUC, place the image right above the window
bottom, with the final empty line invisible (or at least partially
invisible). But in actual fact that line is still completely visible. I can
move the cursor to it without causing any scrolling.

-- 
Joost Kremers
Life has its moments