* Bug? org-id-find not finding some IDs
@ 2022-08-02 1:45 Jack Kamm
2022-08-04 2:24 ` Ihor Radchenko
0 siblings, 1 reply; 4+ messages in thread
From: Jack Kamm @ 2022-08-02 1:45 UTC (permalink / raw)
To: emacs-orgmode
Hello,
The documentation for org-id-extra-files suggests that org-id-find
should search in Org files visited by Emacs:
> When Org reparses files to remake the list of files and IDs it is
> tracking, it will normally scan the agenda files, the archives
> related to agenda files, ... and any Org file currently visited by
> Emacs.
But, I've found that's not true, or maybe I'm misunderstanding the
doc.
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.
Or maybe the docstring for org-id-extra-files should be rewritten to
say "the current buffer" instead of "any Org file currently visited"?
Also, this seems to be the cause of this bug in org-caldav, which is
how I ran into it:
https://github.com/dengste/org-caldav/issues/230
Would there a recommended mitigation for this on org-caldav's side? I'm
thinking it could call
(org-id-update-id-locations org-caldav-files)
early on, to make sure org-caldav-files ends up in org-id-files.
Tested on following versions:
GNU Emacs 28.1 (build 2, x86_64-pc-linux-gnu, X toolkit, cairo version 1.17.6, Xaw3d scroll bars) of 2022-07-10
Org mode version 9.5.2 (release_9.5.2-25-gaf6f12 @ /usr/share/emacs/28.1/lisp/org/)
Org mode version 9.5.4 (release_9.5.4-702-g5a49cc @ /home/jack/dev/org-mode/lisp/)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Bug? org-id-find not finding some IDs
2022-08-02 1:45 Bug? org-id-find not finding some IDs Jack Kamm
@ 2022-08-04 2:24 ` Ihor Radchenko
2022-08-05 5:32 ` Jack Kamm
0 siblings, 1 reply; 4+ messages in thread
From: Ihor Radchenko @ 2022-08-04 2:24 UTC (permalink / raw)
To: Jack Kamm; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 552 bytes --]
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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-id-update-locations-Scan-all-the-open-Org-buffer.patch --]
[-- Type: text/x-patch, Size: 1644 bytes --]
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 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Bug? org-id-find not finding some IDs
2022-08-04 2:24 ` Ihor Radchenko
@ 2022-08-05 5:32 ` Jack Kamm
2022-08-05 12:46 ` Ihor Radchenko
0 siblings, 1 reply; 4+ messages in thread
From: Jack Kamm @ 2022-08-05 5:32 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: emacs-orgmode
Ihor Radchenko <yantar92@gmail.com> writes:
> 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?
Thanks, Ihor. I tried your patch and it solved my issue -- both the
minimal example I sent, as well as the related issue I was experiencing
with org-caldav.
Jack
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Bug? org-id-find not finding some IDs
2022-08-05 5:32 ` Jack Kamm
@ 2022-08-05 12:46 ` Ihor Radchenko
0 siblings, 0 replies; 4+ messages in thread
From: Ihor Radchenko @ 2022-08-05 12:46 UTC (permalink / raw)
To: Jack Kamm; +Cc: emacs-orgmode
Jack Kamm <jackkamm@tatersworld.org> writes:
> Ihor Radchenko <yantar92@gmail.com> writes:
>
>> 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?
>
> Thanks, Ihor. I tried your patch and it solved my issue -- both the
> minimal example I sent, as well as the related issue I was experiencing
> with org-caldav.
Applied onto main via 8f5bf1725.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=8f5bf172556564df89fb16ce8ecec68c5b7f0221
Best,
Ihor
> Jack
--
Ihor Radchenko,
Org mode maintainer,
Learn more about Org mode at https://orgmode.org/.
Support Org development at https://liberapay.com/org-mode,
or support my work at https://liberapay.com/yantar92
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-08-05 12:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-02 1:45 Bug? org-id-find not finding some IDs Jack Kamm
2022-08-04 2:24 ` Ihor Radchenko
2022-08-05 5:32 ` Jack Kamm
2022-08-05 12:46 ` Ihor Radchenko
Code repositories for project(s) associated with this 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).