summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Guerry <bzg@altern.org>2013-03-01 15:47:55 +0100
committerBastien Guerry <bzg@altern.org>2013-03-01 15:47:55 +0100
commitccc7383890b0a3af139bd0f4b8282572d605183b (patch)
treef1c0c1a30272d724263b3ceccb60d73f1de820f2
parent0c40f479cd68385b1302f925819cb5434e1a0fd6 (diff)
downloadorg-mode-ccc7383890b0a3af139bd0f4b8282572d605183b.tar.gz
Don't create UID for the entire file when write an agenda to .ics
* org-agenda.el (org-agenda-collect-markers) (org-create-marker-find-array): Move to ox-icalendar.el. (org-agenda-marker-table, org-check-agenda-marker-table): Delete. * ox-icalendar.el (org-icalendar-create-uid): New parameter H-MARKERS to only update some headlines, not the whole file. (org-icalendar--combine-files): When exporting to an .ics file only add UID to the headlines shown in the agenda buffer. (org-agenda-collect-markers, org-create-marker-find-array): Move here.
-rw-r--r--lisp/org-agenda.el37
-rw-r--r--lisp/ox-icalendar.el52
2 files changed, 39 insertions, 50 deletions
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 3b6a005..70cee2f 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -3432,43 +3432,6 @@ removed from the entry content. Currently only `planning' is allowed here."
(setq txt (buffer-substring (point-min) (point)))))))))
txt))
-(defun org-agenda-collect-markers ()
- "Collect the markers pointing to entries in the agenda buffer."
- (let (m markers)
- (save-excursion
- (goto-char (point-min))
- (while (not (eobp))
- (when (setq m (or (org-get-at-bol 'org-hd-marker)
- (org-get-at-bol 'org-marker)))
- (push m markers))
- (beginning-of-line 2)))
- (nreverse markers)))
-
-(defun org-create-marker-find-array (marker-list)
- "Create a alist of files names with all marker positions in that file."
- (let (f tbl m a p)
- (while (setq m (pop marker-list))
- (setq p (marker-position m)
- f (buffer-file-name (or (buffer-base-buffer
- (marker-buffer m))
- (marker-buffer m))))
- (if (setq a (assoc f tbl))
- (push (marker-position m) (cdr a))
- (push (list f p) tbl)))
- (mapcar (lambda (x) (setcdr x (sort (copy-sequence (cdr x)) '<)) x)
- tbl)))
-
-(defvar org-agenda-marker-table nil) ; dynamically scoped parameter
-(defun org-check-agenda-marker-table ()
- "Check of the current entry is on the marker list."
- (let ((file (buffer-file-name (or (buffer-base-buffer) (current-buffer))))
- a)
- (and (setq a (assoc file org-agenda-marker-table))
- (save-match-data
- (save-excursion
- (org-back-to-heading t)
- (member (point) (cdr a)))))))
-
(defun org-check-for-org-mode ()
"Make sure current buffer is in org-mode. Error if not."
(or (derived-mode-p 'org-mode)
diff --git a/lisp/ox-icalendar.el b/lisp/ox-icalendar.el
index f0b98b9..12b3ca7 100644
--- a/lisp/ox-icalendar.el
+++ b/lisp/ox-icalendar.el
@@ -285,20 +285,23 @@ re-read the iCalendar file.")
;;; Internal Functions
-(defun org-icalendar-create-uid (file &optional bell)
+(defun org-icalendar-create-uid (file &optional bell h-markers)
"Set ID property on headlines missing it in FILE.
When optional argument BELL is non-nil, inform the user with
-a message if the file was modified."
- (let (modified-flag)
+a message if the file was modified. With optional argument
+H-MARKERS non-nil, it is a list of markers for the headlines
+which will be updated."
+ (let (modified-flag pt)
+ (when h-markers (setq pt (goto-char (car h-markers))))
(org-map-entries
(lambda ()
(let ((entry (org-element-at-point)))
- (unless (org-element-property :ID entry)
+ (unless (or (< (point) pt) (org-element-property :ID entry))
(org-id-get-create)
(setq modified-flag t)
(forward-line))
- (when (eq (org-element-type entry) 'inlinetask)
- (setq org-map-continue-from (org-element-property :end entry)))))
+ (setq org-map-continue-from
+ (if h-markers (pop h-markers) (point-max)))))
nil nil 'comment)
(when (and bell modified-flag)
(message "ID properties created in file \"%s\"" file)
@@ -888,8 +891,32 @@ The file is stored under the name chosen in
`(apply 'org-icalendar--combine-files nil ',files)))
(apply 'org-icalendar--combine-files nil (org-agenda-files t))))
-(declare-function org-agenda-collect-markers "org-agenda" ())
-(declare-function org-create-marker-find-array "org-agenda" (marker-list))
+(defun org-agenda-collect-markers ()
+ "Collect the markers pointing to entries in the agenda buffer."
+ (let (m markers)
+ (save-excursion
+ (goto-char (point-min))
+ (while (not (eobp))
+ (when (setq m (or (org-get-at-bol 'org-hd-marker)
+ (org-get-at-bol 'org-marker)))
+ (push m markers))
+ (beginning-of-line 2)))
+ (nreverse markers)))
+
+(defun org-create-marker-find-array (marker-list)
+ "Create an alist of files names with all marker positions in that file."
+ (let (f tbl m a p)
+ (while (setq m (pop marker-list))
+ (setq p (marker-position m)
+ f (buffer-file-name
+ (or (buffer-base-buffer (marker-buffer m))
+ (marker-buffer m))))
+ (if (setq a (assoc f tbl))
+ (push (marker-position m) (cdr a))
+ (push (list f p) tbl)))
+ (mapcar (lambda (x) (setcdr x (sort (copy-sequence (cdr x)) '<)) x)
+ tbl)))
+
(defun org-icalendar-export-current-agenda (file)
"Export current agenda view to an iCalendar FILE.
This function assumes major mode for current buffer is
@@ -930,11 +957,10 @@ files to build the calendar from."
(catch 'nextfile
(org-check-agenda-file file)
(with-current-buffer (org-get-agenda-file-buffer file)
- ;; Create ID if necessary.
- (when org-icalendar-store-UID
- (org-icalendar-create-uid file))
- (let ((marks (cdr (assoc (expand-file-name file)
- restriction))))
+ (let ((marks (cdr (assoc (expand-file-name file) restriction))))
+ ;; Create ID if necessary.
+ (when org-icalendar-store-UID
+ (org-icalendar-create-uid file t marks))
(unless (and restriction (not marks))
;; Add a hook adding :ICALENDAR_MARK: property
;; to each entry appearing in agenda view.