diff options
| author | Lars Ingebrigtsen | 2015-12-25 18:50:43 +0100 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2015-12-25 18:50:43 +0100 |
| commit | 6d124eef1c940b251277b3eed6dd55eb7565d97e (patch) | |
| tree | 69abd5bc146b2a6b404d12979f7e9cf994510e54 | |
| parent | bdaff9c813973c31dfe1cd357b0f5099ccd0b883 (diff) | |
| download | emacs-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.
| -rw-r--r-- | doc/misc/eww.texi | 6 | ||||
| -rw-r--r-- | etc/NEWS | 5 | ||||
| -rw-r--r-- | lisp/net/eww.el | 12 | ||||
| -rw-r--r-- | 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 f1347b7b3bb..15cc867dc7f 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. | |||
| 109 | The @kbd{F} command (@code{eww-toggle-fonts}) toggles whether to use | 109 | The @kbd{F} command (@code{eww-toggle-fonts}) toggles whether to use |
| 110 | variable-pitch fonts or not. This sets the @code{shr-use-fonts} variable. | 110 | variable-pitch fonts or not. This sets the @code{shr-use-fonts} variable. |
| 111 | 111 | ||
| 112 | @findex eww-toggle-colors | ||
| 113 | @findex shr-use-colors | ||
| 114 | @kindex F | ||
| 115 | The @kbd{C} command (@code{eww-toggle-colors}) toggles whether to use | ||
| 116 | HTML-specified colors or not. This sets the @code{shr-use-colors} variable. | ||
| 117 | |||
| 112 | @findex eww-download | 118 | @findex eww-download |
| 113 | @vindex eww-download-directory | 119 | @vindex eww-download-directory |
| 114 | @kindex d | 120 | @kindex d |
| @@ -524,6 +524,11 @@ whether to use variable-pitch fonts or not. The user can also | |||
| 524 | customize the `shr-use-fonts' variable. | 524 | customize the `shr-use-fonts' variable. |
| 525 | 525 | ||
| 526 | +++ | 526 | +++ |
| 527 | *** A new command `C' (`eww-toggle-colors) can be used to toggle | ||
| 528 | whether to use the HTML-specified colors or not. The user can also | ||
| 529 | customize the `shr-use-colors variable. | ||
| 530 | |||
| 531 | +++ | ||
| 527 | *** A new command `R' (`eww-readable') will try do identify the main | 532 | *** A new command `R' (`eww-readable') will try do identify the main |
| 528 | textual parts of a web page and display only that, leaving menus and | 533 | textual parts of a web page and display only that, leaving menus and |
| 529 | the like off the page. | 534 | the like off the page. |
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. |
| 68 | If nil, don't draw horizontal table lines." | 74 | If 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 |