1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-24 10:38:38 +00:00

Ulf Jasper <ulf.jasper at web.de>

(icalendar-version): Increase to "0.17".
(icalendar-import-format): Doc fix.  Allow function type.
(icalendar--read-element): Doc fix.
(icalendar--parse-summary-and-rest): Doc fix.  Handle function
type icalendar-import-format.  Make regexps non-greedy.
(icalendar--format-ical-event): Handle function type
icalendar-import-format.
(icalendar-import-format-sample): New function.
This commit is contained in:
Glenn Morris 2008-01-26 20:20:20 +00:00
parent 832ffa7c8e
commit b3360383c8
2 changed files with 133 additions and 91 deletions

View File

@ -1,3 +1,14 @@
2008-01-20 Ulf Jasper <ulf.jasper@web.de>
* icalendar.el (icalendar-version): Increase to "0.17".
(icalendar-import-format): Doc fix. Allow function type.
(icalendar--read-element): Doc fix.
(icalendar--parse-summary-and-rest): Doc fix. Handle function
type icalendar-import-format. Make regexps non-greedy.
(icalendar--format-ical-event): Handle function type
icalendar-import-format.
(icalendar-import-format-sample): New function.
2008-01-26 Thien-Thi Nguyen <ttn@gnuvola.org>
* vc.el (vc-exec-after): For mode-line-process highlighting, if

View File

@ -105,7 +105,7 @@
;;; Code:
(defconst icalendar-version "0.16"
(defconst icalendar-version "0.17"
"Version number of icalendar.el.")
;; ======================================================================
@ -118,17 +118,25 @@
(defcustom icalendar-import-format
"%s%d%l%o"
"Format string for importing events from iCalendar into Emacs diary.
This string defines how iCalendar events are inserted into diary
file. Meaning of the specifiers:
"Format for importing events from iCalendar into Emacs diary.
It defines how iCalendar events are inserted into diary file.
This may either be a string or a function.
In case of a formatting STRING the following specifiers can be used:
%c Class, see `icalendar-import-format-class'
%d Description, see `icalendar-import-format-description'
%l Location, see `icalendar-import-format-location'
%o Organizer, see `icalendar-import-format-organizer'
%s Summary, see `icalendar-import-format-summary'
%t Status, see `icalendar-import-format-status'
%u URL, see `icalendar-import-format-url'"
:type 'string
%u URL, see `icalendar-import-format-url'
A formatting FUNCTION will be called with a VEVENT as its only
argument. It must return a string. See
`icalendar-import-format-sample' for an example."
:type '(choice
(string :tag "String")
(function :tag "Function"))
:group 'icalendar)
(defcustom icalendar-import-format-summary
@ -247,7 +255,7 @@ Pass arguments REGEXP REP STRING FIXEDCASE LITERAL to
INVALUE gives the current iCalendar element we are reading.
INPARAMS gives the current parameters.....
This function calls itself recursively for each nested calendar element
it finds"
it finds."
(let (element children line name params param param-name param-value
value
(continue t))
@ -923,8 +931,13 @@ entries. ENTRY-MAIN is the first line of the diary entry."
(error "Could not parse entry")))
(defun icalendar--parse-summary-and-rest (summary-and-rest)
"Parse SUMMARY-AND-REST from a diary to fill iCalendar properties."
"Parse SUMMARY-AND-REST from a diary to fill iCalendar properties.
Returns an alist."
(save-match-data
(if (functionp icalendar-import-format)
;; can't do anything
nil
;; split summary-and-rest
(let* ((s icalendar-import-format)
(p-cla (or (string-match "%c" icalendar-import-format) -1))
(p-des (or (string-match "%d" icalendar-import-format) -1))
@ -955,20 +968,21 @@ entries. ENTRY-MAIN is the first line of the diary entry."
(list
;; summary must be first! because of %s
(list "%s"
(concat "\\(" icalendar-import-format-summary "\\)?"))
(concat "\\(" icalendar-import-format-summary "\\)??"))
(list "%c"
(concat "\\(" icalendar-import-format-class "\\)?"))
(concat "\\(" icalendar-import-format-class "\\)??"))
(list "%d"
(concat "\\(" icalendar-import-format-description "\\)?"))
(concat "\\(" icalendar-import-format-description "\\)??"))
(list "%l"
(concat "\\(" icalendar-import-format-location "\\)?"))
(concat "\\(" icalendar-import-format-location "\\)??"))
(list "%o"
(concat "\\(" icalendar-import-format-organizer "\\)?"))
(concat "\\(" icalendar-import-format-organizer "\\)??"))
(list "%t"
(concat "\\(" icalendar-import-format-status "\\)?"))
(concat "\\(" icalendar-import-format-status "\\)??"))
(list "%u"
(concat "\\(" icalendar-import-format-url "\\)?"))))
(setq s (concat (icalendar--rris "%s" "\\(.*\\)" s nil t) " "))
(concat "\\(" icalendar-import-format-url "\\)??"))))
(setq s (concat "^" (icalendar--rris "%s" "\\(.*?\\)" s nil t)
" $"))
(if (string-match s summary-and-rest)
(let (cla des loc org sta sum url)
(if (and pos-sum (match-beginning pos-sum))
@ -1005,7 +1019,7 @@ entries. ENTRY-MAIN is the first line of the diary entry."
(if org (cons 'org org) nil)
(if sta (cons 'sta sta) nil)
;;(if sum (cons 'sum sum) nil)
(if url (cons 'url url) nil)))))))
(if url (cons 'url url) nil))))))))
;; subroutines for icalendar-export-region
(defun icalendar--convert-ordinary-to-ical (nonmarker entry-main)
@ -1600,6 +1614,8 @@ buffer `*icalendar-errors*'."
(defun icalendar--format-ical-event (event)
"Create a string representation of an iCalendar EVENT."
(if (functionp icalendar-import-format)
(funcall icalendar-import-format event)
(let ((string icalendar-import-format)
(conversion-list
'(("%c" CLASS icalendar-import-format-class)
@ -1628,7 +1644,7 @@ buffer `*icalendar-errors*'."
string
t t))))
conversion-list)
string))
string)))
(defun icalendar--convert-ical-to-diary (ical-list diary-file
&optional do-not-ask
@ -2044,6 +2060,21 @@ the entry."
;; return diary-file in case it has been changed interactively
diary-file)
;; ======================================================================
;; Examples
;; ======================================================================
(defun icalendar-import-format-sample (event)
"Example function for formatting an icalendar EVENT."
(format (concat "SUMMARY=`%s' DESCRIPTION=`%s' LOCATION=`%s' ORGANIZER=`%s' "
"STATUS=`%s' URL=`%s' CLASS=`%s'")
(or (icalendar--get-event-property event 'SUMMARY) "")
(or (icalendar--get-event-property event 'DESCRIPTION) "")
(or (icalendar--get-event-property event 'LOCATION) "")
(or (icalendar--get-event-property event 'ORGANIZER) "")
(or (icalendar--get-event-property event 'STATUS) "")
(or (icalendar--get-event-property event 'URL) "")
(or (icalendar--get-event-property event 'CLASS) "")))
(provide 'icalendar)
;; arch-tag: 74fdbe8e-0451-4e38-bb61-4416e822f4fc