summaryrefslogtreecommitdiff
path: root/lisp/net/eww.el
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2022-09-26 13:53:10 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2022-09-26 13:53:10 +0200
commit4feeb7570df33ac335049296d62dba5e05031747 (patch)
treed44ecadde7fb2dd773956dd6aa6b23fbd39bc3cc /lisp/net/eww.el
parente2f2f6b9e869e8cf2714b35d5645fbbbcf2975de (diff)
downloademacs-4feeb7570df33ac335049296d62dba5e05031747.tar.gz
emacs-4feeb7570df33ac335049296d62dba5e05031747.tar.bz2
emacs-4feeb7570df33ac335049296d62dba5e05031747.zip
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).
Diffstat (limited to 'lisp/net/eww.el')
-rw-r--r--lisp/net/eww.el20
1 files changed, 20 insertions, 0 deletions
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index af938e3c192..2a511333de1 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))