From: stardiviner <firstname.lastname@example.org>
To: Ihor Radchenko <email@example.com>
Cc: Bastien <firstname.lastname@example.org>, Org Mode <email@example.com>
Subject: Re: [QUESTION] Re: [PATCH] make org-attach-url download function as an option
Date: Fri, 17 Jul 2020 06:54:35 +0800 [thread overview]
Message-ID: <firstname.lastname@example.org> (raw)
Ihor Radchenko <email@example.com> writes:
> I do not know an answer to your question, but would like to point out
> that make-thread will return immidietealy and all the following code
> will run before the download finishes:
> (run-hook-with-args 'org-attach-after-change-hook attach-dir)
> (cond ((eq org-attach-store-link-p 'attached)...
> At least the hooks and org-attach-tag would expect that the file is
> attached already.
Indeed, as long as org-attach introduced new async actions. Those hooks will
have problem if they requires files is downloading finished. Also `make-thread'
does not have process sentinel. That's also an problem.
Does anyone have better idea?
> stardiviner <firstname.lastname@example.org> writes:
>> I got solution for async org-attach-url now. Use `make-thread` for async
>> downloading is simple.
>> Here is the code prototype, but it has a problem, seems `apply` part code does
>> not really downloading file. I don't know why. Does anybody knows the reason?
>> #+begin_src diff
>> modified 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
>> @@ -503,7 +509,12 @@ (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) (make-thread
>> + (lambda ()
>> + ;; (url-copy-file file attach-file)
>> + ;; FIXME This seems does not really download file. Don't know why.
>> + (apply org-attach-url-function '(file attach-file)))
>> + "org-attach-url downloading")))
>> (run-hook-with-args 'org-attach-after-change-hook attach-dir)
>> (cond ((eq org-attach-store-link-p 'attached)
>> Bastien <email@example.com> writes:
>>> stardiviner <firstname.lastname@example.org> 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 cancel
>>>> 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.
>>>> I hope to make "org-attach-url" download file asynchronously. But function
>>>> org-attach-attach hardcoded this function for 'url method. Here is a patch to
>>>> make it into an option.
>>> (FWIW, I could not find the patch.)
>>> 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)?
>>> Until Emacs has a function to copy a URL's contents asynchronously,
>>> I'd rather not add this functionality in Org.
>> [ 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
[ stardiviner ]
I try to make every word tell the meaning that I want to express.
IRC(freenode): stardiviner, Matrix: stardiviner
next prev parent reply other threads:[~2020-07-16 22:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-29 13:49 [PATCH] make org-attach-url download function as an option stardiviner
2020-05-24 14:01 ` Bastien
2020-05-25 0:12 ` stardiviner
2020-07-15 9:05 ` [QUESTION] " stardiviner
2020-07-16 0:52 ` Ihor Radchenko
2020-07-16 22:54 ` stardiviner [this message]
2020-07-16 23:20 ` Ihor Radchenko
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).