alphapapa / pocket-reader.el

Emacs client for Pocket reading list (getpocket.com)
GNU General Public License v3.0
223 stars 12 forks source link

Add an option to mark elfeed entries as read when added to Pocket. #27

Closed mssdvd closed 3 years ago

alphapapa commented 3 years ago

Thanks, but I'd prefer that you handle this by defining a command in your own config that does this. As is, this PR would add a new defcustom that is unnecessary if Elfeed isn't installed, and if it were moved into the with-eval-after-load form, it would cause a compilation warning due to the variable's not being defined. It would only be a few lines of code in your config.

What do you think? Thanks.

mssdvd commented 3 years ago

I know that an advice is sufficient but I believe most users expect the item to be considered as read since they will read or listen to it later on Pocket.

I added the defcustom for those users that prefer the current behaviour. If you prefer I could remove the variable.

alphapapa commented 3 years ago

I agree, it seems reasonable for that to be the default behavior. It's what I have in this command in my config:

(defun ap/elfeed-add-links-to-pocket ()
    "Add selected entries in Elfeed search buffer to Pocket, with tags, and mark as unstarred and read in Elfeed."
    (interactive)
    (when-let* ((entries (elfeed-search-selected))
                (groups (--group-by (elfeed-entry-tags it) entries)))
      ;; Add each group to Pocket
      (cl-loop with added-urls
               for group in groups
               for tags = (substring-no-properties (s-join "," (mapcar #'symbol-name (remove 'unread (car group)))))
               for links = (--map (elfeed-entry-link it) (cdr group))
               when (pocket-lib-add-urls links :tags tags)
               append links into added-urls
               finally do (message "Added: %s" (s-join ", " added-urls)))
      (apply #'elfeed-untag entries '(unread starred))
      (mapc #'elfeed-search-update-entry entries)))

So if you want to add it directly to the command without the option, I think that's a sensible improvement. Thanks.

mssdvd commented 3 years ago

I like more your solution because it uploads the tags but I would remove only the unread tag from the elfeed db.

alphapapa commented 3 years ago

If you don't mind, please redo this PR as a branch on your repo other than master.

mssdvd commented 3 years ago

I removed the option. I wouldn't add tag uploads as it might clutter the users' feed.