Function: erc-fill--wrap-measure

erc-fill--wrap-measure is a byte-compiled function defined in erc-fill.el.gz.

Signature

(erc-fill--wrap-measure BEG END)

Documentation

Return display spec width for inserted region between BEG and END.

Ignore any invisible props that may be present when figuring. Expect the target region to be free of line-prefix and wrap-prefix properties, and expect display-line-numbers-mode(var)/display-line-numbers-mode(fun) to be disabled. On Emacs 28 and below, return END minus BEG.

Source Code

;; Defined in /usr/src/emacs/lisp/erc/erc-fill.el.gz
(defun erc-fill--wrap-measure (beg end)
  "Return display spec width for inserted region between BEG and END.
Ignore any `invisible' props that may be present when figuring.
Expect the target region to be free of `line-prefix' and
`wrap-prefix' properties, and expect `display-line-numbers-mode'
to be disabled.  On Emacs 28 and below, return END minus BEG."
  ;; Rely on `buffer-text-pixel-size' here even for buffers displayed in
  ;; another window because temporarily selecting such windows via
  ;; `with-selected-window' seems to interfere with the implementation
  ;; of `erc-scrolltobottom-all' in ERC 5.6, which needs improvement.
  (if (fboundp 'buffer-text-pixel-size)
      ;; This `save-excursion' is likely unnecessary.  It was originally
      ;; meant to protect point from `buffer-text-pixel-size', which no
      ;; longer runs in the selected window's buffer.
      (save-excursion
        (save-restriction
          (narrow-to-region beg end)
          (let* ((buffer-invisibility-spec)
                 (rv (car (if (eq (selected-window) (get-buffer-window))
                              (window-text-pixel-size)
                            (buffer-text-pixel-size)))))
            (if erc-fill-wrap-use-pixels
                (if (zerop rv) 0 (list rv))
              (/ rv (frame-char-width))))))
    (- end beg)))