emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug? org-id-find not finding some IDs


From: Ihor Radchenko
Subject: Re: Bug? org-id-find not finding some IDs
Date: Thu, 04 Aug 2022 10:24:29 +0800

Jack Kamm <jackkamm@tatersworld.org> writes:

> For a minimal example, put the following in test.org:
>
>> * Headline 1
>> :PROPERTIES:
>> :ID:       b1569c92-3872-4ab9-80eb-274c4950991e
>> :END:
>
> Then:
>
> 1. emacs -Q test.org
> 2. C-x b *scratch*
> 3. M-: (org-id-find "b1569c92-3872-4ab9-80eb-274c4950991e")
>
> Which returns nil. Also, "C-h v org-id-files" doesn't contain
> test.org.

This is indeed inconsistent. The current behaviour is to scan only files
where it is known that IDs are present.

Can you try the attached patch?

Best,
Ihor

>From 5d166219c9af1f34dccebac55249db926fcfbbe1 Mon Sep 17 00:00:00 2001
Message-Id: 
<5d166219c9af1f34dccebac55249db926fcfbbe1.1659579786.git.yantar92@gmail.com>
From: Ihor Radchenko <yantar92@gmail.com>
Date: Thu, 4 Aug 2022 10:21:59 +0800
Subject: [PATCH] org-id-update-locations: Scan all the open Org buffers

* lisp/org-id.el (org-id-update-id-locations): Always scan all the
open Org file buffers for IDs.

Fixes 87r11zifjy.fsf@gmail.com">https://orgmode.org/list/87r11zifjy.fsf@gmail.com
---
 lisp/org-id.el | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lisp/org-id.el b/lisp/org-id.el
index f54e7280a..fe2f5f328 100644
--- a/lisp/org-id.el
+++ b/lisp/org-id.el
@@ -491,8 +491,8 @@ (defun org-id-decode (id)
 (defun org-id-update-id-locations (&optional files silent)
   "Scan relevant files for IDs.
 Store the relation between files and corresponding IDs.
-This will scan all agenda files, all associated archives, and all
-files currently mentioned in `org-id-locations'.
+This will scan all agenda files, all associated archives, all open Org
+files, and all files currently mentioned in `org-id-locations'.
 When FILES is given, scan also these files.
 If SILENT is non-nil, messages are suppressed."
   (interactive)
@@ -515,6 +515,8 @@ (defun org-id-update-id-locations (&optional files silent)
                       org-id-extra-files)
                     ;; All files known to have IDs.
                     org-id-files
+                     ;; All Org files open in Emacs.
+                     (mapcar #'buffer-file-name (org-buffer-list 'files t))
                     ;; Additional files from function call.
                     files)))))
          (nfiles (length files))
-- 
2.35.1


reply via email to

[Prev in Thread] Current Thread [Next in Thread]