From 10d371e4fa0aa5f18f006f6698052ba18c1f5987 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Tue, 30 Nov 2021 16:46:24 +0100 Subject: Document pixel-fill-region * doc/lispref/text.texi (Filling): Document pixel-fill-region. * lisp/textmodes/pixel-fill.el (pixel-fill-width): Add new helper function. --- lisp/textmodes/pixel-fill.el | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'lisp/textmodes/pixel-fill.el') diff --git a/lisp/textmodes/pixel-fill.el b/lisp/textmodes/pixel-fill.el index eff09dfca65..a66f07e1a99 100644 --- a/lisp/textmodes/pixel-fill.el +++ b/lisp/textmodes/pixel-fill.el @@ -43,6 +43,28 @@ of a line or the end of a line." :type 'boolean :version "29.1") +(defun pixel-fill-width (&optional columns window) + "Return the pixel width corresponding to COLUMNS in WINDOW. +If COLUMNS in nil, use the enture window width. + +If WINDOW is nil, this defaults to the current window." + (unless window + (setq window (selected-window))) + (let ((frame (window-frame window))) + (if columns + (* (frame-char-width frame) columns) + (- (window-body-width nil t) + (* 2 (frame-char-width frame)) + ;; We need to adjust the available width for when the user + ;; disables the fringes, which will cause the display + ;; engine usurp one column for the continuation glyph. + (if (and (fboundp 'fringe-columns) + (or (not (zerop (fringe-columns 'right))) + (not (zerop (fringe-columns 'left))))) + 0 + (* (frame-char-width frame) 2)) + 1)))) + (defun pixel-fill-region (start end pixel-width) "Fill the region between START and END. This will attempt to reformat the text in the region to have no -- cgit v1.2.3