[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 6d124ee: Allow toggling colors in eww
From: |
Lars Ingebrigtsen |
Subject: |
[Emacs-diffs] master 6d124ee: Allow toggling colors in eww |
Date: |
Fri, 25 Dec 2015 17:50:52 +0000 |
branch: master
commit 6d124eef1c940b251277b3eed6dd55eb7565d97e
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>
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.
---
doc/misc/eww.texi | 6 ++++++
etc/NEWS | 5 +++++
lisp/net/eww.el | 12 ++++++++++++
lisp/net/shr.el | 10 +++++++++-
4 files changed, 32 insertions(+), 1 deletions(-)
diff --git a/doc/misc/eww.texi b/doc/misc/eww.texi
index f1347b7..15cc867 100644
--- a/doc/misc/eww.texi
+++ b/doc/misc/eww.texi
@@ -109,6 +109,12 @@ only display this part. This usually gets rid of menus
and the like.
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.
address@hidden eww-toggle-colors
address@hidden shr-use-colors
address@hidden F
+ The @kbd{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-download
@vindex eww-download-directory
@kindex d
diff --git a/etc/NEWS b/etc/NEWS
index 1ef496c..76fac3e 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -524,6 +524,11 @@ whether to use variable-pitch fonts or not. The user can
also
customize the `shr-use-fonts' variable.
+++
+*** A new command `C' (`eww-toggle-colors) can be used to toggle
+whether to use the HTML-specified colors or not. The user can also
+customize the `shr-use-colors variable.
+
++++
*** A new command `R' (`eww-readable') will try do identify the main
textual parts of a web page and display only that, leaving menus and
the like off the page.
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index 742e1e4..0bd6036 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -681,6 +681,7 @@ the like."
(define-key map "E" 'eww-set-character-encoding)
(define-key map "S" 'eww-list-buffers)
(define-key map "F" 'eww-toggle-fonts)
+ (define-key map [(meta C)] 'eww-toggle-fonts)
(define-key map "b" 'eww-add-bookmark)
(define-key map "B" 'eww-list-bookmarks)
@@ -705,6 +706,8 @@ the like."
["Add bookmark" eww-add-bookmark t]
["List bookmarks" eww-list-bookmarks t]
["List cookies" url-cookie-list t]
+ ["Toggle fonts" eww-toggle-fonts t]
+ ["Toggle colors" eww-toggle-colors t]
["Character Encoding" eww-set-character-encoding]))
map))
@@ -1495,6 +1498,15 @@ If CHARSET is nil then use UTF-8."
"off"))
(eww-reload))
+(defun eww-toggle-colors ()
+ "Toggle whether to use HTML-specified colors or not."
+ (interactive)
+ (message "Colors are now %s"
+ (if (setq shr-use-colors (not shr-use-colors))
+ "on"
+ "off"))
+ (eww-reload))
+
;;; Bookmarks code
(defvar eww-bookmarks nil)
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index a7fdf9e..3d5f02c 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -63,6 +63,12 @@ fit these criteria."
:group 'shr
:type 'boolean)
+(defcustom shr-use-colors t
+ "If non-nil, respect color specifications in the HTML."
+ :version "25.2"
+ :group 'shr
+ :type 'boolean)
+
(defcustom shr-table-horizontal-line nil
"Character used to draw horizontal table lines.
If nil, don't draw horizontal table lines."
@@ -1082,7 +1088,9 @@ ones, in case fg and bg are nil."
(shr-color-visible bg fg)))))))
(defun shr-colorize-region (start end fg &optional bg)
- (when (and (or fg bg) (>= (display-color-cells) 88))
+ (when (and shr-use-colors
+ (or fg bg)
+ (>= (display-color-cells) 88))
(let ((new-colors (shr-color-check fg bg)))
(when new-colors
(when fg
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 6d124ee: Allow toggling colors in eww,
Lars Ingebrigtsen <=