[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: eww

From: Ted Zlatanov
Subject: Re: eww
Date: Mon, 01 Jul 2013 18:48:25 -0400
User-agent: Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.3.50 (gnu/linux)

On Thu, 20 Jun 2013 11:01:47 +0200 Lars Magne Ingebrigtsen <address@hidden> 

LMI> Ted Zlatanov <address@hidden> writes:
>> Let me know if you're planning to implement this or not (so I can do it,
>> if not you).

LMI> Sure, go ahead.  :-)

I'm not sure I understand all the buffer magic eww does, so here's an
attempt to provide `eww-view-source' under `v' (right now it just calls
`debug' on the data).  If I edebug `eww-view-source' it has the right
data, but I think something is getting lost in translation because the
data doesn't show up when I actually hit `v'.

If you or someone else know what I've missed, please let me know.  It's
probably something really simple...


=== modified file 'lisp/net/eww.el'
--- lisp/net/eww.el     2013-06-28 07:54:42 +0000
+++ lisp/net/eww.el     2013-07-01 22:42:27 +0000
@@ -100,6 +100,7 @@
 (defvar eww-home-url nil)
 (defvar eww-start-url nil)
 (defvar eww-contents-url nil)
+(defvar eww-source-code nil)
 (defun eww (url)
@@ -200,11 +201,12 @@
 (defun eww-display-html (charset url)
   (unless (eq charset 'utf8)
     (decode-coding-region (point) (point-max) charset))
-  (let ((document
+  (let ((source-code (buffer-substring (point) (point-max)))
+        (document
          'base (list (cons 'href url))
          (libxml-parse-html-region (point) (point-max)))))
-    (eww-setup-buffer)
+    (eww-setup-buffer source-code)
     (setq eww-current-url url)
     (let ((inhibit-read-only t)
@@ -296,7 +298,7 @@
 (defun eww-display-raw (charset)
   (let ((data (buffer-substring (point) (point-max))))
-    (eww-setup-buffer)
+    (eww-setup-buffer data)
     (let ((inhibit-read-only t))
       (insert data))
     (goto-char (point-min))))
@@ -308,11 +310,12 @@
       (shr-put-image data nil))
     (goto-char (point-min))))
-(defun eww-setup-buffer ()
+(defun eww-setup-buffer (&optional source-code)
   (pop-to-buffer (get-buffer-create "*eww*"))
   (let ((inhibit-read-only t))
+  (set (make-local-variable 'eww-source-code) source-code)
   (unless (eq major-mode 'eww-mode)
@@ -334,6 +337,7 @@
     (define-key map "t" 'eww-top-url)
     (define-key map "&" 'eww-browse-with-external-browser)
     (define-key map "d" 'eww-download)
+    (define-key map "v" 'eww-view-source)
     (define-key map "w" 'eww-copy-page-url)
     (define-key map "C" 'url-cookie-list)
@@ -391,6 +395,13 @@
   (setq eww-history nil)
   (kill-buffer (current-buffer)))
+(defun eww-view-source ()
+  "View the page source code."
+  (interactive)
+  (if eww-source-code
+      (debug eww-source-code)
+    (error "No source code available")))
 (defun eww-back-url ()
   "Go to the previously displayed page."

reply via email to

[Prev in Thread] Current Thread [Next in Thread]