diff options
author | Matt Lundin <mdl@imapmail.org> | 2011-05-01 16:55:29 -0400 |
---|---|---|
committer | Eric Schulte <schulte.eric@gmail.com> | 2011-05-02 10:19:33 -0600 |
commit | 5cfb04a4e1c72a7e09d66eb9d8692fd624b65f28 (patch) | |
tree | b8408dc7c66e3d65f0cad49412a09b265feff68f | |
parent | 1af957a906ebc6072b1f6800497428c0914912d1 (diff) | |
download | org-mode-5cfb04a4e1c72a7e09d66eb9d8692fd624b65f28.tar.gz |
Warn if duplicate ID is created
* lisp/org-bibtex.el (org-bibtex-key-property): When storing key in
ID, warn if a duplicate ID is generated.
-rw-r--r-- | 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 8a5bb98..12956fe 100644 --- a/lisp/org-bibtex.el +++ b/lisp/org-bibtex.el @@ -231,7 +231,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 @@ -356,10 +355,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) |