Function: org-wrap
org-wrap is a byte-compiled function defined in org-macs.el.gz.
Signature
(org-wrap STRING &optional WIDTH LINES)
Documentation
Wrap string to either a number of lines, or a width in characters.
If WIDTH is non-nil, the string is wrapped to that width, however many lines that costs. If there is a word longer than WIDTH, the text is actually wrapped to the length of that word. IF WIDTH is nil and LINES is non-nil, the string is forced into at most that many lines, whatever width that takes. The return value is a list of lines, without newlines at the end.
Source Code
;; Defined in /usr/src/emacs/lisp/org/org-macs.el.gz
(defun org-wrap (string &optional width lines)
"Wrap string to either a number of lines, or a width in characters.
If WIDTH is non-nil, the string is wrapped to that width, however many lines
that costs. If there is a word longer than WIDTH, the text is actually
wrapped to the length of that word.
IF WIDTH is nil and LINES is non-nil, the string is forced into at most that
many lines, whatever width that takes.
The return value is a list of lines, without newlines at the end."
(let* ((words (split-string string))
(maxword (apply #'max (mapcar #'org-string-width words)))
w ll)
(cond (width
(org--do-wrap words (max maxword width)))
(lines
(setq w maxword)
(setq ll (org--do-wrap words maxword))
(if (<= (length ll) lines)
ll
(setq ll words)
(while (> (length ll) lines)
(setq w (1+ w))
(setq ll (org--do-wrap words w)))
ll))
(t (error "Cannot wrap this")))))