[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 4feeb7570d: Rescale images along with text in eww with `C-x C-+'
From: |
Lars Ingebrigtsen |
Subject: |
master 4feeb7570d: Rescale images along with text in eww with `C-x C-+' |
Date: |
Mon, 26 Sep 2022 07:53:46 -0400 (EDT) |
branch: master
commit 4feeb7570df33ac335049296d62dba5e05031747
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Rescale images along with text in eww with `C-x C-+'
* lisp/net/eww.el (eww--rescale-images): Also rescale images when
using `C-x C-+' etc (bug#58047).
---
lisp/net/eww.el | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index af938e3c19..2a511333de 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -1179,8 +1179,28 @@ the like."
(setq-local bookmark-make-record-function #'eww-bookmark-make-record)
(buffer-disable-undo)
(setq-local shr-url-transformer #'eww--transform-url)
+ ;; Also rescale images when rescaling the text.
+ (add-hook 'text-scale-mode-hook #'eww--rescale-images nil t)
(setq buffer-read-only t))
+(defvar text-scale-mode)
+(defvar text-scale-mode-amount)
+(defun eww--rescale-images ()
+ (let ((scaling (if text-scale-mode
+ (+ 1 (* text-scale-mode-amount 0.1))
+ 1))
+ match)
+ (save-excursion
+ (goto-char (point-min))
+ (while (setq match (text-property-search-forward 'display))
+ (let ((image (prop-match-value match)))
+ (when (imagep image)
+ (unless (image-property image :original-scale)
+ (setf (image-property image :original-scale)
+ (or (image-property image :scale) 1)))
+ (setf (image-property image :scale)
+ (* (image-property image :original-scale) scaling))))))))
+
(defun eww--url-at-point ()
"`thing-at-point' provider function."
(get-text-property (point) 'shr-url))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 4feeb7570d: Rescale images along with text in eww with `C-x C-+',
Lars Ingebrigtsen <=