From 517cea6cb6fbf95ef3cb062591364bb7bda8c251 Mon Sep 17 00:00:00 2001 From: SqrtMinusOne Date: Thu, 31 Mar 2022 19:34:58 +0300 Subject: [PATCH] feat: elfeed-summary-other-window --- README.org | 9 +++++++++ elfeed-summary.el | 37 +++++++++++++++++++++++++++++++++---- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/README.org b/README.org index 04336ed..01f12e9 100644 --- a/README.org +++ b/README.org @@ -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. 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 Also take a look at =M-x customize-group elfeed-summary= for the rest of available options. * Ideas and alternatives diff --git a/elfeed-summary.el b/elfeed-summary.el index 952d2dd..40d433d 100644 --- a/elfeed-summary.el +++ b/elfeed-summary.el @@ -285,6 +285,18 @@ from the summary buffer." :group 'elfeed-summary :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*" "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" "A major mode to display the elfeed summary data." :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) ((group :initform nil))) @@ -706,12 +719,28 @@ FEEDS is a list of instances of `elfeed-feed'." (elfeed-entry-tags entry)))))) (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) "Open the FEED in a elfeed search buffer. FEED is an instance `elfeed-feed'. If SHOW-READ is t, also show read items." - (elfeed) + (elfeed-summary--open-elfeed) (elfeed-search-set-filter (concat elfeed-summary-default-filter @@ -756,7 +785,7 @@ SECTION is an instance of `elfeed-summary-group-section'." (cond (elfeed-summary--search-mark-read (elfeed-summary--mark-read feeds)) - (t (elfeed) + (t (elfeed-summary--open-elfeed) (elfeed-search-set-filter (concat elfeed-summary-default-filter @@ -825,7 +854,7 @@ descent." (alist-get 'faces data))))) (widget-create 'push-button :notify (lambda (widget &rest _) - (elfeed) + (elfeed-summary--open-elfeed) (elfeed-search-set-filter (widget-get widget :filter))) :filter (alist-get :filter search-data)