Function: icalendar-make-property
icalendar-make-property is a macro defined in icalendar-ast.el.gz.
Signature
(icalendar-make-property TYPE VALUE &rest PARAM-TEMPLATES)
Documentation
Construct an iCalendar property node of TYPE with value VALUE.
TYPE should be an iCalendar type symbol satisfying
icalendar-property-type-symbol-p; it should not be quoted.
VALUE should evaluate to a value appropriate for TYPE. In particular,
if TYPE expects a list of values (see
icalendar-expects-list-of-values-p), VALUE should be such a list. If
necessary, the value(s) in VALUE will be wrapped in syntax nodes
indicating their type. If VALUE is not of the default value type for
TYPE, an icalendar-valuetypeparam will automatically be added to
PARAM-TEMPLATES.
Each element of PARAM-TEMPLATES should represent a parameter node; see
icalendar-make-node-from-templates for the format of such templates.
A template can also have the form (@ L), where L evaluates to a list of
parameter nodes to be added to the component.
PARAM-TEMPLATES which evaluate to nil are removed when the property node is constructed.
For example,
(icalendar-make-property icalendar-rdate (list '(2 1 2025) '(3 1 2025)))
will return an icalendar-rdate node whose value is a list of
icalendar-date nodes containing the dates above as their values.
The resulting syntax node is checked for validity by
icalendar-ast-node-valid-p before it is returned.
Source Code
;; Defined in /usr/src/emacs/lisp/calendar/icalendar-ast.el.gz
(defmacro ical:make-property (type value &rest param-templates)
"Construct an iCalendar property node of TYPE with value VALUE.
TYPE should be an iCalendar type symbol satisfying
`icalendar-property-type-symbol-p'; it should not be quoted.
VALUE should evaluate to a value appropriate for TYPE. In particular,
if TYPE expects a list of values (see
`icalendar-expects-list-of-values-p'), VALUE should be such a list. If
necessary, the value(s) in VALUE will be wrapped in syntax nodes
indicating their type. If VALUE is not of the default value type for
TYPE, an `icalendar-valuetypeparam' will automatically be added to
PARAM-TEMPLATES.
Each element of PARAM-TEMPLATES should represent a parameter node; see
`icalendar-make-node-from-templates' for the format of such templates.
A template can also have the form (@ L), where L evaluates to a list of
parameter nodes to be added to the component.
PARAM-TEMPLATES which evaluate to nil are removed when the property node
is constructed.
For example,
(icalendar-make-property icalendar-rdate (list \\='(2 1 2025) \\='(3 1 2025)))
will return an `icalendar-rdate' node whose value is a list of
`icalendar-date' nodes containing the dates above as their values.
The resulting syntax node is checked for validity by
`icalendar-ast-node-valid-p' before it is returned."
;; TODO: support `ical:other-property', maybe like
;; (ical:other-property "X-NAME" value ...)
(declare (debug (symbolp form &rest form))
(indent 2))
(unless (ical:property-type-symbol-p type)
(error "Not an iCalendar property type: %s" type))
(let ((value-types (cons (get type 'ical:default-type)
(get type 'ical:other-types)))
params-expr children lists-of-children)
(dolist (c param-templates)
(cond ((and (listp c) (ical:type-symbol-p (car c)))
;; c is a template for a child node, so it should be
;; recursively expanded:
(push (cons 'ical:make-node-from-templates c)
children))
((and (listp c) (eq '@ (car c)))
;; c is a template (@ L) where L evaluates to a list of children:
(push (cadr c) lists-of-children))
(t
;; otherwise, just pass c through as is; this allows
;; interleaving templates with other expressions that
;; evaluate to syntax nodes:
(push c children))))
(when (or children lists-of-children)
(setq params-expr
`(seq-filter #'identity
(append (list ,@children) ,@lists-of-children))))
(if (ical:expects-list-of-values-p type)
`(ical:-make-property--list ',type ',value-types ,value ,params-expr)
`(ical:-make-property--nonlist ',type ',value-types ,value ,params-expr))))