2

What is the reverse method of org-id-get-create -- i.e., remove the ID property drawer and also remove the corresponding entry in the org-id-locations-file?

2 Answers 2

2

org-id-get-create calls org-id-get, which calls org-id-add-location, which updates the global org-id-locations hash-table. This does not automatically update the org-id-locations-file. I have chosen to add org-id-locations-save to a custom version of org-id-get -- just after the call to org-id-add-location. However, that is not mission critical since there are other methods such as the kill-emacs-hook that trigger org-id-locations-save. [I simply want my database updated forthwith.]

The following function will remove the ID property drawer and update both the org-id-locations hash-table and the org-id-locations-file.

(defun org-id-remove-entry ()
"Remove/delete the ID entry and update the databases.
Update the `org-id-locations' global hash-table, and update the
`org-id-locations-file'.  `org-id-track-globally' must be `t`."
(interactive)
  (save-excursion
    (org-back-to-heading t)
    (when (org-entry-delete (point) "ID")
      (org-id-update-id-locations nil 'silent))))
1

The OP asked how to remove, I have been happy hiding it with this config:

(setq org-id-locations-file "/path/to/state-directory")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.