Function: icalendar-read-list-with
icalendar-read-list-with is a byte-compiled function defined in
icalendar-parser.el.gz.
Signature
(icalendar-read-list-with READER STRING &optional VALUE-REGEX SEPARATORS OMIT-NULLS TRIM)
Documentation
Read a list of values from STRING with READER.
READER should be a reader function that accepts a single string argument.
SEPARATORS, OMIT-NULLS, and TRIM are as in split-string.
SEPARATORS defaults to "[^\\][,;]". TRIM defaults to matching a
double quote character.
VALUE-REGEX should be a regular expression if READER assumes that individual substrings in STRING have previously been matched against this regex. In this case, each value in S is placed in a temporary buffer and the match against VALUE-REGEX is performed before READER is called.
Source Code
;; Defined in /usr/src/emacs/lisp/calendar/icalendar-parser.el.gz
(defun ical:read-list-with (reader string
&optional value-regex separators omit-nulls trim)
"Read a list of values from STRING with READER.
READER should be a reader function that accepts a single string argument.
SEPARATORS, OMIT-NULLS, and TRIM are as in `split-string'.
SEPARATORS defaults to \"[^\\][,;]\". TRIM defaults to matching a
double quote character.
VALUE-REGEX should be a regular expression if READER assumes that
individual substrings in STRING have previously been matched
against this regex. In this case, each value in S is placed in a
temporary buffer and the match against VALUE-REGEX is performed
before READER is called."
(let* ((wrapped-reader
(if (not value-regex)
;; no need for temp buffer:
reader
;; match the regex in a temp buffer before calling reader:
(lambda (s)
(with-temp-buffer
(insert s)
(goto-char (point-min))
(unless (looking-at value-regex)
(ical:signal-parse-error
(format "Expected list of values matching '%s'" value-regex)))
(funcall reader (match-string 0))))))
(seps (or separators "[^\\][,;]"))
(trm (or trim "\""))
(raw-values (split-string string seps omit-nulls trm)))
(unless (functionp reader)
(signal 'ical:parser-error
(list (format "`%s' is not a reader function" reader))))
(mapcar wrapped-reader raw-values)))