Function: diary-icalendar-format-list
diary-icalendar-format-list is a byte-compiled function defined in
diary-icalendar.el.gz.
Signature
(diary-icalendar-format-list VALUES &optional TITLE PLURAL-FORM SEP INDENT)
Documentation
Smartly format VALUES for the diary.
VALUES should be a list of strings. nil elements will be ignored, and an empty list will return nil.
TITLE is a string to add to the beginning of the list; a colon will be appended. PLURAL-FORM is the plural of TITLE, to be used when VALUES contains more than one element (default: TITLE+"s").
The strings in VALUES are first joined with SEP (default: ", "), with
"TITLE: " prepended. If the result is longer than the current value of
fill-column, the values are instead formatted one per line, with the
title on its own line at the beginning, and the whole list indented
relative to the title by INDENT spaces (default: 2). Thus, in the first
case, the result looks like:
TITLE(s): VAL1, VAL2, ...
and in the second:
TITLE(s):
VAL1
VAL2
...
Source Code
;; Defined in /usr/src/emacs/lisp/calendar/diary-icalendar.el.gz
(defun di:format-list (values &optional title plural-form sep indent)
"Smartly format VALUES for the diary.
VALUES should be a list of strings. nil elements will be ignored, and an
empty list will return nil.
TITLE is a string to add to the beginning of the list; a colon will be
appended. PLURAL-FORM is the plural of TITLE, to be used when VALUES
contains more than one element (default: TITLE+\"s\").
The strings in VALUES are first joined with SEP (default: \", \"), with
\"TITLE: \" prepended. If the result is longer than the current value of
`fill-column', the values are instead formatted one per line, with the
title on its own line at the beginning, and the whole list indented
relative to the title by INDENT spaces (default: 2). Thus, in the first
case, the result looks like:
TITLE(s): VAL1, VAL2, ...
and in the second:
TITLE(s):
VAL1
VAL2
..."
(when (cdr values)
(setq title (when title (or plural-form (concat title "s")))))
(unless indent
(setq indent 2))
;; Remove nil values and extra whitespace:
(setq values (mapcar #'string-trim (delq nil values)))
(when values
(let ((line (concat
(when title (concat title ": "))
(string-join values (or sep ", ")))))
(if (< (length line) fill-column)
line
;; Otherwise, one value per line:
(with-temp-buffer
(insert (string-join values "\n"))
(indent-code-rigidly (point-min) (point-max) indent)
(goto-char (point-min))
(when title
(insert title ":\n"))
(buffer-string))))))