Slice images in rss entries for easier scrolling
Can be disabled with +rss-enable-sliced-images.
This commit is contained in:
parent
db0ad48e4d
commit
ba674c8744
1 changed files with 23 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue