From ec96a2a436d0310c93ecdcc99bec845c5bc917d0 Mon Sep 17 00:00:00 2001 From: bth Date: Fri, 5 Jun 2026 13:46:15 -0700 Subject: [PATCH] um-tag-insert should refuse to add dupes --- um.el | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/um.el b/um.el index 0833365..cc4192e 100644 --- a/um.el +++ b/um.el @@ -294,10 +294,15 @@ Ultimately this relies on `xref-matches-in-files', which calls (reverse tags))) (defun um-tag-insert (tag) - "Insert TAG as + tag\n in current buffer appending to the journal header." - (goto-char (um--header-end-pos)) - (forward-line -1) - (insert (concat "+ " tag "\n"))) + "Insert TAG as + tag\n in current buffer appending to the journal header. + +Emits message if TAG is already present, but does not error." + (if (member tag (um--extract-tags (list buffer-file-name))) + ;; NOTE: user-error would stop any iteration over files: + (message "\"%s\" tag already exists in %s" tag buffer-file-name) + (goto-char (um--header-end-pos)) + (forward-line -1) + (insert (concat "+ " tag "\n")))) (defun um-tag-delete (tag) "Delete TAG from the journal header in current buffer."