From 0ea7f0233604d11ea459d04f620384ae2b954ede Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Tue, 15 Sep 2009 19:10:53 +0100 Subject: [PATCH] Fix bug when forcing an ID onto an item. The bug happened when calling org-id-get from another buffer. It is then important to switch to that buffer when the new ID is created. --- lisp/ChangeLog | 4 ++++ lisp/org-id.el | 21 +++++++++++---------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 0ae4b9af2..936e1aa4d 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -13,6 +13,10 @@ * org.el: Add an entry for org-crypt. +2009-09-15 Carsten Dominik + + * org-id.el (org-id-get): Fix bug with forcing ID on an item. + 2009-09-15 Carsten Dominik * org-table.el (orgtbl-line-start-regexp): Match also TBLNAME diff --git a/lisp/org-id.el b/lisp/org-id.el index b8d6d00ca..448275143 100644 --- a/lisp/org-id.el +++ b/lisp/org-id.el @@ -212,16 +212,17 @@ If the entry does not have an ID, the function returns nil. However, when CREATE is non nil, create an ID if none is present already. PREFIX will be passed through to `org-id-new'. In any case, the ID of the entry is returned." - (let ((id (org-entry-get pom "ID"))) - (cond - ((and id (stringp id) (string-match "\\S-" id)) - id) - (create - (setq id (org-id-new prefix)) - (org-entry-put pom "ID" id) - (org-id-add-location id (buffer-file-name (buffer-base-buffer))) - id) - (t nil)))) + (org-with-point-at pom + (let ((id (org-entry-get nil "ID"))) + (cond + ((and id (stringp id) (string-match "\\S-" id)) + id) + (create + (setq id (org-id-new prefix)) + (org-entry-put pom "ID" id) + (org-id-add-location id (buffer-file-name (buffer-base-buffer))) + id) + (t nil))))) ;;;###autoload (defun org-id-get-with-outline-path-completion (&optional targets)