elfeed icon indicating copy to clipboard operation
elfeed copied to clipboard

Be smarter about moving to the next entry after an action

Open groks opened this issue 9 years ago • 3 comments

Add an extension point elfeed-search-next-entry and call it instead of the hard-coded forward-line after performing an action such as tagging/untagging.

Instead of always moving forward, move back if it looks like you're reversing up the search results.

Maybe there's a fancier algorithm?

groks avatar Dec 27 '15 22:12 groks

Interesting, I hadn't expected extension here. I don't object to the idea of putting some kind of configuration here (defcustom, etc.), but I don't want to change the way it currently operates. In particular, the more complex elfeed-search-next-entry added in 941b077 won't advance past the first entry if it's read and the second is unread. By default I'd like to stick to the very obvious and unsurprising current behavior.

As a side note, outside of certain compiler bugs, running the test suite ("make test") should come out totally clean. After the second commit, the compiler complains about the use of next-line and previous-line (for interactive use only).

skeeto avatar Jan 15 '16 20:01 skeeto

I agree with the notion that the defaults should be obvious, but I'd love to have the option to enable this since I very often read a given day's feeds from bottom to top.

porglezomp avatar Oct 23 '16 12:10 porglezomp

This would be useful for me as well, most of the time I read things from the bottom, sometimes marking them as 'read', and it mildly annoyed me to have to manually move the cursor each time.

I fooled around, modifying elfeed-search-untag-all, and the initial draft came up as something like this:

(defun elfeed-search-untag-all (tag)
  "Remove TAG from all selected entries."
  (interactive (list (intern (read-from-minibuffer "Tag: "))))
  (let ((entries (elfeed-search-selected)))
    (elfeed-untag entries tag)
    (mapc #'elfeed-search-update-entry entries)
    (unless elfeed-search-remain-on-entry
      (if (when-let ((nxt-entry
                      (save-mark-and-excursion
                        (when (use-region-p)
                          (goto-char (region-end)))
                        (forward-line)
                        (car (elfeed-search-selected)))))
            (member 'unread (elfeed-entry-tags nxt-entry)))
          (forward-line)
        (progn
          (when (use-region-p) (goto-char (region-beginning)))
          (forward-line -1))))))

And then I found this PR, so ended up simply advising the function:

(defun elfeed-search-untag-all-a (_)
  "Advice to the previous elfeed-entry unless the next one is unread."
  (when-let ((nxt-entry (car (elfeed-search-selected))))
    (unless (member 'unread (elfeed-entry-tags nxt-entry))
      (forward-line -2))))

(advice-add 'elfeed-search-untag-all :after 'elfeed-search-untag-all-a)

I'm not suggesting anything, just posting it here, maybe someone finds it useful.

agzam avatar Nov 18 '22 00:11 agzam