emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Anand Deopurkar <anandrdeopurkar@gmail.com>
To: Org Mode List <emacs-orgmode@gnu.org>
Subject: [PATCH] org-agenda.el: Fix org-agenda-write to avoid duplicates
Date: Sun, 03 Mar 2024 20:12:52 +1100	[thread overview]
Message-ID: <87r0gradbf.fsf@gmail.com> (raw)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: 0001-org-agenda.el-Fix-org-agenda-write-to-avoid-duplicat.patch --]
[-- Type: text/x-patch, Size: 1439 bytes --]

From a269ee1d657ea11f998d294169cd9a88618409fb Mon Sep 17 00:00:00 2001
From: Anand Deopurkar <anandrdeopurkar@gmail.com>
Date: Sun, 3 Mar 2024 16:38:43 +1100
Subject: [PATCH] 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
---
 lisp/org-agenda.el | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 8cb3496ca..798ef1a10 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -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))
-- 
2.43.0



             reply	other threads:[~2024-03-03  9:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-03  9:12 Anand Deopurkar [this message]
2024-03-03 13:47 ` [PATCH] org-agenda.el: Fix org-agenda-write to avoid duplicates Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r0gradbf.fsf@gmail.com \
    --to=anandrdeopurkar@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).