branch: externals/org
commit 2cf245810b76666df0d7dcf0717cb78de11930bd
Author: Ihor Radchenko <[email protected]>
Commit: Ihor Radchenko <[email protected]>
org-lint-invalid-id-link: Improve performance
* lisp/org-lint.el (org-lint-invalid-id-link): Do not try to search
for exact position of every ID. Instead, sync all the ID locations
once and then make use of the up-to-date locations state to query if
an ID is present.
---
lisp/org-lint.el | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/lisp/org-lint.el b/lisp/org-lint.el
index bb8e7c7c21..0e0bbea66d 100644
--- a/lisp/org-lint.el
+++ b/lisp/org-lint.el
@@ -584,11 +584,16 @@ Use :header-args: instead"
path)))))))))
(defun org-lint-invalid-id-link (ast)
+ (org-id-update-id-locations nil t)
(org-element-map ast 'link
(lambda (link)
(let ((id (org-element-property :path link)))
(and (equal (org-element-property :type link) "id")
- (not (org-id-find id))
+ ;; The locations are up-to-date with file changes after
+ ;; the call to `org-id-update-id-locations'. We do not
+ ;; need to double-check if recorded ID is still present
+ ;; in the file.
+ (not (org-id-find-id-file id))
(list (org-element-begin link)
(format "Unknown ID \"%s\"" id)))))))