diff options
author | Lars Ingebrigtsen <larsi@gnus.org> | 2021-11-30 16:46:24 +0100 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2021-11-30 16:46:28 +0100 |
commit | 10d371e4fa0aa5f18f006f6698052ba18c1f5987 (patch) | |
tree | 372712463ed093a3bb0a31f12172928d9ee9a765 /lisp/textmodes | |
parent | 99c276b3c0aee5599c1d281c1e9fe223810784ca (diff) | |
download | emacs-10d371e4fa0aa5f18f006f6698052ba18c1f5987.tar.gz emacs-10d371e4fa0aa5f18f006f6698052ba18c1f5987.tar.bz2 emacs-10d371e4fa0aa5f18f006f6698052ba18c1f5987.zip |
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.
Diffstat (limited to 'lisp/textmodes')
-rw-r--r-- | lisp/textmodes/pixel-fill.el | 22 |
1 files changed, 22 insertions, 0 deletions
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 |