-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
- Loading branch information
0 parents
commit a262c64
Showing
7 changed files
with
933 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
Elfeed goodies | ||
================== | ||
|
||
Various bits and pieces to enhance the [Elfeed][elfeed] user experience. | ||
|
||
![Screenshot #1](data/screenshot-1.png) | ||
![Screenshot #2](data/screenshot-2.png) | ||
|
||
Features | ||
------- | ||
|
||
* An adaptive, powerline-based header for the `*elfeed-search*` buffer: | ||
+ Adapts to the window width, so narrow windows will feature more interesting | ||
information primarily. Most useful with a split-pane setup. | ||
* Split pane setup. | ||
* Easy customisation. | ||
|
||
Getting started | ||
------------ | ||
|
||
```elisp | ||
(require 'elfeed) | ||
(require 'elfeed-goodies) | ||
(elfeed-goodies/setup) | ||
``` | ||
|
||
You can customise some aspects of the package with `M-x customize-group | ||
elfeed-goodies`. | ||
|
||
Copyright & License | ||
------------------------ | ||
|
||
Copyright (c) 2015 Gergely Nagy, released under the terms of the GNU GPLv3+. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
;;; elfeed-goodies-search-powerline.el --- Elfeed goodies: powerlineized search | ||
;; | ||
;; Copyright (c) 2015 Gergely Nagy | ||
;; | ||
;; Author: Gergely Nagy | ||
;; URL: https://github.com/algernon/elfeed-goodies | ||
;; | ||
;; This file is NOT part of GNU Emacs. | ||
;; | ||
;;; License: GPLv3+ | ||
|
||
(require 'elfeed) | ||
(require 'elfeed-goodies) | ||
(require 'powerline) | ||
|
||
(defcustom elfeed-goodies/feed-source-column-width 16 | ||
"Width of the feed source column." | ||
:group 'elfeed-goodies) | ||
|
||
(defcustom elfeed-goodies/tag-column-width 24 | ||
"Width of the tags column." | ||
:group 'elfeed-goodies) | ||
|
||
(defcustom elfeed-goodies/wide-threshold 0.5 | ||
"Minimum width of the window (percent of the frame) to start using the wide layout from." | ||
:group 'elfeed-goodies) | ||
|
||
(defun -pad-string-to (str width) | ||
(format (format "%s%%%ds" str width) "")) | ||
|
||
(defun -elfeed/feed-stats () | ||
(if (and elfeed-search-filter-active elfeed-search-filter-overflowing) | ||
(list 0 0 0) | ||
(cl-loop with feeds = (make-hash-table :test 'equal) | ||
for entry in elfeed-search-entries | ||
for feed = (elfeed-entry-feed entry) | ||
for url = (elfeed-feed-url feed) | ||
count entry into entry-count | ||
count (elfeed-tagged-p 'unread entry) into unread-count | ||
do (puthash url t feeds) | ||
finally | ||
(cl-return | ||
(list unread-count entry-count (hash-table-count feeds)))))) | ||
|
||
(defun -elfeed/queue-stats () | ||
(list (hash-table-count elfeed-db-feeds) | ||
(length url-queue) | ||
(cl-count-if #'url-queue-buffer url-queue))) | ||
|
||
(defun search-header/rhs (separator-left separator-right search-filter stats update) | ||
(list | ||
(funcall separator-right 'mode-line 'powerline-active1) | ||
(powerline-raw (concat " " search-filter) 'powerline-active1 'r) | ||
(funcall separator-right 'powerline-active1 'powerline-active2) | ||
(destructuring-bind (unread entry-count feed-count) stats | ||
(let ((content (format " %d/%d:%d " unread entry-count feed-count))) | ||
(when url-queue | ||
(destructuring-bind (total-feeds queue-length in-progress) (-elfeed/queue-stats) | ||
(setf content (concat content (format " (* %.0f%%%%)" | ||
(* (/ (- total-feeds (+ queue-length | ||
in-progress)) | ||
total-feeds 1.0) 100)))))) | ||
(propertize content | ||
'face 'powerline-active2))) | ||
(funcall separator-right 'powerline-active2 'powerline-active1) | ||
(powerline-raw (concat " " update) 'powerline-active1 'r))) | ||
|
||
(defun search-header/draw-wide (separator-left separator-right search-filter stats db-time) | ||
(let* ((update (format-time-string "%Y-%m-%d %H:%M:%S %z" db-time)) | ||
(lhs (list | ||
(powerline-raw (-pad-string-to "Feed" (- elfeed-goodies/feed-source-column-width 4)) 'powerline-active1 'l) | ||
(funcall separator-left 'powerline-active1 'powerline-active2) | ||
(powerline-raw (-pad-string-to "Tags" (- elfeed-goodies/tag-column-width 6)) 'powerline-active2 'l) | ||
(funcall separator-left 'powerline-active2 'mode-line) | ||
(powerline-raw "Subject" 'mode-line 'l))) | ||
(rhs (search-header/rhs separator-left separator-right search-filter stats update))) | ||
|
||
(concat (powerline-render lhs) | ||
(powerline-fill 'mode-line (powerline-width rhs)) | ||
(powerline-render rhs)))) | ||
|
||
(defun search-header/draw-tight (separator-left separator-right search-filter stats db-time) | ||
(let* ((update (format-time-string "%H:%M:%S" db-time)) | ||
(lhs (list | ||
(powerline-raw "Subject" 'mode-line 'l))) | ||
(rhs (search-header/rhs separator-left separator-right search-filter stats update))) | ||
(concat (powerline-render lhs) | ||
(powerline-fill 'mode-line (powerline-width rhs)) | ||
(powerline-render rhs)))) | ||
|
||
(defun elfeed-goodies/search-header-draw () | ||
"Returns the string to be used as the Elfeed header." | ||
(if (zerop (elfeed-db-last-update)) | ||
(elfeed-search--intro-header) | ||
(let* ((separator-left (intern (format "powerline-%s-%s" | ||
"arrow-fade" | ||
(car powerline-default-separator-dir)))) | ||
(separator-right (intern (format "powerline-%s-%s" | ||
"arrow-fade" | ||
(cdr powerline-default-separator-dir)))) | ||
(db-time (seconds-to-time (elfeed-db-last-update))) | ||
(stats (-elfeed/feed-stats)) | ||
(search-filter (cond | ||
(elfeed-search-filter-active | ||
"") | ||
(elfeed-search-filter | ||
elfeed-search-filter) | ||
("")))) | ||
(if (>= (window-width) (* (frame-width) elfeed-goodies/wide-threshold)) | ||
(search-header/draw-wide separator-left separator-right search-filter stats db-time) | ||
(search-header/draw-tight separator-left separator-right search-filter stats db-time))))) | ||
|
||
(defun elfeed-goodies/entry-line-draw (entry) | ||
"Print ENTRY to the buffer." | ||
|
||
(let* ((title (or (elfeed-meta entry :title) (elfeed-entry-title entry) "")) | ||
(title-faces (elfeed-search--faces (elfeed-entry-tags entry))) | ||
(feed (elfeed-entry-feed entry)) | ||
(feed-title | ||
(when feed | ||
(or (elfeed-meta feed :title) (elfeed-feed-title feed)))) | ||
(tags (mapcar #'symbol-name (elfeed-entry-tags entry))) | ||
(tags-str (concat "[" (mapconcat 'identity tags ",") "]")) | ||
(title-width (- (window-width) elfeed-goodies/feed-source-column-width | ||
elfeed-goodies/tag-column-width 4)) | ||
(title-column (elfeed-format-column | ||
title (elfeed-clamp | ||
elfeed-search-title-min-width | ||
title-width | ||
title-width) | ||
:left)) | ||
(tag-column (elfeed-format-column | ||
tags-str (elfeed-clamp (length tags-str) | ||
elfeed-goodies/tag-column-width | ||
elfeed-goodies/tag-column-width) | ||
:left)) | ||
(feed-column (elfeed-format-column | ||
feed-title (elfeed-clamp elfeed-goodies/feed-source-column-width | ||
elfeed-goodies/feed-source-column-width | ||
elfeed-goodies/feed-source-column-width) | ||
:left))) | ||
|
||
(if (>= (window-width) (* (frame-width) elfeed-goodies/wide-threshold)) | ||
(progn | ||
(insert (propertize feed-column 'face 'elfeed-search-feed-face) " ") | ||
(insert (propertize tag-column 'face 'elfeed-search-tag-face) " ") | ||
(insert (propertize title 'face title-faces 'kbd-help title))) | ||
(insert (propertize title 'face title-faces 'kbd-help title))))) | ||
|
||
(provide 'elfeed-goodies-search-powerline) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
;;; elfeed-goodies-split-pane.el --- Elfeed goodies: split pane support | ||
;; | ||
;; Copyright (c) 2015 Gergely Nagy | ||
;; | ||
;; Author: Gergely Nagy | ||
;; URL: https://github.com/algernon/elfeed-goodies | ||
;; | ||
;; This file is NOT part of GNU Emacs. | ||
;; | ||
;;; License: GPLv3+ | ||
|
||
(require 'elfeed-goodies) | ||
(require 'popwin) | ||
|
||
(defcustom elfeed-goodies/entry-pane-position 'right | ||
"Position of the popup entry pane." | ||
:group 'elfeed-goodies) | ||
|
||
(defcustom elfeed-goodies/entry-pane-size 0.75 | ||
"Size (width or height, depending on position) of the popup entry pane." | ||
:group 'elfeed-goodies) | ||
|
||
(defun elfeed-goodies/switch-pane (buff) | ||
"Display BUFF in a popup window." | ||
(popwin:popup-buffer buff | ||
:position elfeed-goodies/entry-pane-position | ||
:width (when (member elfeed-goodies/entry-pane-position '(left right)) | ||
elfeed-goodies/entry-pane-size) | ||
:height (when (member elfeed-goodies/entry-pane-position '(top bottom)) | ||
elfeed-goodies/entry-pane-size) | ||
:stick t | ||
:dedicated t)) | ||
|
||
(defun elfeed-goodies/delete-pane () | ||
"Delete the *elfeed-entry* split pane." | ||
(interactive) | ||
(let* ((buff (get-buffer "*elfeed-entry*")) | ||
(window (get-buffer-window buff))) | ||
(kill-buffer buff) | ||
(delete-window window))) | ||
|
||
(provide 'elfeed-goodies-split-pane) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
;;; elfeed-goodies.el --- Elfeed goodies | ||
;; | ||
;; Copyright (c) 2015 Gergely Nagy | ||
;; | ||
;; Author: Gergely Nagy | ||
;; URL: https://github.com/algernon/elfeed-goodies | ||
;; | ||
;; This file is NOT part of GNU Emacs. | ||
;; | ||
;;; License: GPLv3+ | ||
|
||
(provide 'elfeed-goodies) | ||
|
||
(require 'elfeed-goodies-search-powerline) | ||
(require 'elfeed-goodies-split-pane) | ||
|
||
(defgroup elfeed-goodies nil | ||
"Customisation group for `elfeed-goodies'." | ||
:group 'comm) | ||
|
||
;;;###autoload | ||
(defun elfeed-goodies/setup () | ||
"Setup Elfeed with extras: | ||
* Adaptive header bar and entries. | ||
* Header bar using powerline. | ||
* Split pane view via popwin." | ||
(interactive) | ||
(setq elfeed-search-header-function #'elfeed-goodies/search-header-draw | ||
elfeed-search-print-entry-function #'elfeed-goodies/entry-line-draw | ||
elfeed-show-entry-switch #'elfeed-goodies/switch-pane | ||
elfeed-show-entry-delete #'elfeed-goodies/delete-pane)) | ||
|