[gnus git] branch master updated: m0-7-45-gc2cced8 =3= * eww.el: Start writing a new, tiny web browser. ; * eww.el: Start writing a new, tiny web browser. ; Allow <base> to have contents.
Lars Magne Ingebrigtsen <[email protected]>
| Newsgroups | gmane.emacs.gnus.cvs |
|---|---|
| Message-ID | <[email protected]> |
via c2cced874fe3e2cfb9694d8a43dec8401c9f93da (commit)
via 40f7d4c0497c44af26e277886474ba945a56cc70 (commit)
via 550aadf49faff7e33c4f6790013a81ceb0b52e2a (commit)
from 492a488c523f66af16089368d6177145a3a59b45 (commit)
- Log -----------------------------------------------------------------
commit c2cced874fe3e2cfb9694d8a43dec8401c9f93da
Author: Lars Magne Ingebrigtsen <[email protected]>
Date: Mon Jun 10 11:10:49 2013 +0200
* eww.el: Start writing a new, tiny web browser.
diff --git a/lisp/eww.el b/lisp/eww.el
new file mode 100644
index 0000000..e23e390
--- /dev/null
+++ b/lisp/eww.el
@@ -0,0 +1,119 @@
+;;; eww.el --- Emacs Web Wowser
+
+;; Copyright (C) 2013 Free Software Foundation, Inc.
+
+;; Author: Lars Magne Ingebrigtsen <[email protected]>
+;; Keywords: html
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;; Code:
+
+(eval-when-compile (require 'cl))
+(require 'shr)
+(require 'url)
+(require 'cl-lib)
+
+(defvar eww-current-url nil)
+
+(defun eww (url)
+ "Fetch URL and render the page."
+ (interactive "sUrl: ")
+ (url-retrieve url 'eww-render (list url)))
+
+(defun eww-render (status url)
+ (let* ((headers (eww-parse-headers))
+ (content-type
+ (mail-header-parse-content-type
+ (or (cdr (assoc "content-type" headers))
+ "text/plain")))
+ (charset (intern
+ (downcase
+ (or (cdr (assq 'charset (cdr content-type)))
+ "utf8"))))
+ (data-buffer (current-buffer)))
+ (unwind-protect
+ (cond
+ ((equal (car content-type) "text/html")
+ (eww-display-html charset url))
+ ((string-match "^image/" (car content-type))
+ (eww-display-image))
+ (t
+ (eww-display-raw charset)))
+ (kill-buffer data-buffer))))
+
+(defun eww-parse-headers ()
+ (let ((headers nil))
+ (while (and (not (eobp))
+ (not (eolp)))
+ (when (looking-at "\\([^:]+\\): *\\(.*\\)")
+ (push (cons (downcase (match-string 1))
+ (match-string 2))
+ headers))
+ (forward-line 1))
+ (unless (eobp)
+ (forward-line 1))
+ headers))
+
+(defun eww-display-html (charset url)
+ (unless (eq charset 'utf8)
+ (decode-coding-region (point) (point-max) charset))
+ (let ((document
+ (list
+ 'base (list (cons 'href url))
+ (libxml-parse-html-region (point) (point-max)))))
+ (eww-setup-buffer)
+ (setq eww-current-url url)
+ (shr-insert-document document)
+ (goto-char (point-min))))
+
+(defun eww-display-raw (charset)
+ (let ((data (buffer-substring (point) (point-max))))
+ (eww-setup-buffer)
+ (insert data)
+ (goto-char (point-min))))
+
+(defun eww-display-image ()
+ (let ((data (buffer-substring (point) (point-max))))
+ (eww-setup-buffer)
+ (shr-put-image data nil)
+ (goto-char (point-min))))
+
+(defun eww-setup-buffer ()
+ (pop-to-buffer (get-buffer-create "*eww*"))
+ (erase-buffer)
+ (eww-mode))
+
+(defvar eww-mode-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map "q" 'eww-quit)
+ map))
+
+(defun eww-mode ()
+ "Mode for browsing the web.
+
+\\{eww-mode-map}"
+ (interactive)
+ (setq major-mode 'eww-mode
+ mode-name "eww")
+ (set (make-local-variable 'eww-current-url) 'author)
+ (use-local-map eww-mode-map))
+
+(provide 'eww)
+
+;;; eww.el ends here
commit 40f7d4c0497c44af26e277886474ba945a56cc70
Author: Lars Magne Ingebrigtsen <[email protected]>
Date: Mon Jun 10 11:12:31 2013 +0200
* eww.el: Start writing a new, tiny web browser.
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 81122f1..8064dcd 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,7 @@
+2013-06-10 Lars Magne Ingebrigtsen <[email protected]>
+
+ * eww.el: Start writing a new, tiny web browser.
+
2013-06-10 Albert Krewinkel <[email protected]>
* sieve.el: Put point at beginning of buffer when viewing a script.
commit 550aadf49faff7e33c4f6790013a81ceb0b52e2a
Author: Lars Magne Ingebrigtsen <[email protected]>
Date: Mon Jun 10 10:52:34 2013 +0200
Allow <base> to have contents.
diff --git a/lisp/shr.el b/lisp/shr.el
index 9284da4..6e0aa26 100644
--- a/lisp/shr.el
+++ b/lisp/shr.el
@@ -945,7 +945,8 @@ ones, in case fg and bg are nil."
plist)))
(defun shr-tag-base (cont)
- (setq shr-base (cdr (assq :href cont))))
+ (setq shr-base (cdr (assq :href cont)))
+ (shr-generic cont))
(defun shr-tag-a (cont)
(let ((url (cdr (assq :href cont)))
-----------------------------------------------------------------------
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we listed those
revisions in full, above.
Summary of changes:
lisp/ChangeLog | 4 ++
lisp/eww.el | 119 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
lisp/shr.el | 3 +-
3 files changed, 125 insertions(+), 1 deletions(-)
create mode 100644 lisp/eww.el
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnus Project".
The branch, master has been updated
hooks/post-receive
--
Gnus Project