feat: elfeed-summary-other-window

This commit is contained in:
Pavel Korytov 2022-03-31 19:34:58 +03:00
parent 2f351bed59
commit 517cea6cb6
2 changed files with 42 additions and 4 deletions

View file

@ -157,6 +157,15 @@ Faces for groups by default use the =elfeed-summary-group-faces= variable, which
Faces for feeds by default reuse [[https://github.com/skeeto/elfeed#custom-tag-faces][the existing elfeed mechanism]]. The tags for feeds are taken from the =elfeed-feeds= variable; if a feed has at least one unread entry, the unread tag is added to the list. This can be overridden by setting the =elfeed-summary-feed-face-fn= variable. Faces for feeds by default reuse [[https://github.com/skeeto/elfeed#custom-tag-faces][the existing elfeed mechanism]]. The tags for feeds are taken from the =elfeed-feeds= variable; if a feed has at least one unread entry, the unread tag is added to the list. This can be overridden by setting the =elfeed-summary-feed-face-fn= variable.
Searches are mostly the same as feeds, but tags for the search are taken from the =:tags= attribute. This also can be overridden with =elfeed-summary-search-face-fn= variable. Searches are mostly the same as feeds, but tags for the search are taken from the =:tags= attribute. This also can be overridden with =elfeed-summary-search-face-fn= variable.
** Opening =elfeed-search= in other window
If you set:
#+begin_src emacs-lisp
(setq elfeed-summary-other-window t)
#+end_src
Then =RET= and =M-RET= in the =elfeed-summary= buffer will open the search buffer in other window.
=elfeed-summary-width= regulates the width of the remaining summary window in this case. It is useful because the data in the search buffer is generally wider than in the summary buffer. The variable can also be set to =nil= to disable this behavior.
** Other options ** Other options
Also take a look at =M-x customize-group elfeed-summary= for the rest of available options. Also take a look at =M-x customize-group elfeed-summary= for the rest of available options.
* Ideas and alternatives * Ideas and alternatives

View file

@ -285,6 +285,18 @@ from the summary buffer."
:group 'elfeed-summary :group 'elfeed-summary
:type '(repeat face)) :type '(repeat face))
(defcustom elfeed-summary-other-window nil
"Whether to open the elfeed-search buffer in other window."
:group 'elfeed-summary
:type 'boolean)
(defcustom elfeed-summary-width 55
"Width of the summary buffer when opening the search buffer.
Useful only if `elfeed-summary-other-window' is set to t."
:group 'elfeed-summary
:type 'integer)
(defconst elfeed-summary-buffer "*elfeed-summary*" (defconst elfeed-summary-buffer "*elfeed-summary*"
"Elfeed summary buffer name.") "Elfeed summary buffer name.")
@ -649,7 +661,8 @@ The return value is a list of alists of the following elements:
(define-derived-mode elfeed-summary-mode magit-section "Elfeed Summary" (define-derived-mode elfeed-summary-mode magit-section "Elfeed Summary"
"A major mode to display the elfeed summary data." "A major mode to display the elfeed summary data."
:group 'org-journal-tags :group 'org-journal-tags
(setq-local buffer-read-only t)) (setq-local buffer-read-only t)
(setq-local truncate-lines t))
(defclass elfeed-summary-group-section (magit-section) (defclass elfeed-summary-group-section (magit-section)
((group :initform nil))) ((group :initform nil)))
@ -706,12 +719,28 @@ FEEDS is a list of instances of `elfeed-feed'."
(elfeed-entry-tags entry)))))) (elfeed-entry-tags entry))))))
(elfeed-summary--refresh))) (elfeed-summary--refresh)))
(defun elfeed-summary--open-elfeed ()
"Open elfeed.
If `elfeed-summary-other-window' is t, open elfeed in other window."
(if elfeed-summary-other-window
(let ((window (selected-window)))
(switch-to-buffer-other-window (elfeed-search-buffer))
(when elfeed-summary-width
(with-selected-window window
(enlarge-window (- elfeed-summary-width
(window-width))
t))))
(switch-to-buffer (elfeed-search-buffer)))
(unless (eq major-mode 'elfeed-search-mode)
(elfeed-search-mode)))
(defun elfeed-summary--goto-feed (feed show-read) (defun elfeed-summary--goto-feed (feed show-read)
"Open the FEED in a elfeed search buffer. "Open the FEED in a elfeed search buffer.
FEED is an instance `elfeed-feed'. If SHOW-READ is t, also show read FEED is an instance `elfeed-feed'. If SHOW-READ is t, also show read
items." items."
(elfeed) (elfeed-summary--open-elfeed)
(elfeed-search-set-filter (elfeed-search-set-filter
(concat (concat
elfeed-summary-default-filter elfeed-summary-default-filter
@ -756,7 +785,7 @@ SECTION is an instance of `elfeed-summary-group-section'."
(cond (cond
(elfeed-summary--search-mark-read (elfeed-summary--search-mark-read
(elfeed-summary--mark-read feeds)) (elfeed-summary--mark-read feeds))
(t (elfeed) (t (elfeed-summary--open-elfeed)
(elfeed-search-set-filter (elfeed-search-set-filter
(concat (concat
elfeed-summary-default-filter elfeed-summary-default-filter
@ -825,7 +854,7 @@ descent."
(alist-get 'faces data))))) (alist-get 'faces data)))))
(widget-create 'push-button (widget-create 'push-button
:notify (lambda (widget &rest _) :notify (lambda (widget &rest _)
(elfeed) (elfeed-summary--open-elfeed)
(elfeed-search-set-filter (elfeed-search-set-filter
(widget-get widget :filter))) (widget-get widget :filter)))
:filter (alist-get :filter search-data) :filter (alist-get :filter search-data)