Function: visual-wrap-prefix-function

visual-wrap-prefix-function is a byte-compiled function defined in visual-wrap.el.gz.

Signature

(visual-wrap-prefix-function BEG END)

Documentation

Indent the region between BEG and END with visual filling.

Source Code

;; Defined in /usr/src/emacs/lisp/visual-wrap.el.gz
(defun visual-wrap-prefix-function (beg end)
  "Indent the region between BEG and END with visual filling."
  ;; Any change at the beginning of a line might change its wrap
  ;; prefix, which affects the whole line.  So we need to "round-up"
  ;; `end' to the nearest end of line.  We do the same with `beg'
  ;; although it's probably not needed.
  (goto-char end)
  (unless (bolp) (forward-line 1))
  (setq end (point))
  (goto-char beg)
  (forward-line 0)
  (setq beg (point))
  (visual-wrap--remove-properties beg end)
  (while (< (point) end)
    ;; Check if the display property at the end of this line is "safe".
    (if (visual-wrap--display-property-safe-p
         (get-char-property (pos-eol) 'display))
        ;; If so, we can apply our visual wrapping properties to this
        ;; line and continue to the next line.
        (progn
          (visual-wrap--apply-to-line)
          (forward-line))
      ;; Otherwise, skip ahead until the end of any unsafe display
      ;; properties.  NOTE: We do this out of an abundance of caution to
      ;; be as certain as possible that we're not interfering with the
      ;; display engine.  If this results in cases where we fail to add
      ;; wrapping properties when we should, then we should remove the
      ;; `while' loop below.  Without that loop, this should be the same
      ;; logic `handle_single_display_spec' in xdisp.c uses for
      ;; determining what text to replace.  See bug#73600.
      (goto-char (next-single-char-property-change (pos-eol) 'display))
      (while (not (visual-wrap--display-property-safe-p
                   (get-char-property (point) 'display)))
        (goto-char (next-single-char-property-change (point) 'display)))
      (unless (bolp) (forward-line 1))))
  `(jit-lock-bounds ,beg . ,end))