Function: org-buffer-text-pixel-width

org-buffer-text-pixel-width is a byte-compiled function defined in org-compat.el.

Signature

(org-buffer-text-pixel-width)

Documentation

Return pixel width of text in current buffer.

This function uses buffer-text-pixel-size, when available, and falls back to window-text-pixel-size otherwise.

Source Code

;; Defined in ~/.emacs.d/elpa/org-9.8.2/org-compat.el
(defun org-buffer-text-pixel-width ()
  "Return pixel width of text in current buffer.
This function uses `buffer-text-pixel-size', when available, and falls
back to `window-text-pixel-size' otherwise."
  (if (fboundp 'buffer-text-pixel-size)
      (car (buffer-text-pixel-size nil nil t))
    (if (get-buffer-window (current-buffer))
        ;; FIXME: 10000 because `most-positive-fixnum' ain't working
        ;; (tests failing) and this call will be removed after we drop
        ;; Emacs 28 support anyway.
        (car (window-text-pixel-size
              nil (point-min) (point-max) 10000))
      (let ((dedicatedp (window-dedicated-p))
            (oldbuffer (window-buffer)))
        (unwind-protect
            (progn
              ;; Do not throw error in dedicated windows.
              (set-window-dedicated-p nil nil)
              (set-window-buffer nil (current-buffer))
              (car (window-text-pixel-size
                    nil (point-min) (point-max) 10000)))
          (set-window-buffer nil oldbuffer)
          (set-window-dedicated-p nil dedicatedp))))))