From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id OM3aGnwNy15DAQAA0tVLHw (envelope-from ) for ; Mon, 25 May 2020 00:12:44 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id OC+5FnwNy16kKAAA1q6Kng (envelope-from ) for ; Mon, 25 May 2020 00:12:44 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id A70129403EA for ; Mon, 25 May 2020 00:12:43 +0000 (UTC) Received: from localhost ([::1]:51252 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jd0jR-0002TA-K7 for larch@yhetil.org; Sun, 24 May 2020 20:12:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59538) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jd0j7-0002Sq-E0 for emacs-orgmode@gnu.org; Sun, 24 May 2020 20:12:21 -0400 Received: from [183.249.132.153] (port=1783 helo=localhost) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jd0j5-00052O-Oi; Sun, 24 May 2020 20:12:21 -0400 Received: by localhost (Postfix, from userid 1000) id 7FA8C241A15; Mon, 25 May 2020 08:12:10 +0800 (HKT) References: <87zhaupfl6.fsf@gmail.com> <87pnatl9ek.fsf@bzg.fr> User-agent: mu4e 1.4; emacs 28.0.50 From: stardiviner To: Bastien Subject: Re: [PATCH] make org-attach-url download function as an option In-reply-to: <87pnatl9ek.fsf@bzg.fr> Date: Mon, 25 May 2020 08:12:10 +0800 Message-ID: <87367ohnz9.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-Host-Lookup-Failed: Reverse DNS lookup failed for 183.249.132.153 (deferred) Received-SPF: softfail client-ip=183.249.132.153; envelope-from=numbchild@gmail.com; helo=localhost X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/24 20:12:11 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: 53 X-Spam_score: 5.3 X-Spam_bar: +++++ X-Spam_report: (5.3 / 5.0 requ) BAYES_00=-1.9, DKIM_ADSP_CUSTOM_MED=0.001, FORGED_GMAIL_RCVD=1, FREEMAIL_FROM=0.001, FSL_HELO_NON_FQDN_1=0.001, HELO_LOCALHOST=3.828, NML_ADSP_CUSTOM_MED=0.9, RDNS_NONE=0.793, SPF_SOFTFAIL=0.665, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: reject X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: numbchild@gmail.com Cc: Org Mode Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: -0.51 X-TUID: sNAXlQtSBmys --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Bastien writes: > Hi, > > stardiviner writes: > >> I found when network is bad and slow, or the download file is big, the >> org-attach-url will suspend Emacs for a long time. User might have to ca= ncel >> downloading, and start again later. > > Indeed, this might be annoying. At the same time, it is not > unreasonable to expect the user to know what size is the contents he > is willing to attach to an Org node. It's not the URL file size problem, sometime network is bad. I meet some situations like downloading 1M file might use 5 minutes. Not 1M file or 1G = file difference. > >> I hope to make "org-attach-url" download file asynchronously. But functi= on >> org-attach-attach hardcoded this function for 'url method. Here is a pat= ch to >> make it into an option. > > (FWIW, I could not find the patch.) Aha, I forgot the patch. I attached now. The patch does not provide an async function to download. Just provide an easy way for user to use other async functions. > > I think you are on the right track when trying to enhance the 'url > package. Maybe url-copy-file should be asynchronous and url could > provide url-copy-file-synchronously (to mimic the url-retrieve and > url-retrieve-synchronously pair)? Actually I did check out url-copy-file-synchronously source code, try to mi= mic an async version function. But seems I can't implement it. I will post an e= mail to Emacs-dev mailing list whether this can be improved. > > Until Emacs has a function to copy a URL's contents asynchronously, > I'd rather not add this functionality in Org. Emacs async functionality is always bad. Waiting for Emacs get better async support might need a very long time. I still think simply provide an simple entry for user to change downloading function is a simpler option. WDYT? =2D-=20 [ stardiviner ] I try to make every word tell the meaning that I want to express. Blog: https://stardiviner.github.io/ IRC(freenode): stardiviner, Matrix: stardiviner GPG: F09F650D7D674819892591401B5DF1C95AE89AC3 =20=20=20=20=20=20 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-lisp-org-attach.el-support-custom-url-file-downloadi.patch Content-Transfer-Encoding: quoted-printable From=2061e26e148e68deb03f26dddb2a88beae5b6869f7 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. =2D-- 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 =2D-- 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))) =20 +(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 meth= od) ((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)) =2D ((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) =2D-=20 2.26.2 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQFIBAEBCAAyFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAl7LDVoUHG51bWJjaGls ZEBnbWFpbC5jb20ACgkQG13xyVromsPORwgAhKXxOd5veTWi0nsqyQHhETvjNT1s gJPaHC/OBCg68/27U7U+EHvtrEc2qSXisX3bUmMJuxc2fK6jm+7VJbACOJb18YFb 5NQcqYqOmvl5ao/S5DcVMX9aZVBfipYKczOH2zZz74OrC/lHY7u9QtwJ9leby799 H9/l3v2feTEIoA3dU97d7Q06g5l8GrC6WmPoy1kbc1kT8m6exd9d3iQ4su1b0pKL 2P7sUkfAzMjqHhmcbEXzAbTTFR8Sla/7aW3vu1t+rQHyESd4FhhzaASFJjH96Scm WZ/UJb8jFa57eUVmx0jOyhND7V7BewvSjqfkKqDC1Fcg9lNXADclnthNIQ== =VZ+r -----END PGP SIGNATURE----- --==-=-=--