diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2020-06-25 20:58:35 +0200 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2020-06-28 08:44:11 +0200 |
commit | 07ae5456b1736451c803d9f5fb9f2389a49f7767 (patch) | |
tree | 6b37a5bcbb759a2e113e9033ff1ae2e552bce245 | |
parent | 5d427aefb481259c7ac8152f6d0f840fe0853aff (diff) | |
download | org-mode-07ae5456b1736451c803d9f5fb9f2389a49f7767.tar.gz |
lint: Checking local files in links also include attachments
* lisp/org-lint.el (org-lint-link-to-local-file): Also check
attachment.
-rw-r--r-- | lisp/org-lint.el | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/lisp/org-lint.el b/lisp/org-lint.el index 5c5e642..5200048 100644 --- a/lisp/org-lint.el +++ b/lisp/org-lint.el @@ -567,16 +567,22 @@ Use :header-args: instead" (defun org-lint-link-to-local-file (ast) (org-element-map ast 'link (lambda (l) - (when (equal "file" (org-element-property :type l)) - (let ((file (org-element-property :path l))) - (and (not (file-remote-p file)) - (not (file-exists-p file)) - (list (org-element-property :begin l) - (format (if (org-element-lineage l '(link)) - "Link to non-existent image file \"%s\"\ - in link description" - "Link to non-existent local file \"%s\"") - file)))))))) + (let ((type (org-element-property :type l))) + (pcase type + ((or "attachment" "file") + (let* ((path (org-element-property :path l)) + (file (if (string= type "file") + path + (org-attach-expand path)))) + (and (not (file-remote-p file)) + (not (file-exists-p file)) + (list (org-element-property :begin l) + (format (if (org-element-lineage l '(link)) + "Link to non-existent image file %S \ +in description" + "Link to non-existent local file %S" + file)))))) + (_ nil)))))) (defun org-lint-non-existent-setupfile-parameter (ast) (org-element-map ast 'keyword |