Function: buffer-text-pixel-size
buffer-text-pixel-size is a function defined in xdisp.c.
Signature
(buffer-text-pixel-size &optional BUFFER-OR-NAME WINDOW X-LIMIT Y-LIMIT)
Documentation
Return size of whole text of BUFFER-OR-NAME in WINDOW.
BUFFER-OR-NAME must specify a live buffer or the name of a live buffer and defaults to the current buffer. WINDOW must be a live window and defaults to the selected one. The return value is a cons of the maximum pixel-width of any text line and the pixel-height of all the text lines of the buffer specified by BUFFER-OR-NAME.
The optional arguments X-LIMIT and Y-LIMIT have the same meaning as with
window-text-pixel-size.
Do not use this function if the buffer specified by BUFFER-OR-NAME is
already displayed in WINDOW. window-text-pixel-size is cheaper in
that case because it does not have to temporarily show that buffer in
WINDOW.
Probably introduced at or before Emacs version 29.1.
Source Code
// Defined in /usr/src/emacs/src/xdisp.c
{
struct window *w = decode_live_window (window);
struct buffer *b = (NILP (buffer_or_name)
? current_buffer
: XBUFFER (Fget_buffer (buffer_or_name)));
Lisp_Object buffer, value;
specpdl_ref count = SPECPDL_INDEX ();
XSETBUFFER (buffer, b);
/* The unwind form of with_echo_area_buffer is what we need here to
make WINDOW temporarily show our buffer. */
/* FIXME: Can we move this into the `if (!EQ (buffer, w->contents))`? */
record_unwind_protect (unwind_with_echo_area_buffer,
with_echo_area_buffer_unwind_data (w));
set_buffer_internal_1 (b);
if (!EQ (buffer, w->contents))
{
wset_buffer (w, buffer);
set_marker_both (w->pointm, buffer, BEG, BEG_BYTE);
set_marker_both (w->old_pointm, buffer, BEG, BEG_BYTE);
}
value = window_text_pixel_size (window, Qnil, Qnil, x_limit, y_limit, Qnil,
Qnil);
unbind_to (count, Qnil);
return value;
}