org-agenda.el: Fix org-agenda-write to avoid duplicates

* lisp/org-agenda.el (org-agenda-write): Make sure headlines are not
duplicated when writing to an `org' file, even if they are repeated in
the agenda view.

For example, a headline may appear multiple times in the agenda
view (for example, if it has multiple time stamps).  But
org-agenda-write should write it only once to the output `org' file.

TINYCHANGE
This commit is contained in:
Anand Deopurkar 2024-03-03 16:38:43 +11:00 committed by Ihor Radchenko
parent 2da622cad7
commit 8ac99c33f0
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 6 additions and 5 deletions

View File

@ -3641,11 +3641,12 @@ the agenda to write."
(goto-char p)
(setq m (get-text-property (point) 'org-hd-marker))
(when m
(push (with-current-buffer (marker-buffer m)
(goto-char m)
(org-copy-subtree 1 nil t t)
org-subtree-clip)
content)))
(cl-pushnew (with-current-buffer (marker-buffer m)
(goto-char m)
(org-copy-subtree 1 nil t t)
org-subtree-clip)
content
:test #'equal)))
(find-file file)
(erase-buffer)
(dolist (s content) (org-paste-subtree 1 s))