Function: icalendar-parse-property
icalendar-parse-property is a byte-compiled function defined in
icalendar-parser.el.gz.
Signature
(icalendar-parse-property LIMIT)
Documentation
Parse the current property, up to LIMIT.
Point should be at the beginning of a property line; LIMIT should be the position at the end of the line.
Returns a syntax node for the property. After parsing, point is at the beginning of the next content line.
Source Code
;; Defined in /usr/src/emacs/lisp/calendar/icalendar-parser.el.gz
(defun ical:parse-property (limit)
"Parse the current property, up to LIMIT.
Point should be at the beginning of a property line; LIMIT should be the
position at the end of the line.
Returns a syntax node for the property. After parsing, point is at the
beginning of the next content line."
(rx-let ((ical:property-start (seq line-start (group-n 1 ical:name))))
(let (line-begin line-end property-name property-type params node)
;; Property name
(unless (re-search-forward (rx ical:property-start) limit t)
(ical:signal-parse-error
"Malformed property: could not match property name"
:restart-at (1+ limit)))
(setq property-name (match-string 1))
(setq line-begin (line-beginning-position))
(setq line-end (line-end-position))
;; Parameters
(when (looking-at-p ";")
(setq params (ical:parse-params line-end)))
(unless (looking-at-p ":")
(ical:signal-parse-error
"Malformed property: parameters did not end at colon"
:restart-at (1+ limit)))
(forward-char)
;; Value
(setq property-type (alist-get (upcase property-name)
ical:property-types
'ical:other-property
nil #'equal))
(setq node (ical:parse-property-value property-type limit params))
;; sanity check, since e.g. invalid base64 data might not
;; match all the way to the end of the line, as test
;; rfc5545-sec3.1.3/2 initially revealed
(unless (eql (point) (line-end-position))
(ical:signal-parse-error
(format "%s property value did not consume line: %s"
property-name
(ical:default-value-printer (ical:ast-node-value node)))
:restart-at (1+ limit)))
;; value, children are set in ical:read-property-value,
;; value-begin, value-end, end in ical:parse-property-value.
;; begin and original-name are only available here:
(ical:ast-node-meta-set node :begin line-begin)
(when (eq property-type 'ical:other-property)
(ical:ast-node-meta-set node :original-name property-name))
;; Set point up for the next property parser.
(while (not (bolp))
(forward-char))
;; Return the syntax node
node)))