elfeed icon indicating copy to clipboard operation
elfeed copied to clipboard

Customizable news formatting implementation

Open Dr-Dd opened this issue 4 years ago • 1 comments

I was seeing how it's not possible to reformat the news differently of how they have been originally set (e.g. one line per news, date, title, feed-title, tags).

I hacked around a bit in the code for elfeed-search.el and got what i was looking for by reordering elfeed-search-print-entry--default and changing the formatting a bit

    [...] 
    (insert (propertize date 'face 'elfeed-search-date-face) " ")
    (when feed-title
      (insert (propertize feed-title 'face 'elfeed-search-feed-face) " "))
    (when tags
      (insert "(" tags-str ")\n"))
    (insert "  " (propertize title-column 'face title-faces 'kbd-help title))
    ))

this attains the result that i wanted (screenshot below), and could be implemented by parsing a format string as in "%Y-%F-%T\n-%f" for obtaining the same result, settable via defcustom.

image

But there are some bugs: for example, interacting with a title by pressing RET, invoking elfeed-search-show-entry (and in turn elfeed-show-entry from elfeed-show.el) still reads the buffer as if news were formatted line per line. I've tried understanding the logic of the function but right now i'm unable to.

[...] from elfeed-search.el [...]

(defun elfeed-search-show-entry (entry)
  "Display the currently selected item in a buffer."
  (interactive (list (elfeed-search-selected :ignore-region)))
  (require 'elfeed-show)
  (when (elfeed-entry-p entry)
    (elfeed-untag entry 'unread)
    (elfeed-search-update-entry entry)
    (unless elfeed-search-remain-on-entry (forward-line))
    (elfeed-show-entry entry)))

[...] from elfeed-show.el [...]

(defun elfeed-show-entry (entry)
  "Display ENTRY in the current buffer."
  (let ((buff (get-buffer-create (elfeed-show--buffer-name entry))))
    (with-current-buffer buff
      (elfeed-show-mode)
      (setq elfeed-show-entry entry)
      (elfeed-show-refresh))
    (funcall elfeed-show-entry-switch buff)))

I suspect the problem is with elfeed-search-selected which would need some reworking.

I'm checking in to see if you (@skeeto) are interested in pulling an eventual patch for this feature, and if you agree with what i said, even give me some of your suggestions and thoughts on the matter.

Thanks in advance.

Dr-Dd avatar Jun 10 '21 20:06 Dr-Dd

See https://github.com/skeeto/elfeed/pull/366 for some prior art. If that PR were merged, its excerpt function could be used to do something like that. Unfortunately, I guess Chris hasn't had time to review it. Maybe someday.

Also, see https://github.com/skeeto/elfeed/issues/178.

alphapapa avatar Jun 10 '21 20:06 alphapapa