elfeed icon indicating copy to clipboard operation
elfeed copied to clipboard

Perhaps TAB could expand an item immediately

Open kootenpv opened this issue 9 years ago • 9 comments

I imagined this flow where we have the tree view and hitting "tab" on a feeditem will just expand the current item inline. It would avoid opening a new buffer, and would give a really nicely integrated feeling. What do you think?

kootenpv avatar Oct 10 '16 20:10 kootenpv

This is an interesting idea. I implemented a similar feature in pocket-reader's excerpt feature. I think it could work here too.

alphapapa avatar Jun 16 '18 23:06 alphapapa

I've implemented this in my config as "excerpts". Here's a screenshot and the code I use: out

(defmacro ap/elfeed-search-at-entry (entry &rest body)
  "Eval BODY with point at ENTRY."
  (declare (indent defun))
  `(when-let* ((n (cl-position ,entry elfeed-search-entries)))
     (elfeed-goto-line (+ elfeed-search--offset n))
     ,@body))

(defun ap/elfeed-search-excerpt-toggle-selected ()
  "Toggle excerpts on selected entries."
  (interactive)
  (--each (elfeed-search-selected)
    (ap/elfeed-search-at-entry it
      (ap/elfeed-excerpt-toggle))))

(defun ap/elfeed-excerpt-toggle ()
  (interactive)
  (or (ap/elfeed-excerpt-hide)
      (ap/elfeed-excerpt-insert)))

(defun ap/elfeed-excerpt-hide ()
  (interactive)
  (when-let ((pos (1+ (line-end-position)))
             (overlay (car (ov-in 'type 'excerpt pos pos))))
    (delete-overlay overlay)
    t))

(defun ap/elfeed-wrap-string (string length)
  "Wrap STRING to LENGTH."
  (if (<= (length string) length)
      string
    (s-trim (with-temp-buffer
              (insert string)
              (let ((fill-column length))
                (fill-region (point-min) (point-max))
                (buffer-string))))))

(defun ap/elfeed-excerpt-insert ()
  "Show excerpt of current entry."
  (interactive)
  (let* ((pos (1+ (line-end-position)))
         (width (window-text-width))
         (entry (elfeed-search-selected 'ignore-region))
         (ref (elfeed-entry-content entry))
         (excerpt (--> (elfeed-deref ref)
                       (with-temp-buffer
                         (elfeed-insert-html it)
                         (buffer-string))
                       (ap/elfeed-wrap-string it width)
                       (concat it "\n")
                       (propertize it 'face '(:inherit default :family "Libre Baskerville")))))
    (ov pos pos
        'type 'excerpt
        'after-string excerpt)
    (elfeed-untag entry 'unread)
    (elfeed-search-update-entry entry)))

alphapapa avatar Aug 28 '18 00:08 alphapapa

I'm still using this feature and enjoying it. elfeed-excerpts

@skeeto Would you be interested in a PR for this feature? (It isn't, or needn't be, specific to my customized display code.)

alphapapa avatar Feb 10 '20 15:02 alphapapa

Sure, I'll accept something like this, though I have caveats and a question:

  • Emacs 24.3 compatibility is still a goal since it's so easy to support, so you'd have to give up some newer things like when-let.

  • No third-party dependencies, so those uses of dash and s will need to be replaced with built-in functionality.

  • Does this play well with elfeed-search-selected and friends? It's always been pretty hacky the way it maps the entries list to lines, and I'd be fine with improving that mapping in order to support features like this.

skeeto avatar Feb 12 '20 00:02 skeeto

  • No third-party dependencies, so those uses of dash and s will need to be replaced with built-in functionality.

Sure, that's no problem.

  • Does this play well with elfeed-search-selected and friends?

As far as elfeed-search-selected, yes: if you select multiple entries with the region (i.e. C-SPC C-n), then all entries in the region have their excerpts displayed. (I also have some more specific functionality that displays excerpts for similar entries around point, like ones with the same tags, but I'm not necessarily proposing to include that.)

I'm not sure what you're referring to by "and friends," so I can't say about that. :)

It's always been pretty hacky the way it maps the entries list to lines, and I'd be fine with improving that mapping in order to support features like this.

Yeah, it does feel a little awkward. Here's a macro I use to make it easier, and a function that uses it:

(defmacro ap/elfeed-search-at-entry (entry &rest body)
  "Eval BODY with point at ENTRY."
  (declare (indent defun))
  `(when-let* ((n (cl-position ,entry elfeed-search-entries)))
     (elfeed-goto-line (+ elfeed-search--offset n))
     ,@body))

(defun ap/elfeed-search-excerpt-toggle-selected (&optional hide-all)
  "Toggle excerpts on selected entries.
With prefix, hide all excerpts."
  (interactive (list current-prefix-arg))
  (if hide-all
      (ov-clear 'type 'excerpt)
    (--each (elfeed-search-selected)
      (ap/elfeed-search-at-entry it
        (ap/elfeed-search-excerpt-toggle)))))
  • Emacs 24.3 compatibility is still a goal since it's so easy to support, so you'd have to give up some newer things like when-let.

This is where you get me, though. You know how I love using the newer macros! :) Emacs 24.3 is almost 7 years old now. Are there any distros still using it? But I won't try too hard to talk you out of it.

alphapapa avatar Feb 12 '20 01:02 alphapapa

PR: #366.

alphapapa avatar Feb 15 '20 04:02 alphapapa

"Sure, I'll accept something like this" doesn't sound too appreciative for getting someone to implement a rather big feature. I know I'd be pretty stoked.

kootenpv avatar Feb 16 '20 21:02 kootenpv

It's okay. I know what Chris means.

alphapapa avatar Feb 17 '20 05:02 alphapapa

Really cool feature—feels like it provides the affordances that an org-mode user would expect when viewing a list of items. Would love to see this merged!

ketan0 avatar Nov 03 '20 00:11 ketan0