From: Ralph Schleicher Date: Mon, 12 Apr 2021 08:31:46 +0000 (+0200) Subject: Add command in eww to toggle images X-Git-Tag: emacs-28.0.90~2888 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=9dc28e1fca03b124c53c2f99add3180591896696;p=emacs.git Add command in eww to toggle images * lisp/net/eww.el (eww-toggle-images): New function. (eww-mode-map): Add key binding and menu entry. * lisp/net/shr.el (shr-inhibit-images): Make it customizable. * doc/misc/eww.texi (Basics): Document eww-toggle-images. Fix index entries for shr-use-fonts and shr-use-colors. (Advanced): Document shr-inhibit-images (bug#47705). --- diff --git a/doc/misc/eww.texi b/doc/misc/eww.texi index 6e82a97030e..cc546a92d63 100644 --- a/doc/misc/eww.texi +++ b/doc/misc/eww.texi @@ -124,17 +124,25 @@ which part of the document contains the ``readable'' text, and will only display this part. This usually gets rid of menus and the like. @findex eww-toggle-fonts -@findex shr-use-fonts +@vindex shr-use-fonts @kindex F The @kbd{F} command (@code{eww-toggle-fonts}) toggles whether to use variable-pitch fonts or not. This sets the @code{shr-use-fonts} variable. @findex eww-toggle-colors -@findex shr-use-colors -@kindex F +@vindex shr-use-colors +@kindex M-C The @kbd{M-C} command (@code{eww-toggle-colors}) toggles whether to use HTML-specified colors or not. This sets the @code{shr-use-colors} variable. +@findex eww-toggle-images +@vindex shr-inhibit-images +@kindex M-I +@cindex Image Display + The @kbd{M-I} command (@code{eww-toggle-images}, capital letter i) +toggles whether to display images or not. This also sets the +@code{shr-inhibit-images} variable. + @findex eww-download @vindex eww-download-directory @kindex d @@ -305,6 +313,11 @@ of the width and height. If Emacs supports image scaling (ImageMagick support required) then larger images are scaled down. You can block specific images completely by customizing @code{shr-blocked-images}. +@vindex shr-inhibit-images + You can control image display by customizing +@code{shr-inhibit-images}. If this variable is @code{nil}, display +the ``ALT'' text of images instead. + @vindex shr-color-visible-distance-min @vindex shr-color-visible-luminance-min @cindex Contrast diff --git a/lisp/net/eww.el b/lisp/net/eww.el index 32fe857e65c..eec3ec7ba8b 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -987,6 +987,7 @@ the like." (define-key map "F" 'eww-toggle-fonts) (define-key map "D" 'eww-toggle-paragraph-direction) (define-key map [(meta C)] 'eww-toggle-colors) + (define-key map [(meta I)] 'eww-toggle-images) (define-key map "b" 'eww-add-bookmark) (define-key map "B" 'eww-list-bookmarks) @@ -1015,6 +1016,7 @@ the like." ["List cookies" url-cookie-list t] ["Toggle fonts" eww-toggle-fonts t] ["Toggle colors" eww-toggle-colors t] + ["Toggle images" eww-toggle-images t] ["Character Encoding" eww-set-character-encoding] ["Toggle Paragraph Direction" eww-toggle-paragraph-direction])) map)) @@ -1893,6 +1895,14 @@ If CHARSET is nil then use UTF-8." "off")) (eww-reload)) +(defun eww-toggle-images () + "Toggle whether or not to display images." + (interactive nil eww-mode) + (setq shr-inhibit-images (not shr-inhibit-images)) + (eww-reload) + (message "Images are now %s" + (if shr-inhibit-images "off" "on"))) + ;;; Bookmarks code (defvar eww-bookmarks nil) diff --git a/lisp/net/shr.el b/lisp/net/shr.el index 7c15eb1ca0b..cbdeb65ba8b 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el @@ -183,8 +183,10 @@ temporarily blinks with this face." "Face for elements." :version "27.1") -(defvar shr-inhibit-images nil - "If non-nil, inhibit loading images.") +(defcustom shr-inhibit-images nil + "If non-nil, inhibit loading images." + :version "28.1" + :type 'boolean) (defvar shr-external-rendering-functions nil "Alist of tag/function pairs used to alter how shr renders certain tags.