From 61e26e148e68deb03f26dddb2a88beae5b6869f7 Mon Sep 17 00:00:00 2001 From: stardiviner Date: Wed, 29 Apr 2020 21:38:34 +0800 Subject: [PATCH] lisp/org-attach.el: support custom url file downloading function lisp/org-attach.el (org-attach-url-function): make download function as a defcustom option. So that user can use async function or other functions instead. --- lisp/org-attach.el | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lisp/org-attach.el b/lisp/org-attach.el index 57d1360fc..e33551f40 100644 --- a/lisp/org-attach.el +++ b/lisp/org-attach.el @@ -110,6 +110,12 @@ (defcustom org-attach-method 'cp (const :tag "Hard Link" ln) (const :tag "Symbol Link" lns))) +(defcustom org-attach-url-function 'url-copy-file + "The download file function to use in org-attach-url." + :type '(choice (const 'url-copy-file)) + :safe #'functionp + :group 'org-attach) + (defcustom org-attach-expert nil "Non-nil means do not show the splash buffer with the attach dispatcher." :group 'org-attach @@ -504,7 +510,7 @@ (defun org-attach-attach (file &optional visit-dir method) ((eq method 'cp) (copy-file file attach-file)) ((eq method 'ln) (add-name-to-file file attach-file)) ((eq method 'lns) (make-symbolic-link file attach-file)) - ((eq method 'url) (url-copy-file file attach-file))) + ((eq method 'url) (apply org-attach-url-function file (list attach-file)))) (run-hook-with-args 'org-attach-after-change-hook attach-dir) (org-attach-tag) (cond ((eq org-attach-store-link-p 'attached) -- 2.26.2