Now on revision 105326. ------------------------------------------------------------ revno: 105326 committer: Michael Albinus branch nick: trunk timestamp: Wed 2011-07-27 13:22:22 +0200 message: * net/tramp-sh.el (tramp-maybe-send-script): Don't let-bind the connection process, it could be nil. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-07-27 03:44:45 +0000 +++ lisp/ChangeLog 2011-07-27 11:22:22 +0000 @@ -1,3 +1,8 @@ +2011-07-27 Michael Albinus + + * net/tramp-sh.el (tramp-maybe-send-script): Don't let-bind the + connection process, it could be nil. + 2011-07-27 Leo Liu Simplify url handling in rcirc-mode. === modified file 'lisp/net/tramp-sh.el' --- lisp/net/tramp-sh.el 2011-07-24 09:56:26 +0000 +++ lisp/net/tramp-sh.el 2011-07-27 11:22:22 +0000 @@ -3457,8 +3457,10 @@ (defun tramp-maybe-send-script (vec script name) "Define in remote shell function NAME implemented as SCRIPT. Only send the definition if it has not already been done." - (let* ((p (tramp-get-connection-process vec)) - (scripts (tramp-get-connection-property p "scripts" nil))) + ;; We cannot let-bind (tramp-get-connection-process vec) because it + ;; might be nil. + (let ((scripts (tramp-get-connection-property + (tramp-get-connection-process vec) "scripts" nil))) (unless (member name scripts) (tramp-with-progress-reporter vec 5 (format "Sending script `%s'" name) ;; The script could contain a call of Perl. This is masked with `%s'. @@ -3467,7 +3469,8 @@ (format "%s () {\n%s\n}" name (format script (tramp-get-remote-perl vec))) "Script %s sending failed" name) - (tramp-set-connection-property p "scripts" (cons name scripts)))))) + (tramp-set-connection-property + (tramp-get-connection-process vec) "scripts" (cons name scripts)))))) (defun tramp-set-auto-save () (when (and ;; ange-ftp has its own auto-save mechanism ------------------------------------------------------------ revno: 105325 committer: Leo Liu branch nick: trunk timestamp: Wed 2011-07-27 11:44:45 +0800 message: Simplify url handling in rcirc-mode diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-07-26 19:18:40 +0000 +++ lisp/ChangeLog 2011-07-27 03:44:45 +0000 @@ -1,3 +1,11 @@ +2011-07-27 Leo Liu + + Simplify url handling in rcirc-mode. + + * net/rcirc.el (rcirc-browse-url-map, rcirc-browse-url-at-point) + (rcirc-browse-url-at-mouse): Remove. + * net/rcirc.el (rcirc-markup-urls): Use `make-button'. + 2011-07-26 Alan Mackenzie Fontify bitfield declarations properly. === modified file 'lisp/net/rcirc.el' --- lisp/net/rcirc.el 2011-06-20 12:55:24 +0000 +++ lisp/net/rcirc.el 2011-07-27 03:44:45 +0000 @@ -935,14 +935,6 @@ map) "Keymap for rcirc mode.") -(defvar rcirc-browse-url-map - (let ((map (make-sparse-keymap))) - (define-key map (kbd "RET") 'rcirc-browse-url-at-point) - (define-key map (kbd "") 'rcirc-browse-url-at-mouse) - (define-key map [follow-link] 'mouse-face) - map) - "Keymap used for browsing URLs in `rcirc-mode'.") - (defvar rcirc-short-buffer-name nil "Generated abbreviation to use to indicate buffer activity.") @@ -2351,21 +2343,6 @@ (browse-url (completing-read "rcirc browse-url: " completions nil nil initial-input 'history) arg))) - -(defun rcirc-browse-url-at-point (point) - "Send URL at point to `browse-url'." - (interactive "d") - (let ((beg (previous-single-property-change (1+ point) 'mouse-face)) - (end (next-single-property-change point 'mouse-face))) - (browse-url (buffer-substring-no-properties beg end)))) - -(defun rcirc-browse-url-at-mouse (event) - "Send URL at mouse click to `browse-url'." - (interactive "e") - (let ((position (event-end event))) - (with-current-buffer (window-buffer (posn-window position)) - (rcirc-browse-url-at-point (posn-point position))))) - (defun rcirc-markup-timestamp (sender response) (goto-char (point-min)) @@ -2406,12 +2383,16 @@ (while (and rcirc-url-regexp ;; nil means disable URL catching (re-search-forward rcirc-url-regexp nil t)) (let ((start (match-beginning 0)) - (end (match-end 0))) - (rcirc-add-face start end 'rcirc-url) - (add-text-properties start end (list 'mouse-face 'highlight - 'keymap rcirc-browse-url-map)) + (end (match-end 0)) + (url (match-string-no-properties 0))) + (make-button start end + 'face 'rcirc-url + 'follow-link t + 'rcirc-url url + 'action (lambda (button) + (browse-url (button-get button 'rcirc-url)))) ;; record the url - (push (buffer-substring-no-properties start end) rcirc-urls)))) + (push url rcirc-urls)))) (defun rcirc-markup-keywords (sender response) (when (and (string= response "PRIVMSG") ------------------------------------------------------------ revno: 105324 [merge] committer: Alan Mackenzie branch nick: trunk timestamp: Tue 2011-07-26 19:27:17 +0000 message: Fontify bitfield declarations properly. cc-langs.el (c-has-bitfields): New lang variable. (c-symbol-chars): Now exported as a lang variable. (c-not-primitive-type-keywords): New lang variable. cc-fonts.el (c-font-lock-declarations): Jump over the QT keyword "more" to prevent "more slots: ...." being spuriously parsed as a bitfield declaraion. cc-engine.el (c-beginning-of-statement-1): Refactor and enhance to handle bitfield declarations. (c-punctuation-in): New function. (c-forward-decl-or-cast-1): Enhance CASE 3 to handle bitfield declarations properly. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-07-26 15:36:04 +0000 +++ lisp/ChangeLog 2011-07-26 19:18:40 +0000 @@ -1,3 +1,21 @@ +2011-07-26 Alan Mackenzie + + Fontify bitfield declarations properly. + + * progmodes/cc-langs.el (c-has-bitfields): New lang variable. + (c-symbol-chars): Now exported as a lang variable. + (c-not-primitive-type-keywords): New lang variable. + + * progmodes/cc-fonts.el (c-font-lock-declarations): Jump over the + QT keyword "more" to prevent "more slots: ...." being spuriously + parsed as a bitfield declaraion. + + * progmodes/cc-engine.el (c-beginning-of-statement-1): Refactor + and enhance to handle bitfield declarations. + (c-punctuation-in): New function. + (c-forward-decl-or-cast-1): Enhance CASE 3 to handle bitfield + declarations properly. + 2011-07-26 Ulf Jasper * calendar/icalendar.el (icalendar--all-events): Take care of === modified file 'lisp/progmodes/cc-engine.el' --- lisp/progmodes/cc-engine.el 2011-07-18 17:15:24 +0000 +++ lisp/progmodes/cc-engine.el 2011-07-26 19:18:40 +0000 @@ -709,6 +709,9 @@ ;; content was found in the label. Note that we might still ;; regard it a label if it starts with `c-label-kwds'. label-good-pos + ;; Putative positions of the components of a bitfield declaration, + ;; e.g. "int foo : NUM_FOO_BITS ;" + bitfield-type-pos bitfield-id-pos bitfield-size-pos ;; Symbol just scanned back over (e.g. 'while or 'boundary). ;; See above. sym @@ -765,13 +768,22 @@ ;; Record this as the first token if not starting inside it. (setq tok start)) - ;; The following while loop goes back one sexp (balanced parens, - ;; etc. with contents, or symbol or suchlike) each iteration. This - ;; movement is accomplished with a call to scan-sexps approx 130 lines - ;; below. + + ;; The following while loop goes back one sexp (balanced parens, + ;; etc. with contents, or symbol or suchlike) each iteration. This + ;; movement is accomplished with a call to c-backward-sexp approx 170 + ;; lines below. + ;; + ;; The loop is exited only by throwing nil to the (catch 'loop ...): + ;; 1. On reaching the start of a macro; + ;; 2. On having passed a stmt boundary with the PDA stack empty; + ;; 3. On reaching the start of an Objective C method def; + ;; 4. From macro `c-bos-pop-state'; when the stack is empty; + ;; 5. From macro `c-bos-pop-state-and-retry' when the stack is empty. (while (catch 'loop ;; Throw nil to break, non-nil to continue. (cond + ;; Are we in a macro, just after the opening #? ((save-excursion (and macro-start ; Always NIL for AWK. (progn (skip-chars-backward " \t") @@ -792,7 +804,7 @@ (setq pos saved ret 'macro ignore-labels t)) - (throw 'loop nil)) + (throw 'loop nil)) ; 1. Start of macro. ;; Do a round through the automaton if we've just passed a ;; statement boundary or passed a "while"-like token. @@ -801,7 +813,7 @@ (setq sym (intern (match-string 1))))) (when (and (< pos start) (null stack)) - (throw 'loop nil)) + (throw 'loop nil)) ; 2. Statement boundary. ;; The PDA state handling. ;; @@ -918,19 +930,14 @@ ;; HERE IS THE SINGLE PLACE INSIDE THE PDA LOOP WHERE WE MOVE ;; BACKWARDS THROUGH THE SOURCE. - ;; This is typically fast with the caching done by - ;; c-(backward|forward)-sws. (c-backward-syntactic-ws) - (let ((before-sws-pos (point)) - ;; Set as long as we have to continue jumping by sexps. - ;; It's the position to use as end in the next round. - sexp-loop-continue-pos ;; The end position of the area to search for statement ;; barriers in this round. - (sexp-loop-end-pos pos)) + (maybe-after-boundary-pos pos)) - ;; The following while goes back one sexp per iteration. + ;; Go back over exactly one logical sexp, taking proper + ;; account of macros and escaped EOLs. (while (progn (unless (c-safe (c-backward-sexp) t) @@ -938,81 +945,87 @@ ;; stack won't be empty the code below will report a ;; suitable error. (throw 'loop nil)) - - ;; Check if the sexp movement crossed a statement or - ;; declaration boundary. But first modify the point - ;; so that `c-crosses-statement-barrier-p' only looks - ;; at the non-sexp chars following the sexp. - (save-excursion - (when (setq - boundary-pos - (cond - ((if macro-start - nil - (save-excursion - (when (c-beginning-of-macro) - ;; Set continuation position in case - ;; `c-crosses-statement-barrier-p' - ;; doesn't detect anything below. - (setq sexp-loop-continue-pos (point))))) - ;; If the sexp movement took us into a - ;; macro then there were only some non-sexp - ;; chars after it. Skip out of the macro - ;; to analyze them but not the non-sexp - ;; chars that might be inside the macro. - (c-end-of-macro) - (c-crosses-statement-barrier-p - (point) sexp-loop-end-pos)) - - ((and - (eq (char-after) ?{) - (not (c-looking-at-inexpr-block lim nil t))) - ;; Passed a block sexp. That's a boundary - ;; alright. - (point)) - - ((looking-at "\\s\(") - ;; Passed some other paren. Only analyze - ;; the non-sexp chars after it. - (goto-char (1+ (c-down-list-backward - before-sws-pos))) - ;; We're at a valid token start position - ;; (outside the `save-excursion') if - ;; `c-crosses-statement-barrier-p' failed. - (c-crosses-statement-barrier-p - (point) sexp-loop-end-pos)) - - (t - ;; Passed a symbol sexp or line - ;; continuation. It doesn't matter that - ;; it's included in the analyzed region. - (if (c-crosses-statement-barrier-p - (point) sexp-loop-end-pos) - t - ;; If it was a line continuation then we - ;; have to continue looping. - (if (looking-at "\\\\$") - (setq sexp-loop-continue-pos (point))) - nil)))) - - (setq pptok ptok - ptok tok - tok boundary-pos - sym 'boundary) - ;; Like a C "continue". Analyze the next sexp. - (throw 'loop t))) - - sexp-loop-continue-pos) ; End of "go back a sexp" loop condition. - (goto-char sexp-loop-continue-pos) - (setq sexp-loop-end-pos sexp-loop-continue-pos - sexp-loop-continue-pos nil)))) + (cond + ;; Have we moved into a macro? + ((and (not macro-start) + (c-beginning-of-macro)) + ;; Have we crossed a statement boundary? If not, + ;; keep going back until we find one or a "real" sexp. + (and + (save-excursion + (c-end-of-macro) + (not (c-crosses-statement-barrier-p + (point) maybe-after-boundary-pos))) + (setq maybe-after-boundary-pos (point)))) + ;; Have we just gone back over an escaped NL? This + ;; doesn't count as a sexp. + ((looking-at "\\\\$"))))) + + ;; Have we crossed a statement boundary? + (setq boundary-pos + (cond + ;; Are we at a macro beginning? + ((and (not macro-start) + c-opt-cpp-prefix + (looking-at c-opt-cpp-prefix)) + (save-excursion + (c-end-of-macro) + (c-crosses-statement-barrier-p + (point) maybe-after-boundary-pos))) + ;; Just gone back over a brace block? + ((and + (eq (char-after) ?{) + (not (c-looking-at-inexpr-block lim nil t))) + (save-excursion + (c-forward-sexp) (point))) + ;; Just gone back over some paren block? + ((looking-at "\\s\(") + (save-excursion + (goto-char (1+ (c-down-list-backward + before-sws-pos))) + (c-crosses-statement-barrier-p + (point) maybe-after-boundary-pos))) + ;; Just gone back over an ordinary symbol of some sort? + (t (c-crosses-statement-barrier-p + (point) maybe-after-boundary-pos)))) + + (when boundary-pos + (setq pptok ptok + ptok tok + tok boundary-pos + sym 'boundary) + ;; Like a C "continue". Analyze the next sexp. + (throw 'loop t)))) ;; ObjC method def? (when (and c-opt-method-key (setq saved (c-in-method-def-p))) (setq pos saved ignore-labels t) ; Avoid the label check on exit. - (throw 'loop nil)) + (throw 'loop nil)) ; 3. ObjC method def. + + ;; Might we have a bitfield declaration, " : "? + (if c-has-bitfields + (cond + ;; The : and fields? + ((and (numberp c-maybe-labelp) + (not bitfield-size-pos) + (save-excursion + (goto-char (or tok start)) + (not (looking-at c-keywords-regexp))) + (not (looking-at c-keywords-regexp)) + (not (c-punctuation-in (point) c-maybe-labelp))) + (setq bitfield-size-pos (or tok start) + bitfield-id-pos (point))) + ;; The field? + ((and bitfield-id-pos + (not bitfield-type-pos)) + (if (and (looking-at c-symbol-key) ; Can only be an integer type. :-) + (not (looking-at c-not-primitive-type-keywords-regexp)) + (not (c-punctuation-in (point) tok))) + (setq bitfield-type-pos (point)) + (setq bitfield-size-pos nil + bitfield-id-pos nil))))) ;; Handle labels. (unless (eq ignore-labels t) @@ -1044,8 +1057,10 @@ pptok ptok ptok tok tok (point) - pos tok))) ; Not nil (for the while loop). - + pos tok) ; always non-nil + ) ; end of (catch loop ....) + ) ; end of sexp-at-a-time (while ....) + ;; If the stack isn't empty there might be errors to report. (while stack (if (and (vectorp saved-pos) (eq (length saved-pos) 3)) @@ -1067,6 +1082,7 @@ (eq c-maybe-labelp t) (not (eq ret 'beginning)) after-labels-pos + (not bitfield-type-pos) ; Bitfields take precedence over labels. (or (not label-good-pos) (<= label-good-pos pos) (progn @@ -1104,6 +1120,19 @@ (goto-char pos) ret))) +(defun c-punctuation-in (from to) + "Return non-nil if there is a non-comment non-macro punctuation character +between FROM and TO. FROM must not be in a string or comment. The returned +value is the position of the first such character." + (save-excursion + (goto-char from) + (let ((pos (point))) + (while (progn (skip-chars-forward c-symbol-chars to) + (c-forward-syntactic-ws to) + (> (point) pos)) + (setq pos (point)))) + (and (< (point) to) (point)))) + (defun c-crosses-statement-barrier-p (from to) "Return non-nil if buffer positions FROM to TO cross one or more statement or declaration boundaries. The returned value is actually @@ -6618,19 +6647,27 @@ (if backup-at-type (progn - ;; CASE 3 - (when (= (point) start) - ;; Got a plain list of identifiers. If a colon follows it's - ;; a valid label. Otherwise the last one probably is the - ;; declared identifier and we should back up to the previous - ;; type, providing it isn't a cast. + + ;; CASE 3 + (when (= (point) start) + ;; Got a plain list of identifiers. If a colon follows it's + ;; a valid label, or maybe a bitfield. Otherwise the last + ;; one probably is the declared identifier and we should + ;; back up to the previous type, providing it isn't a cast. (if (and (eq (char-after) ?:) (not (c-major-mode-is 'java-mode))) - ;; If we've found a specifier keyword then it's a - ;; declaration regardless. - (throw 'at-decl-or-cast (eq at-decl-or-cast t)) - (setq backup-if-not-cast t) - (throw 'at-decl-or-cast t))) + (cond + ;; If we've found a specifier keyword then it's a + ;; declaration regardless. + ((eq at-decl-or-cast t) + (throw 'at-decl-or-cast t)) + ((and c-has-bitfields + (eq at-decl-or-cast 'ids)) ; bitfield. + (setq backup-if-not-cast t) + (throw 'at-decl-or-cast t))) + + (setq backup-if-not-cast t) + (throw 'at-decl-or-cast t))) ;; CASE 4 (when (and got-suffix === modified file 'lisp/progmodes/cc-fonts.el' --- lisp/progmodes/cc-fonts.el 2011-07-18 17:15:24 +0000 +++ lisp/progmodes/cc-fonts.el 2011-07-26 19:18:40 +0000 @@ -1179,6 +1179,14 @@ (goto-char start-pos))) ;; Now analyze the construct. + ;; In QT, "more" is an irritating keyword that expands to nothing. + ;; We skip over it to prevent recognition of "more slots: " + ;; as a bitfield declaration. + (when (and (c-major-mode-is 'c++-mode) + (looking-at + (concat "\\(more\\)\\([^" c-symbol-chars "]\\|$\\)"))) + (goto-char (match-end 1)) + (c-forward-syntactic-ws)) (setq decl-or-cast (c-forward-decl-or-cast-1 match-pos context last-cast-end)) === modified file 'lisp/progmodes/cc-langs.el' --- lisp/progmodes/cc-langs.el 2011-07-22 12:53:46 +0000 +++ lisp/progmodes/cc-langs.el 2011-07-26 19:18:40 +0000 @@ -511,6 +511,12 @@ ;;; Lexer-level syntax (identifiers, tokens etc). +(c-lang-defconst c-has-bitfields + "Whether the language has bitfield declarations." + t nil + (c c++ objc) t) +(c-lang-defvar c-has-bitfields (c-lang-const c-has-bitfields)) + (c-lang-defconst c-symbol-start "Regexp that matches the start of a symbol, i.e. any identifier or keyword. It's unspecified how far it matches. Does not contain a \\| @@ -528,6 +534,7 @@ ;; operator chars too, but they are handled with other means instead. t (concat c-alnum "_$") objc (concat c-alnum "_$@")) +(c-lang-defvar c-symbol-chars (c-lang-const c-symbol-chars)) (c-lang-defconst c-symbol-key "Regexp matching identifiers and keywords (with submatch 0). Assumed @@ -1927,6 +1934,21 @@ (c-lang-defvar c-not-decl-init-keywords (c-lang-const c-not-decl-init-keywords)) +(c-lang-defconst c-not-primitive-type-keywords + "List of all keywords apart from primitive types (like \"int\")." + t (set-difference (c-lang-const c-keywords) + (c-lang-const c-primitive-type-kwds) + :test 'string-equal) + ;; The "more" for C++ is the QT keyword (as in "more slots:"). + ;; This variable is intended for use in c-beginning-of-statement-1. + c++ (append (c-lang-const c-not-primitive-type-keywords) '("more"))) + +(c-lang-defconst c-not-primitive-type-keywords-regexp + t (c-make-keywords-re t + (c-lang-const c-not-primitive-type-keywords))) +(c-lang-defvar c-not-primitive-type-keywords-regexp + (c-lang-const c-not-primitive-type-keywords-regexp)) + (c-lang-defconst c-protection-kwds "Access protection label keywords in classes." t nil ------------------------------------------------------------ revno: 105323 committer: Ulf Jasper branch nick: trunk timestamp: Tue 2011-07-26 17:36:04 +0200 message: icalendar: Take care of multiple vcalendars in a single file. lisp/ChangeLog: * calendar/icalendar.el (icalendar--all-events): Take care of multiple vcalendars in a single file. (icalendar--convert-float-to-ical): checkdoc fixes. * automated/icalendar-tests.el (icalendar-tests--compare-strings): Removed, simply use string=. (icalendar--diarytime-to-isotime) (icalendar--datetime-to-diary-date) (icalendar--datestring-to-isodate) (icalendar--format-ical-event) (icalendar--parse-summary-and-rest) (icalendar-tests--do-test-import) (icalendar-tests--do-test-cycle) : Changed argument order of string= to EXPECTED ACTUAL. (icalendar--import-format-sample) (icalendar--format-ical-event) (icalendar-import-non-recurring) (icalendar-import-rrule) (icalendar-import-duration) (icalendar-import-bug-6766) (icalendar-real-world): Adjusted to string= instead of icalendar-tests--compare-strings. (icalendar-import-multiple-vcalendars): New. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-07-25 01:44:10 +0000 +++ lisp/ChangeLog 2011-07-26 15:36:04 +0000 @@ -1,3 +1,9 @@ +2011-07-26 Ulf Jasper + + * calendar/icalendar.el (icalendar--all-events): Take care of + multiple vcalendars in a single file. + (icalendar--convert-float-to-ical): checkdoc fixes. + 2011-07-25 Deniz Dogan * image.el (insert-image): Clarifying docstring. === modified file 'lisp/calendar/icalendar.el' --- lisp/calendar/icalendar.el 2011-04-27 17:48:35 +0000 +++ lisp/calendar/icalendar.el 2011-07-26 15:36:04 +0000 @@ -412,10 +412,15 @@ (setq result subresult))))) result)) - ; private +;; private (defun icalendar--all-events (icalendar) "Return the list of all existing events in the given ICALENDAR." - (icalendar--get-children (car icalendar) 'VEVENT)) + (let ((result '())) + (mapc (lambda (elt) + (setq result (append (icalendar--get-children elt 'VEVENT) + result))) + (nreverse icalendar)) + result)) (defun icalendar--split-value (value-string) "Split VALUE-STRING at ';='." @@ -1571,8 +1576,8 @@ (n (nth 3 sexp)) (day (nth 4 sexp)) (summary - (replace-regexp-in-string - "\\(^\s+\\|\s+$\\)" "" + (replace-regexp-in-string + "\\(^\s+\\|\s+$\\)" "" (buffer-substring (point) (point-max))))) (when day @@ -1590,7 +1595,7 @@ (null (let ((date (calendar-current-date)) (entry entry-main)) (diary-float month dayname n))) - (concat + (concat "\nEXDATE;VALUE=DATE:" (format-time-string "%Y%m%d" (current-time)))) "\nRRULE:" === modified file 'test/ChangeLog' --- test/ChangeLog 2011-05-11 21:34:40 +0000 +++ test/ChangeLog 2011-07-26 15:36:04 +0000 @@ -1,3 +1,25 @@ +2011-07-26 Ulf Jasper + + * automated/icalendar-tests.el (icalendar-tests--compare-strings): + Removed, simply use string=. + (icalendar--diarytime-to-isotime) + (icalendar--datetime-to-diary-date) + (icalendar--datestring-to-isodate) + (icalendar--format-ical-event) + (icalendar--parse-summary-and-rest) + (icalendar-tests--do-test-import) + (icalendar-tests--do-test-cycle) : Changed argument order of + string= to EXPECTED ACTUAL. + (icalendar--import-format-sample) + (icalendar--format-ical-event) + (icalendar-import-non-recurring) + (icalendar-import-rrule) + (icalendar-import-duration) + (icalendar-import-bug-6766) + (icalendar-real-world): Adjusted to string= instead of + icalendar-tests--compare-strings. + (icalendar-import-multiple-vcalendars): New. + 2011-05-11 Teodor Zlatanov * automated/gnus-tests.el: Add wrapper for Gnus tests. === modified file 'test/automated/icalendar-tests.el' --- test/automated/icalendar-tests.el 2011-02-20 14:35:58 +0000 +++ test/automated/icalendar-tests.el 2011-07-26 15:36:04 +0000 @@ -51,35 +51,6 @@ (replace-regexp-in-string "[ \t\n]+\\'" "" (replace-regexp-in-string "\\`[ \t\n]+" "" string))) -(defun icalendar-tests--compare-strings (str1 str2) - "Compare strings STR1 and STR2. -Return t if strings are equal, else return substring indicating first difference. -FIXME: make this a little smarter." - (let* ((s1 (icalendar-tests--trim str1)) - (s2 (icalendar-tests--trim str2)) - (result (compare-strings s1 0 nil s2 0 nil)) - (len (length str2))) - (if (numberp result) - (if (> result 0) - (concat "..." (substring str2 (- result 1) - (min len (+ (- result 1) 3))) "...") - (concat "..." (substring str2 (- (+ result 1)) - (min len (+ (- (+ result 1)) 3))) "...")) - t))) - -(ert-deftest icalendar-tests--compare-strings () - "Test icalendar-tests--compare-strings." - (should (equal t (icalendar-tests--compare-strings " abcde" "abcde "))) - (should - (string= "...def..." - (icalendar-tests--compare-strings "abcxe" "abcdefghijklmn"))) - (should (string= "...xe..." - (icalendar-tests--compare-strings "abcde" "abcxe"))) - (should (string= "...ddd..." - (icalendar-tests--compare-strings "abc" "abcdddddd"))) - (should (string= "......" - (icalendar-tests--compare-strings "abcdefghij" "abc")))) - ;; ====================================================================== ;; Tests of functions ;; ====================================================================== @@ -269,85 +240,85 @@ (ert-deftest icalendar--diarytime-to-isotime () "Test method for `icalendar--diarytime-to-isotime'." - (should (string= (icalendar--diarytime-to-isotime "01:15" "") - "T011500")) - (should (string= (icalendar--diarytime-to-isotime "1:15" "") - "T011500")) - (should (string= (icalendar--diarytime-to-isotime "0:01" "") - "T000100")) - (should (string= (icalendar--diarytime-to-isotime "0100" "") - "T010000")) - (should (string= (icalendar--diarytime-to-isotime "0100" "am") - "T010000")) - (should (string= (icalendar--diarytime-to-isotime "0100" "pm") - "T130000")) - (should (string= (icalendar--diarytime-to-isotime "1200" "") - "T120000")) - (should (string= (icalendar--diarytime-to-isotime "17:17" "") - "T171700")) - (should (string= (icalendar--diarytime-to-isotime "1200" "am") - "T000000")) - (should (string= (icalendar--diarytime-to-isotime "1201" "am") - "T000100")) - (should (string= (icalendar--diarytime-to-isotime "1259" "am") - "T005900")) - (should (string= (icalendar--diarytime-to-isotime "1200" "pm") - "T120000")) - (should (string= (icalendar--diarytime-to-isotime "1201" "pm") - "T120100")) - (should (string= (icalendar--diarytime-to-isotime "1259" "pm") - "T125900"))) + (should (string= "T011500" + (icalendar--diarytime-to-isotime "01:15" ""))) + (should (string= "T011500" + (icalendar--diarytime-to-isotime "1:15" ""))) + (should (string= "T000100" + (icalendar--diarytime-to-isotime "0:01" ""))) + (should (string= "T010000" + (icalendar--diarytime-to-isotime "0100" ""))) + (should (string= "T010000" + (icalendar--diarytime-to-isotime "0100" "am"))) + (should (string= "T130000" + (icalendar--diarytime-to-isotime "0100" "pm"))) + (should (string= "T120000" + (icalendar--diarytime-to-isotime "1200" ""))) + (should (string= "T171700" + (icalendar--diarytime-to-isotime "17:17" ""))) + (should (string= "T000000" + (icalendar--diarytime-to-isotime "1200" "am"))) + (should (string= "T000100" + (icalendar--diarytime-to-isotime "1201" "am"))) + (should (string= "T005900" + (icalendar--diarytime-to-isotime "1259" "am"))) + (should (string= "T120000" + (icalendar--diarytime-to-isotime "1200" "pm"))) + (should (string= "T120100" + (icalendar--diarytime-to-isotime "1201" "pm"))) + (should (string= "T125900" + (icalendar--diarytime-to-isotime "1259" "pm")))) (ert-deftest icalendar--datetime-to-diary-date () "Test method for `icalendar--datetime-to-diary-date'." (let* ((datetime '(59 59 23 31 12 2008)) (calendar-date-style 'iso)) - (should (string= (icalendar--datetime-to-diary-date datetime) - "2008 12 31")) + (should (string= "2008 12 31" + (icalendar--datetime-to-diary-date datetime))) (setq calendar-date-style 'european) - (should (string= (icalendar--datetime-to-diary-date datetime) - "31 12 2008")) + (should (string= "31 12 2008" + (icalendar--datetime-to-diary-date datetime))) (setq calendar-date-style 'american) - (should (string= (icalendar--datetime-to-diary-date datetime) - "12 31 2008")))) + (should (string= "12 31 2008" + (icalendar--datetime-to-diary-date datetime))))) (ert-deftest icalendar--datestring-to-isodate () "Test method for `icalendar--datestring-to-isodate'." (let ((calendar-date-style 'iso)) ;; numeric iso - (should (string= (icalendar--datestring-to-isodate "2008 05 11") - "20080511")) - (should (string= (icalendar--datestring-to-isodate "2008 05 31") - "20080531")) - (should (string= (icalendar--datestring-to-isodate "2008 05 31" 2) - "20080602")) + (should (string= "20080511" + (icalendar--datestring-to-isodate "2008 05 11"))) + (should (string= "20080531" + (icalendar--datestring-to-isodate "2008 05 31"))) + (should (string= "20080602" + (icalendar--datestring-to-isodate "2008 05 31" 2))) ;; numeric european (setq calendar-date-style 'european) - (should (string= (icalendar--datestring-to-isodate "11 05 2008") - "20080511")) - (should (string= (icalendar--datestring-to-isodate "31 05 2008") - "20080531")) - (should (string= (icalendar--datestring-to-isodate "31 05 2008" 2) - "20080602")) + (should (string= "20080511" + (icalendar--datestring-to-isodate "11 05 2008"))) + (should (string= "20080531" + (icalendar--datestring-to-isodate "31 05 2008"))) + (should (string= "20080602" + (icalendar--datestring-to-isodate "31 05 2008" 2))) ;; numeric american (setq calendar-date-style 'american) - (should (string= (icalendar--datestring-to-isodate "11 05 2008") - "20081105")) - (should (string= (icalendar--datestring-to-isodate "12 30 2008") - "20081230")) - (should (string= (icalendar--datestring-to-isodate "12 30 2008" 2) - "20090101")) + (should (string= "20081105" + (icalendar--datestring-to-isodate "11 05 2008"))) + (should (string= "20081230" + (icalendar--datestring-to-isodate "12 30 2008"))) + (should (string= "20090101" + (icalendar--datestring-to-isodate "12 30 2008" 2))) ;; non-numeric (setq calendar-date-style nil) ;not necessary for conversion - (should (string= (icalendar--datestring-to-isodate "Nov 05 2008") - "20081105")) - (should (string= (icalendar--datestring-to-isodate "05 Nov 2008") - "20081105")) - (should (string= (icalendar--datestring-to-isodate "2008 Nov 05") - "20081105")))) + (should (string= "20081105" + (icalendar--datestring-to-isodate "Nov 05 2008"))) + (should (string= "20081105" + (icalendar--datestring-to-isodate "05 Nov 2008"))) + (should (string= "20081105" + (icalendar--datestring-to-isodate "2008 Nov 05"))))) (ert-deftest icalendar--first-weekday-of-year () "Test method for `icalendar-first-weekday-of-year'." @@ -363,7 +334,9 @@ (ert-deftest icalendar--import-format-sample () "Test method for `icalendar-import-format-sample'." - (should (string= (icalendar-import-format-sample + (should (string= (concat "SUMMARY=`a' DESCRIPTION=`b' LOCATION=`c' " + "ORGANIZER=`d' STATUS=`' URL=`' CLASS=`'") + (icalendar-import-format-sample (icalendar-tests--get-ical-event "BEGIN:VEVENT DTSTAMP:20030509T043439Z DTSTART:20030509T103000 @@ -373,9 +346,7 @@ DTEND:20030509T153000 DESCRIPTION:b END:VEVENT -")) - (concat "SUMMARY=`a' DESCRIPTION=`b' LOCATION=`c' " - "ORGANIZER=`d' STATUS=`' URL=`' CLASS=`'")))) +"))))) (ert-deftest icalendar--format-ical-event () "Test `icalendar--format-ical-event'." @@ -397,12 +368,11 @@ DESCRIPTION:des END:VEVENT "))) - (should (string= (icalendar--format-ical-event event) - "SUM sum DES des LOC loc ORG org")) + (should (string= "SUM sum DES des LOC loc ORG org" + (icalendar--format-ical-event event))) (setq icalendar-import-format (lambda (&rest ignore) "helloworld")) - (should (string= (icalendar--format-ical-event event) - "helloworld")) + (should (string= "helloworld" (icalendar--format-ical-event event))) (setq icalendar-import-format (lambda (e) (format "-%s-%s-%s-%s-%s-%s-%s-" @@ -413,8 +383,8 @@ (icalendar--get-event-property event 'STATUS) (icalendar--get-event-property event 'URL) (icalendar--get-event-property event 'CLASS)))) - (should (string= (icalendar--format-ical-event event) - "-sum-des-loc-org-nil-nil-nil-")))) + (should (string= "-sum-des-loc-org-nil-nil-nil-" + (icalendar--format-ical-event event))))) (ert-deftest icalendar--parse-summary-and-rest () "Test `icalendar--parse-summary-and-rest'." @@ -428,15 +398,15 @@ (icalendar-import-format-class " CLA %s") (result)) (setq result (icalendar--parse-summary-and-rest "SUM sum ORG org")) - (should (string= (cdr (assoc 'org result)) "org")) + (should (string= "org" (cdr (assoc 'org result)))) (setq result (icalendar--parse-summary-and-rest "SUM sum DES des LOC loc ORG org STA sta URL url CLA cla")) - (should (string= (cdr (assoc 'des result)) "des")) - (should (string= (cdr (assoc 'loc result)) "loc")) - (should (string= (cdr (assoc 'org result)) "org")) - (should (string= (cdr (assoc 'sta result)) "sta")) - (should (string= (cdr (assoc 'cla result)) "cla")) + (should (string= "des" (cdr (assoc 'des result)))) + (should (string= "loc" (cdr (assoc 'loc result)))) + (should (string= "org" (cdr (assoc 'org result)))) + (should (string= "sta" (cdr (assoc 'sta result)))) + (should (string= "cla" (cdr (assoc 'cla result)))) (setq icalendar-import-format (lambda () "Hello world")) (setq result (icalendar--parse-summary-and-rest @@ -738,12 +708,10 @@ Argument EXPECTED-OUTPUT expected diary string." (let ((temp-file (make-temp-file "icalendar-test-diary"))) (icalendar-import-buffer temp-file t t) - (unwind-protect - (save-excursion - (find-file temp-file) - (let ((result (buffer-substring-no-properties (point-min) (point-max)))) - (should (icalendar-tests--compare-strings result - expected-output)))) + (save-excursion + (find-file temp-file) + (let ((result (buffer-substring-no-properties (point-min) (point-max)))) + (should (string= expected-output result))) (kill-buffer (find-buffer-visiting temp-file)) (delete-file temp-file)))) @@ -753,23 +721,23 @@ "SUMMARY:non-recurring DTSTART;VALUE=DATE-TIME:20030919T090000 DTEND;VALUE=DATE-TIME:20030919T113000" - "&2003/9/19 09:00-11:30 non-recurring" - "&19/9/2003 09:00-11:30 non-recurring" - "&9/19/2003 09:00-11:30 non-recurring") + "&2003/9/19 09:00-11:30 non-recurring\n" + "&19/9/2003 09:00-11:30 non-recurring\n" + "&9/19/2003 09:00-11:30 non-recurring\n") (icalendar-tests--test-import "SUMMARY:non-recurring allday DTSTART;VALUE=DATE-TIME:20030919" - "&2003/9/19 non-recurring allday" - "&19/9/2003 non-recurring allday" - "&9/19/2003 non-recurring allday") + "&2003/9/19 non-recurring allday\n" + "&19/9/2003 non-recurring allday\n" + "&9/19/2003 non-recurring allday\n") (icalendar-tests--test-import ;; do not remove the trailing blank after "long"! - "SUMMARY:long + "SUMMARY:long summary DTSTART;VALUE=DATE:20030919" - "&2003/9/19 long summary" - "&19/9/2003 long summary" - "&9/19/2003 long summary") + "&2003/9/19 long summary\n" + "&19/9/2003 long summary\n" + "&9/19/2003 long summary\n") (icalendar-tests--test-import "UID:748f2da0-0d9b-11d8-97af-b4ec8686ea61 SUMMARY:Sommerferien @@ -791,7 +759,8 @@ " "&%%(and (diary-block 7 19 2004 8 27 2004)) Sommerferien Status: TENTATIVE - Class: PRIVATE") + Class: PRIVATE +") (icalendar-tests--test-import "UID :04979712-3902-11d9-93dd-8f9f4afe08da @@ -814,13 +783,13 @@ " "&2004/11/23 14:00-14:30 folded summary Status: TENTATIVE - Class: PRIVATE" + Class: PRIVATE\n" "&23/11/2004 14:00-14:30 folded summary Status: TENTATIVE - Class: PRIVATE" + Class: PRIVATE\n" "&11/23/2004 14:00-14:30 folded summary Status: TENTATIVE - Class: PRIVATE") + Class: PRIVATE\n") (icalendar-tests--test-import "UID @@ -842,13 +811,13 @@ " "&2004/11/23 14:45-15:45 another example Status: TENTATIVE - Class: PRIVATE" + Class: PRIVATE\n" "&23/11/2004 14:45-15:45 another example Status: TENTATIVE - Class: PRIVATE" + Class: PRIVATE\n" "&11/23/2004 14:45-15:45 another example Status: TENTATIVE - Class: PRIVATE")) + Class: PRIVATE\n")) (ert-deftest icalendar-import-rrule () (icalendar-tests--test-import @@ -857,9 +826,9 @@ DTEND;VALUE=DATE-TIME:20030919T113000 RRULE:FREQ=DAILY; " - "&%%(and (diary-cyclic 1 2003 9 19)) 09:00-11:30 rrule daily" - "&%%(and (diary-cyclic 1 19 9 2003)) 09:00-11:30 rrule daily" - "&%%(and (diary-cyclic 1 9 19 2003)) 09:00-11:30 rrule daily") + "&%%(and (diary-cyclic 1 2003 9 19)) 09:00-11:30 rrule daily\n" + "&%%(and (diary-cyclic 1 19 9 2003)) 09:00-11:30 rrule daily\n" + "&%%(and (diary-cyclic 1 9 19 2003)) 09:00-11:30 rrule daily\n") ;; RRULE examples (icalendar-tests--test-import "SUMMARY:rrule daily @@ -867,9 +836,9 @@ DTEND;VALUE=DATE-TIME:20030919T113000 RRULE:FREQ=DAILY;INTERVAL=2 " - "&%%(and (diary-cyclic 2 2003 9 19)) 09:00-11:30 rrule daily" - "&%%(and (diary-cyclic 2 19 9 2003)) 09:00-11:30 rrule daily" - "&%%(and (diary-cyclic 2 9 19 2003)) 09:00-11:30 rrule daily") + "&%%(and (diary-cyclic 2 2003 9 19)) 09:00-11:30 rrule daily\n" + "&%%(and (diary-cyclic 2 19 9 2003)) 09:00-11:30 rrule daily\n" + "&%%(and (diary-cyclic 2 9 19 2003)) 09:00-11:30 rrule daily\n") (icalendar-tests--test-import "SUMMARY:rrule daily with exceptions DTSTART;VALUE=DATE-TIME:20030919T090000 @@ -877,36 +846,36 @@ RRULE:FREQ=DAILY;INTERVAL=2 EXDATE:20030921,20030925 " - "&%%(and (not (diary-date 2003 9 25)) (not (diary-date 2003 9 21)) (diary-cyclic 2 2003 9 19)) 09:00-11:30 rrule daily with exceptions" - "&%%(and (not (diary-date 25 9 2003)) (not (diary-date 21 9 2003)) (diary-cyclic 2 19 9 2003)) 09:00-11:30 rrule daily with exceptions" - "&%%(and (not (diary-date 9 25 2003)) (not (diary-date 9 21 2003)) (diary-cyclic 2 9 19 2003)) 09:00-11:30 rrule daily with exceptions") + "&%%(and (not (diary-date 2003 9 25)) (not (diary-date 2003 9 21)) (diary-cyclic 2 2003 9 19)) 09:00-11:30 rrule daily with exceptions\n" + "&%%(and (not (diary-date 25 9 2003)) (not (diary-date 21 9 2003)) (diary-cyclic 2 19 9 2003)) 09:00-11:30 rrule daily with exceptions\n" + "&%%(and (not (diary-date 9 25 2003)) (not (diary-date 9 21 2003)) (diary-cyclic 2 9 19 2003)) 09:00-11:30 rrule daily with exceptions\n") (icalendar-tests--test-import "SUMMARY:rrule weekly DTSTART;VALUE=DATE-TIME:20030919T090000 DTEND;VALUE=DATE-TIME:20030919T113000 RRULE:FREQ=WEEKLY; " - "&%%(and (diary-cyclic 7 2003 9 19)) 09:00-11:30 rrule weekly" - "&%%(and (diary-cyclic 7 19 9 2003)) 09:00-11:30 rrule weekly" - "&%%(and (diary-cyclic 7 9 19 2003)) 09:00-11:30 rrule weekly") + "&%%(and (diary-cyclic 7 2003 9 19)) 09:00-11:30 rrule weekly\n" + "&%%(and (diary-cyclic 7 19 9 2003)) 09:00-11:30 rrule weekly\n" + "&%%(and (diary-cyclic 7 9 19 2003)) 09:00-11:30 rrule weekly\n") (icalendar-tests--test-import "SUMMARY:rrule monthly no end DTSTART;VALUE=DATE-TIME:20030919T090000 DTEND;VALUE=DATE-TIME:20030919T113000 RRULE:FREQ=MONTHLY; " - "&%%(and (diary-date t t 19) (diary-block 2003 9 19 9999 1 1)) 09:00-11:30 rrule monthly no end" - "&%%(and (diary-date 19 t t) (diary-block 19 9 2003 1 1 9999)) 09:00-11:30 rrule monthly no end" - "&%%(and (diary-date t 19 t) (diary-block 9 19 2003 1 1 9999)) 09:00-11:30 rrule monthly no end") + "&%%(and (diary-date t t 19) (diary-block 2003 9 19 9999 1 1)) 09:00-11:30 rrule monthly no end\n" + "&%%(and (diary-date 19 t t) (diary-block 19 9 2003 1 1 9999)) 09:00-11:30 rrule monthly no end\n" + "&%%(and (diary-date t 19 t) (diary-block 9 19 2003 1 1 9999)) 09:00-11:30 rrule monthly no end\n") (icalendar-tests--test-import "SUMMARY:rrule monthly with end DTSTART;VALUE=DATE-TIME:20030919T090000 DTEND;VALUE=DATE-TIME:20030919T113000 RRULE:FREQ=MONTHLY;UNTIL=20050819; " - "&%%(and (diary-date t t 19) (diary-block 2003 9 19 2005 8 19)) 09:00-11:30 rrule monthly with end" - "&%%(and (diary-date 19 t t) (diary-block 19 9 2003 19 8 2005)) 09:00-11:30 rrule monthly with end" - "&%%(and (diary-date t 19 t) (diary-block 9 19 2003 8 19 2005)) 09:00-11:30 rrule monthly with end") + "&%%(and (diary-date t t 19) (diary-block 2003 9 19 2005 8 19)) 09:00-11:30 rrule monthly with end\n" + "&%%(and (diary-date 19 t t) (diary-block 19 9 2003 19 8 2005)) 09:00-11:30 rrule monthly with end\n" + "&%%(and (diary-date t 19 t) (diary-block 9 19 2003 8 19 2005)) 09:00-11:30 rrule monthly with end\n") (icalendar-tests--test-import "DTSTART;VALUE=DATE:20040815 DTEND;VALUE=DATE:20040816 @@ -914,81 +883,81 @@ UID:CC56BEA6-49D2-11D8-8833-00039386D1C2-RID RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=8 " - "&%%(and (diary-anniversary 2004 8 15)) Maria Himmelfahrt" - "&%%(and (diary-anniversary 15 8 2004)) Maria Himmelfahrt" - "&%%(and (diary-anniversary 8 15 2004)) Maria Himmelfahrt") + "&%%(and (diary-anniversary 2004 8 15)) Maria Himmelfahrt\n" + "&%%(and (diary-anniversary 15 8 2004)) Maria Himmelfahrt\n" + "&%%(and (diary-anniversary 8 15 2004)) Maria Himmelfahrt\n") (icalendar-tests--test-import "SUMMARY:rrule yearly DTSTART;VALUE=DATE-TIME:20030919T090000 DTEND;VALUE=DATE-TIME:20030919T113000 RRULE:FREQ=YEARLY;INTERVAL=2 " - "&%%(and (diary-anniversary 2003 9 19)) 09:00-11:30 rrule yearly" ;FIXME - "&%%(and (diary-anniversary 19 9 2003)) 09:00-11:30 rrule yearly" ;FIXME - "&%%(and (diary-anniversary 9 19 2003)) 09:00-11:30 rrule yearly") ;FIXME + "&%%(and (diary-anniversary 2003 9 19)) 09:00-11:30 rrule yearly\n" ;FIXME + "&%%(and (diary-anniversary 19 9 2003)) 09:00-11:30 rrule yearly\n" ;FIXME + "&%%(and (diary-anniversary 9 19 2003)) 09:00-11:30 rrule yearly\n") ;FIXME (icalendar-tests--test-import "SUMMARY:rrule count daily short DTSTART;VALUE=DATE-TIME:20030919T090000 DTEND;VALUE=DATE-TIME:20030919T113000 RRULE:FREQ=DAILY;COUNT=1;INTERVAL=1 " - "&%%(and (diary-cyclic 1 2003 9 19) (diary-block 2003 9 19 2003 9 19)) 09:00-11:30 rrule count daily short" - "&%%(and (diary-cyclic 1 19 9 2003) (diary-block 19 9 2003 19 9 2003)) 09:00-11:30 rrule count daily short" - "&%%(and (diary-cyclic 1 9 19 2003) (diary-block 9 19 2003 9 19 2003)) 09:00-11:30 rrule count daily short") + "&%%(and (diary-cyclic 1 2003 9 19) (diary-block 2003 9 19 2003 9 19)) 09:00-11:30 rrule count daily short\n" + "&%%(and (diary-cyclic 1 19 9 2003) (diary-block 19 9 2003 19 9 2003)) 09:00-11:30 rrule count daily short\n" + "&%%(and (diary-cyclic 1 9 19 2003) (diary-block 9 19 2003 9 19 2003)) 09:00-11:30 rrule count daily short\n") (icalendar-tests--test-import "SUMMARY:rrule count daily long DTSTART;VALUE=DATE-TIME:20030919T090000 DTEND;VALUE=DATE-TIME:20030919T113000 RRULE:FREQ=DAILY;COUNT=14;INTERVAL=1 " - "&%%(and (diary-cyclic 1 2003 9 19) (diary-block 2003 9 19 2003 10 2)) 09:00-11:30 rrule count daily long" - "&%%(and (diary-cyclic 1 19 9 2003) (diary-block 19 9 2003 2 10 2003)) 09:00-11:30 rrule count daily long" - "&%%(and (diary-cyclic 1 9 19 2003) (diary-block 9 19 2003 10 2 2003)) 09:00-11:30 rrule count daily long") + "&%%(and (diary-cyclic 1 2003 9 19) (diary-block 2003 9 19 2003 10 2)) 09:00-11:30 rrule count daily long\n" + "&%%(and (diary-cyclic 1 19 9 2003) (diary-block 19 9 2003 2 10 2003)) 09:00-11:30 rrule count daily long\n" + "&%%(and (diary-cyclic 1 9 19 2003) (diary-block 9 19 2003 10 2 2003)) 09:00-11:30 rrule count daily long\n") (icalendar-tests--test-import "SUMMARY:rrule count bi-weekly 3 times DTSTART;VALUE=DATE-TIME:20030919T090000 DTEND;VALUE=DATE-TIME:20030919T113000 RRULE:FREQ=WEEKLY;COUNT=3;INTERVAL=2 " - "&%%(and (diary-cyclic 14 2003 9 19) (diary-block 2003 9 19 2003 10 31)) 09:00-11:30 rrule count bi-weekly 3 times" - "&%%(and (diary-cyclic 14 19 9 2003) (diary-block 19 9 2003 31 10 2003)) 09:00-11:30 rrule count bi-weekly 3 times" - "&%%(and (diary-cyclic 14 9 19 2003) (diary-block 9 19 2003 10 31 2003)) 09:00-11:30 rrule count bi-weekly 3 times") + "&%%(and (diary-cyclic 14 2003 9 19) (diary-block 2003 9 19 2003 10 31)) 09:00-11:30 rrule count bi-weekly 3 times\n" + "&%%(and (diary-cyclic 14 19 9 2003) (diary-block 19 9 2003 31 10 2003)) 09:00-11:30 rrule count bi-weekly 3 times\n" + "&%%(and (diary-cyclic 14 9 19 2003) (diary-block 9 19 2003 10 31 2003)) 09:00-11:30 rrule count bi-weekly 3 times\n") (icalendar-tests--test-import "SUMMARY:rrule count monthly DTSTART;VALUE=DATE-TIME:20030919T090000 DTEND;VALUE=DATE-TIME:20030919T113000 RRULE:FREQ=MONTHLY;INTERVAL=1;COUNT=5 " - "&%%(and (diary-date t t 19) (diary-block 2003 9 19 2004 1 19)) 09:00-11:30 rrule count monthly" - "&%%(and (diary-date 19 t t) (diary-block 19 9 2003 19 1 2004)) 09:00-11:30 rrule count monthly" - "&%%(and (diary-date t 19 t) (diary-block 9 19 2003 1 19 2004)) 09:00-11:30 rrule count monthly") + "&%%(and (diary-date t t 19) (diary-block 2003 9 19 2004 1 19)) 09:00-11:30 rrule count monthly\n" + "&%%(and (diary-date 19 t t) (diary-block 19 9 2003 19 1 2004)) 09:00-11:30 rrule count monthly\n" + "&%%(and (diary-date t 19 t) (diary-block 9 19 2003 1 19 2004)) 09:00-11:30 rrule count monthly\n") (icalendar-tests--test-import "SUMMARY:rrule count every second month DTSTART;VALUE=DATE-TIME:20030919T090000 DTEND;VALUE=DATE-TIME:20030919T113000 RRULE:FREQ=MONTHLY;INTERVAL=2;COUNT=5 " - "&%%(and (diary-date t t 19) (diary-block 2003 9 19 2004 5 19)) 09:00-11:30 rrule count every second month" ;FIXME - "&%%(and (diary-date 19 t t) (diary-block 19 9 2003 19 5 2004)) 09:00-11:30 rrule count every second month" ;FIXME - "&%%(and (diary-date t 19 t) (diary-block 9 19 2003 5 19 2004)) 09:00-11:30 rrule count every second month") ;FIXME + "&%%(and (diary-date t t 19) (diary-block 2003 9 19 2004 5 19)) 09:00-11:30 rrule count every second month\n" ;FIXME + "&%%(and (diary-date 19 t t) (diary-block 19 9 2003 19 5 2004)) 09:00-11:30 rrule count every second month\n" ;FIXME + "&%%(and (diary-date t 19 t) (diary-block 9 19 2003 5 19 2004)) 09:00-11:30 rrule count every second month\n") ;FIXME (icalendar-tests--test-import "SUMMARY:rrule count yearly DTSTART;VALUE=DATE-TIME:20030919T090000 DTEND;VALUE=DATE-TIME:20030919T113000 RRULE:FREQ=YEARLY;INTERVAL=1;COUNT=5 " - "&%%(and (diary-date t 9 19) (diary-block 2003 9 19 2007 9 19)) 09:00-11:30 rrule count yearly" - "&%%(and (diary-date 19 9 t) (diary-block 19 9 2003 19 9 2007)) 09:00-11:30 rrule count yearly" - "&%%(and (diary-date 9 19 t) (diary-block 9 19 2003 9 19 2007)) 09:00-11:30 rrule count yearly") + "&%%(and (diary-date t 9 19) (diary-block 2003 9 19 2007 9 19)) 09:00-11:30 rrule count yearly\n" + "&%%(and (diary-date 19 9 t) (diary-block 19 9 2003 19 9 2007)) 09:00-11:30 rrule count yearly\n" + "&%%(and (diary-date 9 19 t) (diary-block 9 19 2003 9 19 2007)) 09:00-11:30 rrule count yearly\n") (icalendar-tests--test-import "SUMMARY:rrule count every second year DTSTART;VALUE=DATE-TIME:20030919T090000 DTEND;VALUE=DATE-TIME:20030919T113000 RRULE:FREQ=YEARLY;INTERVAL=2;COUNT=5 " - "&%%(and (diary-date t 9 19) (diary-block 2003 9 19 2011 9 19)) 09:00-11:30 rrule count every second year" ;FIXME!!! - "&%%(and (diary-date 19 9 t) (diary-block 19 9 2003 19 9 2011)) 09:00-11:30 rrule count every second year" ;FIXME!!! - "&%%(and (diary-date 9 19 t) (diary-block 9 19 2003 9 19 2011)) 09:00-11:30 rrule count every second year") ;FIXME!!! + "&%%(and (diary-date t 9 19) (diary-block 2003 9 19 2011 9 19)) 09:00-11:30 rrule count every second year\n" ;FIXME!!! + "&%%(and (diary-date 19 9 t) (diary-block 19 9 2003 19 9 2011)) 09:00-11:30 rrule count every second year\n" ;FIXME!!! + "&%%(and (diary-date 9 19 t) (diary-block 9 19 2003 9 19 2011)) 09:00-11:30 rrule count every second year\n") ;FIXME!!! ) (ert-deftest icalendar-import-duration () @@ -998,9 +967,9 @@ SUMMARY:duration DURATION:P7D " - "&%%(and (diary-block 2005 2 17 2005 2 23)) duration" - "&%%(and (diary-block 17 2 2005 23 2 2005)) duration" - "&%%(and (diary-block 2 17 2005 2 23 2005)) duration") + "&%%(and (diary-block 2005 2 17 2005 2 23)) duration\n" + "&%%(and (diary-block 17 2 2005 23 2 2005)) duration\n" + "&%%(and (diary-block 2 17 2005 2 23 2005)) duration\n") (icalendar-tests--test-import "UID:20041127T183329Z-18215-1001-4536-49109@andromeda DTSTAMP:20041127T183315Z @@ -1014,11 +983,11 @@ CREATED:20041127T183329 " "&%%(and (diary-cyclic 1 2001 12 21) (diary-block 2001 12 21 2001 12 29)) Urlaub - Class: PUBLIC" + Class: PUBLIC\n" "&%%(and (diary-cyclic 1 21 12 2001) (diary-block 21 12 2001 29 12 2001)) Urlaub - Class: PUBLIC" + Class: PUBLIC\n" "&%%(and (diary-cyclic 1 12 21 2001) (diary-block 12 21 2001 12 29 2001)) Urlaub - Class: PUBLIC")) + Class: PUBLIC\n")) (ert-deftest icalendar-import-bug-6766 () ;;bug#6766 -- multiple byday values in a weekly rrule @@ -1049,20 +1018,62 @@ Status: CONFIRMED Class: PUBLIC &%%(and (memq (calendar-day-of-week date) '(2 4)) (diary-cyclic 1 2010 4 22)) Tues + Thurs thinking - Class: PUBLIC" - + Class: PUBLIC +" "&%%(and (memq (calendar-day-of-week date) '(1 3 4 5)) (diary-cyclic 1 21 4 2010)) 11:30-12:00 Scrum Status: CONFIRMED Class: PUBLIC &%%(and (memq (calendar-day-of-week date) '(2 4)) (diary-cyclic 1 22 4 2010)) Tues + Thurs thinking - Class: PUBLIC" - + Class: PUBLIC +" "&%%(and (memq (calendar-day-of-week date) '(1 3 4 5)) (diary-cyclic 1 4 21 2010)) 11:30-12:00 Scrum Status: CONFIRMED Class: PUBLIC &%%(and (memq (calendar-day-of-week date) '(2 4)) (diary-cyclic 1 4 22 2010)) Tues + Thurs thinking - Class: PUBLIC")) + Class: PUBLIC +")) +(ert-deftest icalendar-import-multiple-vcalendars () + (icalendar-tests--test-import + "DTSTART;VALUE=DATE:20110723 +SUMMARY:event-1 +" + "&2011/7/23 event-1\n" + "&23/7/2011 event-1\n" + "&7/23/2011 event-1\n") + + (icalendar-tests--test-import + "BEGIN:VCALENDAR +PRODID:-//Emacs//NONSGML icalendar.el//EN +VERSION:2.0\nBEGIN:VEVENT +DTSTART;VALUE=DATE:20110723 +SUMMARY:event-1 +END:VEVENT +END:VCALENDAR +BEGIN:VCALENDAR +PRODID:-//Emacs//NONSGML icalendar.el//EN +VERSION:2.0 +BEGIN:VEVENT +DTSTART;VALUE=DATE:20110724 +SUMMARY:event-2 +END:VEVENT +END:VCALENDAR +BEGIN:VCALENDAR +PRODID:-//Emacs//NONSGML icalendar.el//EN +VERSION:2.0 +BEGIN:VEVENT +DTSTART;VALUE=DATE:20110725 +SUMMARY:event-3a +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20110725 +SUMMARY:event-3b +END:VEVENT +END:VCALENDAR +" + "&2011/7/23 event-1\n&2011/7/24 event-2\n&2011/7/25 event-3a\n&2011/7/25 event-3b\n" + "&23/7/2011 event-1\n&24/7/2011 event-2\n&25/7/2011 event-3a\n&25/7/2011 event-3b\n" + "&7/23/2011 event-1\n&7/24/2011 event-2\n&7/25/2011 event-3a\n&7/25/2011 event-3b\n")) ;; ====================================================================== ;; Cycle @@ -1113,7 +1124,7 @@ (when (re-search-forward "\nUID:.*\n" nil t) (replace-match "\n")) (let ((cycled (buffer-substring-no-properties (point-min) (point-max)))) - (should (icalendar-tests--compare-strings cycled org-input))))) + (should (string= org-input cycled))))) ;; clean up (kill-buffer (find-buffer-visiting temp-diary)) (save-excursion @@ -1211,12 +1222,14 @@ Desc: 10:30am - Blah Location: Cccc Organizer: MAILTO:aaaaaaa@aaaaaaa.com - Status: CONFIRMED" + Status: CONFIRMED +" "&5/9/2003 10:30-15:30 On-Site Interview Desc: 10:30am - Blah Location: Cccc Organizer: MAILTO:aaaaaaa@aaaaaaa.com - Status: CONFIRMED") + Status: CONFIRMED +") ;; 2003-06-18 a (icalendar-tests--test-import @@ -1255,12 +1268,14 @@ Desc: 753 Zeichen hier radiert Location: 555 or TN 555-5555 ID 5555 & NochWas (see below) Organizer: MAILTO:xxx@xxxxx.com - Status: CONFIRMED" + Status: CONFIRMED +" "&6/23/2003 11:00-12:00 Dress Rehearsal for XXXX-XXXX Desc: 753 Zeichen hier radiert Location: 555 or TN 555-5555 ID 5555 & NochWas (see below) Organizer: MAILTO:xxx@xxxxx.com - Status: CONFIRMED") + Status: CONFIRMED +") ;; 2003-06-18 b -- uses timezone (icalendar-tests--test-import "BEGIN:VCALENDAR @@ -1323,12 +1338,14 @@ Desc: Viele Zeichen standen hier früher Location: 123 or TN 123-1234 ID abcd & SonstWo (see below) Organizer: MAILTO:bbb@bbbbb.com - Status: CONFIRMED" + Status: CONFIRMED +" "&6/23/2003 17:00-18:00 Updated: Dress Rehearsal for ABC01-15 Desc: Viele Zeichen standen hier früher Location: 123 or TN 123-1234 ID abcd & SonstWo (see below) Organizer: MAILTO:bbb@bbbbb.com - Status: CONFIRMED") + Status: CONFIRMED +") ;; export 2004-10-28 block entries (icalendar-tests--test-export nil @@ -1697,7 +1714,8 @@ Class: PRIVATE &%%(and (diary-cyclic 7 1 11 2004)) Wwww aa hhhh Status: TENTATIVE - Class: PRIVATE" + Class: PRIVATE +" "&11/23/2004 14:00-14:30 Jjjjj & Wwwww Status: TENTATIVE Class: PRIVATE @@ -1716,7 +1734,8 @@ Class: PRIVATE &%%(and (diary-cyclic 7 11 1 2004)) Wwww aa hhhh Status: TENTATIVE - Class: PRIVATE") + Class: PRIVATE +") ;; 2004-09-09 pg (icalendar-tests--test-export @@ -1771,11 +1790,13 @@ "&%%(and (diary-block 6 2 2005 6 2 2005)) Waitangi Day Desc: abcdef Status: CONFIRMED - Class: PRIVATE" + Class: PRIVATE +" "&%%(and (diary-block 2 6 2005 2 6 2005)) Waitangi Day Desc: abcdef Status: CONFIRMED - Class: PRIVATE") + Class: PRIVATE +") ;; 2005-03-01 lt (icalendar-tests--test-import @@ -1785,8 +1806,8 @@ DTSTAMP:20050118T210335Z DURATION:P7D" nil - "&%%(and (diary-block 17 2 2005 23 2 2005)) Hhhhhh Aaaaa ii Aaaaaaaa" - "&%%(and (diary-block 2 17 2005 2 23 2005)) Hhhhhh Aaaaa ii Aaaaaaaa") + "&%%(and (diary-block 17 2 2005 23 2 2005)) Hhhhhh Aaaaa ii Aaaaaaaa\n" + "&%%(and (diary-block 2 17 2005 2 23 2005)) Hhhhhh Aaaaa ii Aaaaaaaa\n") ;; 2005-03-23 lt (icalendar-tests--test-export ------------------------------------------------------------ Use --include-merges or -n0 to see merged revisions.