skeeto / elfeed

An Emacs web feeds client
The Unlicense
1.52k stars 121 forks source link

add elfeed-update-synchronously #338

Open bricewge opened 5 years ago

bricewge commented 5 years ago

It would be useful if elfeed could be updated synchronously. It looks like some of the underlying logic has already been implemented but not yet used: elfeed-curl-retrieve-synchronously.

I know some issue where it's briefly explained how to do it but I can't manage to get it working. I also tried with https://github.com/skeeto/elisp-latch unsuccessfully.

I need this feature because I'm using elfeed to generate an HTML webring (like openring) with emacs --batch, which never populate the DB with feed articles because it's done asynchronously and emacs ends before the async is resolved.

skeeto commented 5 years ago

To fetch in --batch mode, you should be able to do something like this:

(progn (elfeed-update) (while (> (elfeed-queue-count-total) 0) (sleep-for 0.1) (accept-process-output)))

This queues everything up, then waits until they're all done before continuing, making it effectively synchronous. I put the loop in there since, in my test just now, accept-process-output returns immediately even if there is no new process input or output.

bricewge commented 5 years ago

Thank you @skeeto, it works as expected.