-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggestion: Only redraw search buffer after refresh completes #293
Comments
Yup, this is a known trade-off. I believe the slowdown is actually more
in running a complicated filter over and over rather than rendering.
Having a good time-restricted default filter (e.g. allow for an early
bailout) helps a lot, too. For example, in my default I filter for
entries less than a week old.
I'm fine with having an option that would prevent refiltering and redraw
after a database update if the fetch queue is not empty. Another idea is
to do what live filtering does: when the queue is active, stop filtering
when the window has filled with results (don't bother with results below
the fold). Though this only partially mitigates the issue.
|
That sounds like a good idea to me. Two issues about that:
Should we change the update hooks to call Thanks. |
Thanks. |
Well, my hacky workaround doesn't work very well. In it, I save the search filter to a variable, then set it to The asynchronous nature of Here's the code I'm using: (defvar ap/elfeed-update-complete-hook nil
"Functions called with no arguments when `elfeed-update' is finished.")
(defun ap/elfeed-update-complete-hook (&rest ignore)
"When update queue is empty, run `ap/elfeed-update-complete-hook' functions."
(message "%s: Queue length: %s"
(format-time-string "%c")
(length (if elfeed-use-curl
elfeed-curl-queue
url-queue)))
(unless (if elfeed-use-curl
elfeed-curl-queue
url-queue)
(run-hooks 'ap/elfeed-update-complete-hook)))
(add-hook 'elfeed-update-hooks #'ap/elfeed-update-complete-hook)
;; Show message when feeds are finished updating
(defun ap/elfeed-update-message-completed (&rest _ignore)
"Show message if update queue is empty."
(message "Feeds updated"))
(add-hook 'ap/elfeed-update-complete-hook #'ap/elfeed-update-message-completed)
;; Unset and reset view filter when updating feeds
(defvar ap/elfeed-search-update-filter nil
"The filter when `elfeed-update' is called.")
(defun ap/elfeed-search-update-restore-filter ()
"Restore filter after feeds update."
(when ap/elfeed-search-update-filter
(elfeed-search-set-filter ap/elfeed-search-update-filter)
(setq ap/elfeed-search-update-filter nil)))
(add-hook 'ap/elfeed-update-complete-hook #'ap/elfeed-search-update-restore-filter)
(defun ap/elfeed-search-update-save-filter ()
"Save and change the filter while updating."
(setq ap/elfeed-search-update-filter elfeed-search-filter)
(setq elfeed-search-filter "#0"))
;; NOTE: It would be better if this hook were run before starting the feed updates, but in
;; `elfeed-update', it happens afterward.
(add-hook 'elfeed-update-init-hooks #'ap/elfeed-search-update-save-filter) And here's the log output:
|
Well, I made the workaround a little hackier, but it seems to have worked. When There's probably a potential bug in that, if the var is decremented after its value is checked, the filter wouldn't be restored, so I would need to ensure that the hooks are added in the correct order. This is messy and not ideal, but at least it works around the issue for me. I can update all of my feeds, the search buffer is only redrawn once, so it only takes a few seconds instead of a few minutes. And it won't take longer and longer the more feeds I add. :) Here's the complete code (similar to the above, but with the new parts): (defvar ap/elfeed-update-complete-hook nil
"Functions called with no arguments when `elfeed-update' is finished.")
(defvar ap/elfeed-updates-in-progress 0
"Number of feed updates in-progress.")
(defvar ap/elfeed-search-update-filter nil
"The filter when `elfeed-update' is called.")
(defun ap/elfeed-update-complete-hook (&rest ignore)
"When update queue is empty, run `ap/elfeed-update-complete-hook' functions."
(when (= 0 ap/elfeed-updates-in-progress)
(run-hooks 'ap/elfeed-update-complete-hook)))
(add-hook 'elfeed-update-hooks #'ap/elfeed-update-complete-hook)
(defun ap/elfeed-update-message-completed (&rest _ignore)
(message "Feeds updated"))
(add-hook 'ap/elfeed-update-complete-hook #'ap/elfeed-update-message-completed)
(defun ap/elfeed-search-update-restore-filter (&rest ignore)
"Restore filter after feeds update."
(when ap/elfeed-search-update-filter
(elfeed-search-set-filter ap/elfeed-search-update-filter)
(setq ap/elfeed-search-update-filter nil)))
(add-hook 'ap/elfeed-update-complete-hook #'ap/elfeed-search-update-restore-filter)
(defun ap/elfeed-search-update-save-filter (&rest ignore)
"Save and change the filter while updating."
(setq ap/elfeed-search-update-filter elfeed-search-filter)
(setq elfeed-search-filter "#0"))
;; NOTE: It would be better if this hook were run before starting the feed updates, but in
;; `elfeed-update', it happens afterward.
(add-hook 'elfeed-update-init-hooks #'ap/elfeed-search-update-save-filter)
(defun ap/elfeed-update-counter-inc (&rest ignore)
(cl-incf ap/elfeed-updates-in-progress))
(advice-add #'elfeed-update-feed :before #'ap/elfeed-update-counter-inc)
(defun ap/elfeed-update-counter-dec (&rest ignore)
(cl-decf ap/elfeed-updates-in-progress)
(when (< ap/elfeed-updates-in-progress 0)
;; Just in case
(setq ap/elfeed-updates-in-progress 0)))
(add-hook 'elfeed-update-hooks #'ap/elfeed-update-counter-dec) |
Hi Chris,
I've noticed that doing a full refresh of all feeds seems to complete much faster if I use a search filter that doesn't match any entries (e.g.
=asdf
, which matches no feeds). If I use my default filter, it is much, much slower, I'm guessing because it's redrawing the entries after each feed is updated.Would it make sense to have an option to only redraw the search buffer after all feeds have been updated?
The text was updated successfully, but these errors were encountered: