branch: externals/org commit d560a2d7394cc9b016eade35360350023684448e Author: Ihor Radchenko <yanta...@posteo.net> Commit: Ihor Radchenko <yanta...@posteo.net>
org-lint-invalid-id-link: Only update ID locations if there are ID links * lisp/org-lint.el (org-lint-invalid-id-link): Avoid running `org-id-update-id-locations' when there are no ID links in the linted file. --- lisp/org-lint.el | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/lisp/org-lint.el b/lisp/org-lint.el index d0f6994215..7a9195cb63 100644 --- a/lisp/org-lint.el +++ b/lisp/org-lint.el @@ -585,18 +585,23 @@ 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") - ;; 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))))))) + (let ((id-locations-updated nil)) + (org-element-map ast 'link + (lambda (link) + (let ((id (org-element-property :path link))) + (and (equal (org-element-property :type link) "id") + (progn + (unless id-locations-updated + (org-id-update-id-locations nil t) + (setq id-locations-updated t)) + t) + ;; 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)))))))) (defun org-lint-confusing-brackets (ast) (org-element-map ast 'link