1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-11-30 08:08:26 +00:00

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.
This commit is contained in:
Bastien Guerry 2013-03-01 15:47:55 +01:00
parent 0c40f479cd
commit ccc7383890
2 changed files with 39 additions and 50 deletions

View File

@ -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)

View File

@ -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.