Function: icalendar-fix-missing-mailtos
icalendar-fix-missing-mailtos is a byte-compiled function defined in
icalendar-parser.el.gz.
Signature
(icalendar-fix-missing-mailtos)
Documentation
Insert "mailto:" when it is missing before email addresses.
This function is intended to be used from icalendar-pre-parsing-hook,
which see.
Source Code
;; Defined in /usr/src/emacs/lisp/calendar/icalendar-parser.el.gz
(defun ical:fix-missing-mailtos ()
"Insert \"mailto:\" when it is missing before email addresses.
This function is intended to be used from `icalendar-pre-parsing-hook',
which see."
;; fix property values in properties that require an address:
(goto-char (point-min))
(while (re-search-forward
(rx line-start (or "ORGANIZER" "ATTENDEE")
(zero-or-more ical:other-param-safe) ":")
nil t)
(unless (looking-at-p (rx ical:cal-address))
(when (looking-at
(rx
;; match local part of mail address: all the characters
;; allowed after a URI scheme, *except*
;; ?@ (so we can match that after) and
;; ?: (in case we're looking at a non-"mailto:" scheme)
(group-n 1
(one-or-more
(any "A-Za-z0-9" ?- ?. ?_ ?~ ?/ ?? ?# ?\[ ?\] ?! ?$ ?& ?'
?\( ?\) ?* ?+ ?, ?\; ?= ?%)))
"@"))
(when (or (< (length (match-string 0)) 7)
(not (equal "mailto:"
(substring (downcase (match-string 0)) 0 7))))
(replace-match "mailto:\\1" nil nil nil 1)))))
;; fix parameter values in parameters that require an address:
(goto-char (point-min))
(while (re-search-forward
(rx line-start ical:name
(zero-or-more icalendar-other-param-safe)
";"
(or "DELEGATED-FROM" "DELEGATED-TO" "MEMBER" "SENT-BY")
"=")
nil t)
(unless (looking-at-p (rx ical:cal-address))
(while ; DELEGATED* params accept lists
(looking-at
(rx
?\" ; values of these params must always be quoted
(group-n 1 ; matches local part of mail address as above
(one-or-more
(any "A-Za-z0-9" ?- ?. ?_ ?~ ?/ ?? ?# ?\[ ?\] ?! ?$ ?& ?'
?\( ?\) ?* ?+ ?, ?= ?%)))
"@"
(zero-or-more (not ?\"))
?\"
(zero-or-one ",")))
(when (or (< (length (match-string 1)) 7)
(not (equal "mailto:"
(substring (downcase (match-string 1)) 0 7))))
(replace-match "mailto:\\1" nil nil nil 1))
(goto-char (match-end 0))))))