From ba674c8744b3ce21c15e603d5b28ad55fa4c2fa0 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 29 Jun 2018 14:07:29 +0200 Subject: [PATCH] Slice images in rss entries for easier scrolling Can be disabled with +rss-enable-sliced-images. --- modules/app/rss/config.el | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/modules/app/rss/config.el b/modules/app/rss/config.el index 36aaa821a..17334cd61 100644 --- a/modules/app/rss/config.el +++ b/modules/app/rss/config.el @@ -11,6 +11,10 @@ absolute paths.") (defvar +rss-split-direction 'below "What direction to pop up the entry buffer in elfeed.") +(defvar +rss-enable-sliced-images t + "Automatically slice images shown in elfeed-show-mode buffers, making them +easier to scroll through.") + ;; ;; Packages @@ -42,6 +46,25 @@ absolute paths.") (add-hook! 'elfeed-search-mode-hook (add-hook 'kill-buffer-hook #'+rss/quit nil t)) + ;; Large images are annoying to scroll through, because scrolling follows the + ;; cursor, so we force shr to insert images in slices. + (when +rss-enable-sliced-images + (defun +rss-put-image (spec alt &optional flags) + (cl-letf (((symbol-function #'insert-image) + (lambda (image &optional alt _area _slice) + (let ((height (cdr (image-size image t)))) + (insert-sliced-image image alt nil (max 1 (/ height 20.0)) 1))))) + (shr-put-image spec alt flags))) + (defun +rss-render-image-tag (dom &optional url) + (let ((start (point))) + (shr-tag-img dom url) + ;; And remove underlines in case images are links, otherwise we get an + ;; underline beneath every slice. + (put-text-property start (point) 'face '(:underline nil)))) + (setq-hook! 'elfeed-show-mode-hook + shr-put-image-function #'+rss-put-image + shr-external-rendering-functions '((img . +rss-render-image-tag)))) + ;; Keybindings (after! elfeed-show (define-key! elfeed-show-mode-map