aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorLars Ingebrigtsen2015-12-25 18:50:43 +0100
committerLars Ingebrigtsen2015-12-25 18:50:43 +0100
commit6d124eef1c940b251277b3eed6dd55eb7565d97e (patch)
tree69abd5bc146b2a6b404d12979f7e9cf994510e54 /lisp
parentbdaff9c813973c31dfe1cd357b0f5099ccd0b883 (diff)
downloademacs-6d124eef1c940b251277b3eed6dd55eb7565d97e.tar.gz
emacs-6d124eef1c940b251277b3eed6dd55eb7565d97e.zip
Allow toggling colors in eww
* doc/misc/eww.texi (Basics): Mention "C". * lisp/net/eww.el (eww-toggle-colors): New command and keystroke. * lisp/net/shr.el (shr-use-colors): New variable. (shr-colorize-region): Use it.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/net/eww.el12
-rw-r--r--lisp/net/shr.el10
2 files changed, 21 insertions, 1 deletions
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index 742e1e4d1c0..0bd60367f65 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -681,6 +681,7 @@ the like."
681 (define-key map "E" 'eww-set-character-encoding) 681 (define-key map "E" 'eww-set-character-encoding)
682 (define-key map "S" 'eww-list-buffers) 682 (define-key map "S" 'eww-list-buffers)
683 (define-key map "F" 'eww-toggle-fonts) 683 (define-key map "F" 'eww-toggle-fonts)
684 (define-key map [(meta C)] 'eww-toggle-fonts)
684 685
685 (define-key map "b" 'eww-add-bookmark) 686 (define-key map "b" 'eww-add-bookmark)
686 (define-key map "B" 'eww-list-bookmarks) 687 (define-key map "B" 'eww-list-bookmarks)
@@ -705,6 +706,8 @@ the like."
705 ["Add bookmark" eww-add-bookmark t] 706 ["Add bookmark" eww-add-bookmark t]
706 ["List bookmarks" eww-list-bookmarks t] 707 ["List bookmarks" eww-list-bookmarks t]
707 ["List cookies" url-cookie-list t] 708 ["List cookies" url-cookie-list t]
709 ["Toggle fonts" eww-toggle-fonts t]
710 ["Toggle colors" eww-toggle-colors t]
708 ["Character Encoding" eww-set-character-encoding])) 711 ["Character Encoding" eww-set-character-encoding]))
709 map)) 712 map))
710 713
@@ -1495,6 +1498,15 @@ If CHARSET is nil then use UTF-8."
1495 "off")) 1498 "off"))
1496 (eww-reload)) 1499 (eww-reload))
1497 1500
1501(defun eww-toggle-colors ()
1502 "Toggle whether to use HTML-specified colors or not."
1503 (interactive)
1504 (message "Colors are now %s"
1505 (if (setq shr-use-colors (not shr-use-colors))
1506 "on"
1507 "off"))
1508 (eww-reload))
1509
1498;;; Bookmarks code 1510;;; Bookmarks code
1499 1511
1500(defvar eww-bookmarks nil) 1512(defvar eww-bookmarks nil)
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index a7fdf9e1181..3d5f02c359b 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -63,6 +63,12 @@ fit these criteria."
63 :group 'shr 63 :group 'shr
64 :type 'boolean) 64 :type 'boolean)
65 65
66(defcustom shr-use-colors t
67 "If non-nil, respect color specifications in the HTML."
68 :version "25.2"
69 :group 'shr
70 :type 'boolean)
71
66(defcustom shr-table-horizontal-line nil 72(defcustom shr-table-horizontal-line nil
67 "Character used to draw horizontal table lines. 73 "Character used to draw horizontal table lines.
68If nil, don't draw horizontal table lines." 74If nil, don't draw horizontal table lines."
@@ -1082,7 +1088,9 @@ ones, in case fg and bg are nil."
1082 (shr-color-visible bg fg))))))) 1088 (shr-color-visible bg fg)))))))
1083 1089
1084(defun shr-colorize-region (start end fg &optional bg) 1090(defun shr-colorize-region (start end fg &optional bg)
1085 (when (and (or fg bg) (>= (display-color-cells) 88)) 1091 (when (and shr-use-colors
1092 (or fg bg)
1093 (>= (display-color-cells) 88))
1086 (let ((new-colors (shr-color-check fg bg))) 1094 (let ((new-colors (shr-color-check fg bg)))
1087 (when new-colors 1095 (when new-colors
1088 (when fg 1096 (when fg