emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Matt Lundin <mdl@imapmail.org>
To: Org Mode <emacs-orgmode@gnu.org>
Subject: [PATCH 2/4] Warn if duplicate ID is created
Date: Sun, 1 May 2011 16:55:29 -0400	[thread overview]
Message-ID: <87liyqnnab.fsf@fastmail.fm> (raw)


* lisp/org-bibtex.el (org-bibtex-key-property): When storing key in
  ID, warn if a duplicate ID is generated.
---
 lisp/org-bibtex.el |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/lisp/org-bibtex.el b/lisp/org-bibtex.el
index f54a6bf..cf7fc49 100644
--- a/lisp/org-bibtex.el
+++ b/lisp/org-bibtex.el
@@ -239,7 +239,6 @@ not placed in the exported bibtex entry."
   :group 'org-bibtex
   :type 'boolean)
 
-;; TODO if ID, test to make sure ID is unique
 (defcustom org-bibtex-key-property "CUSTOM_ID"
   "Property that holds the bibtex key.
 By default, this is CUSTOM_ID, which enables easy linking to
@@ -364,10 +363,19 @@ This variable is relevant only if `org-bibtex-export-tags-as-keywords` is t."
   "Generate an autokey for the current headline"
   (org-bibtex-put org-bibtex-key-property
                   (if org-bibtex-autogen-keys
-                      (let ((entry (org-bibtex-headline)))
-                        (with-temp-buffer
-                          (insert entry)
-                          (bibtex-generate-autokey)))
+                      (let* ((entry (org-bibtex-headline))
+			     (key 
+			      (with-temp-buffer
+				(insert entry)
+				(bibtex-generate-autokey))))
+			;; test for duplicate IDs if using global ID
+			(when (and
+			       (equal org-bibtex-key-property "ID")
+			       (featurep 'org-id)
+			       (hash-table-p org-id-locations)
+			       (gethash key org-id-locations))
+			  (warn "Another entry has the same ID"))
+			key)
                     (read-from-minibuffer "id: "))))
 
 (defun org-bibtex-fleshout (type &optional optional)
-- 
1.7.5

                 reply	other threads:[~2011-05-01 21:06 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=87liyqnnab.fsf@fastmail.fm \
    --to=mdl@imapmail.org \
    --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).