unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* eww.el: Patch to cache the parse tree
@ 2013-11-27 17:09 T.V. Raman
  2013-11-30  1:08 ` T.V. Raman
  2013-12-01 13:12 ` Lars Magne Ingebrigtsen
  0 siblings, 2 replies; 13+ messages in thread
From: T.V. Raman @ 2013-11-27 17:09 UTC (permalink / raw)
  To: emacs-devel; +Cc: tv.raman.tv

Hi,

I'd like  to add some code to eww.el so that the parsed document
is cached ( -- this will enable  functionality such as document
filtering etc (see
http://emacspeak.googlecode.com/svn/trunk/lisp/shr-url.el) for
similar functionality that I originally built using bare shr.

Here is a patch against Master:

git diff master
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index 86e0977..a446a01 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -89,6 +89,9 @@
   :group 'eww)

 (defvar eww-current-url nil)
+(defvar eww-current-dom nil)
+(make-variable-buffer-local 'eww-current-dom)
+
 (defvar eww-current-title ""
   "Title of current page.")
 (defvar eww-history nil)
@@ -208,6 +211,7 @@ word(s) will be searched for via `eww-search-prefix'."
 		  (start end &optional base-url))

 (defun eww-display-html (charset url)
+  (declare (special eww-current-dom))
   (or (fboundp 'libxml-parse-html-region)
       (error "This function requires Emacs to be compiled with libxml2"))
   (unless (eq charset 'utf8)
@@ -219,6 +223,7 @@ word(s) will be searched for via `eww-search-prefix'."
 	  'base (list (cons 'href url))
 	  (libxml-parse-html-region (point) (point-max)))))
     (eww-setup-buffer)
+    (setq eww-current-dom document)
     (let ((inhibit-read-only t)
 	  (after-change-functions nil)
 	  (shr-width nil)
@@ -387,9 +392,11 @@ word(s) will be searched for via `eww-search-prefix'."
   )

 (defun eww-save-history ()
+  (declare (special ew-current-dom))
   (push (list :url eww-current-url
 	      :title eww-current-title
 	      :point (point)
+              :dom eww-current-dom
 	      :text (buffer-string))
 	eww-history))

@@ -427,6 +434,7 @@ word(s) will be searched for via `eww-search-prefix'."
   (let ((inhibit-read-only t))
     (erase-buffer)
     (insert (plist-get elem :text))
+    (setq eww-current-dom (plist-get elem :dom))
     (goto-char (plist-get elem :point))
     (setq eww-current-url (plist-get elem :url)
 	  eww-current-title (plist-get elem :title))))
09:05:43 raman-glaptop net $
-- 

--



^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2013-12-24 20:36 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-27 17:09 eww.el: Patch to cache the parse tree T.V. Raman
2013-11-30  1:08 ` T.V. Raman
2013-12-01 13:12 ` Lars Magne Ingebrigtsen
2013-12-03  3:09   ` T.V. Raman
2013-12-03  3:34   ` T.V. Raman
2013-12-14 16:27     ` Lars Magne Ingebrigtsen
2013-12-16  0:22       ` T.V. Raman
2013-12-16  0:24       ` T.V. Raman
2013-12-24 20:36         ` Lars Ingebrigtsen
2013-12-04 16:46   ` eww: display page source (was: eww.el: Patch to cache the parse tree) Ted Zlatanov
2013-12-05  1:37     ` eww: display page source Lars Magne Ingebrigtsen
2013-12-05 16:06       ` Ted Zlatanov
2013-12-14 16:26         ` Lars Magne Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).