From 17e4fe90930596ba5cdf82223b9f5de9040a9581 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sun, 13 Feb 2022 22:13:41 +0100 Subject: [PATCH] lint: Fix false positive with inline footnote definitions * lisp/org-lint.el (org-lint-invalid-macro-argument-and-template): Take into consideration inline definitions. * testing/lisp/test-org-lint.el (test-org-lint/undefined-footnote-reference): Add test. Reported-by: Timothy --- lisp/org-lint.el | 8 ++++++-- testing/lisp/test-org-lint.el | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lisp/org-lint.el b/lisp/org-lint.el index 0894951b6..83c2d08a9 100644 --- a/lisp/org-lint.el +++ b/lisp/org-lint.el @@ -784,8 +784,12 @@ Use \"export %s\" instead" reports)) (defun org-lint-undefined-footnote-reference (ast) - (let ((definitions (org-element-map ast 'footnote-definition - (lambda (f) (org-element-property :label f))))) + (let ((definitions + (org-element-map ast '(footnote-definition footnote-reference) + (lambda (f) + (and (or (eq 'footnote-definition (org-element-type f)) + (eq 'inline (org-element-property :type f))) + (org-element-property :label f)))))) (org-element-map ast 'footnote-reference (lambda (f) (let ((label (org-element-property :label f))) diff --git a/testing/lisp/test-org-lint.el b/testing/lisp/test-org-lint.el index e57993c0a..d293e2732 100644 --- a/testing/lisp/test-org-lint.el +++ b/testing/lisp/test-org-lint.el @@ -358,6 +358,9 @@ This is not a node property (should-not (org-test-with-temp-text "Text[fn:1:inline reference]" (org-lint '(undefined-footnote-reference)))) + (should-not + (org-test-with-temp-text "Text[fn:1:inline reference] [fn:1]" + (org-lint '(undefined-footnote-reference)))) (should-not (org-test-with-temp-text "Text[fn::anonymous reference]" (org-lint '(undefined-footnote-reference)))))