From ee1078d0c7dc5478ae8797f40e7c21a01a38b6d1 Mon Sep 17 00:00:00 2001 From: Nathaniel Nicandro Date: Sat, 26 Jan 2019 16:15:21 -0600 Subject: [PATCH] org-babel-jupyter-cleanup-file-links: Handle links with no directory --- ob-jupyter.el | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ob-jupyter.el b/ob-jupyter.el index df83434..4924a3e 100644 --- a/ob-jupyter.el +++ b/ob-jupyter.el @@ -223,10 +223,13 @@ Do this only if the file exists in ;; This assumes that `jupyter-org-client' only emits bracketed links as ;; images (while (re-search-forward link-re bound t) - (let* ((link-path (org-element-property :path (org-element-context))) - (link-dir (expand-file-name (file-name-directory link-path))) - (resource-dir - (expand-file-name org-babel-jupyter-resource-directory))) + (when-let* ((link-path + (org-element-property :path (org-element-context))) + (link-dir + (when (file-name-directory link-path) + (expand-file-name (file-name-directory link-path)))) + (resource-dir + (expand-file-name org-babel-jupyter-resource-directory))) (when (and (equal link-dir resource-dir) (file-exists-p link-path)) (delete-file link-path))))))))