Function: visual-wrap--content-prefix
visual-wrap--content-prefix is a byte-compiled function defined in
visual-wrap.el.gz.
Signature
(visual-wrap--content-prefix PREFIX POSITION)
Documentation
Get the next-line prefix for the specified first-line PREFIX.
POSITION is the position in the buffer where PREFIX is located.
This returns a string prefix to use for subsequent lines; an integer, indicating the number of canonical-width spaces to use; or nil, if PREFIX was empty.
Source Code
;; Defined in /usr/src/emacs/lisp/visual-wrap.el.gz
(defun visual-wrap--content-prefix (prefix position)
"Get the next-line prefix for the specified first-line PREFIX.
POSITION is the position in the buffer where PREFIX is located.
This returns a string prefix to use for subsequent lines; an integer,
indicating the number of canonical-width spaces to use; or nil, if
PREFIX was empty."
(cond
((string= prefix "")
nil)
((or (and adaptive-fill-first-line-regexp
(string-match adaptive-fill-first-line-regexp prefix))
(and comment-start-skip
(string-match comment-start-skip prefix)))
;; If we want to repeat the first-line prefix on subsequent lines,
;; return its string value. However, we remove any `wrap-prefix'
;; property that might have been added earlier. Otherwise, we end
;; up with a string containing a `wrap-prefix' string containing a
;; `wrap-prefix' string...
(remove-text-properties 0 (length prefix) '(wrap-prefix) prefix)
prefix)
(t
;; Otherwise, we want the prefix to be whitespace of the same width
;; as the first-line prefix. We want to return an integer width (in
;; units of the font's average-width) large enough to fit the
;; first-line prefix.
(let ((avg-space (propertize (buffer-substring position (1+ position))
'display '(space :width (1 . width)))))
;; Remove any `min-width' display specs since we'll replace with
;; our own later in `visual-wrap--apply-to-line' (bug#73882).
(add-display-text-property 0 (length prefix) 'min-width nil prefix)
(max (string-width prefix)
(ceiling (string-pixel-width prefix (current-buffer))
(string-pixel-width avg-space (current-buffer))))))))