Function: icalendar-read-param-value

icalendar-read-param-value is a byte-compiled function defined in icalendar-parser.el.gz.

Signature

(icalendar-read-param-value TYPE S)

Documentation

Read a value for a parameter of type TYPE from a string S.

S should have already been matched against the regex for TYPE and the match data should be available to this function. Returns a syntax node of type TYPE containing the read value.

If TYPE accepts a list of values, S will be split on the list separator for TYPE and read individually.

Source Code

;; Defined in /usr/src/emacs/lisp/calendar/icalendar-parser.el.gz
(defun ical:read-param-value (type s)
  "Read a value for a parameter of type TYPE from a string S.
S should have already been matched against the regex for TYPE and
the match data should be available to this function.  Returns a
syntax node of type TYPE containing the read value.

If TYPE accepts a list of values, S will be split on the list
separator for TYPE and read individually."
  (let* ((value-type (get type 'ical:value-type)) ; if nil, value is just a string
         (value-regex (when (get type 'ical:value-rx)
                         (rx-to-string (get type 'ical:value-rx))))
         (list-sep (get type 'ical:list-sep))
         (substitute-val (get type 'ical:substitute-value))
         (unrecognized-val (match-string 5)) ; see :unrecognized in define-param
         (raw-val (if unrecognized-val substitute-val s))
         (one-val-reader (if (ical:value-type-symbol-p value-type)
                             (lambda (s) (ical:read-value-node value-type s))
                           #'identity)) ; value is just a string
         ;; values may be quoted even if :quoted does not require it,
         ;; so they need to be stripped of quotes. read-list-with does
         ;; this by default; in the single value case, use string-trim
         (read-val (if list-sep
                       (ical:read-list-with one-val-reader raw-val
                                            value-regex list-sep)
                     (funcall one-val-reader
                              (string-trim raw-val "\"" "\"")))))
    (ical:make-ast-node type
                        (list :value read-val
                              :original-value unrecognized-val))))