unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "T.V. Raman" <tv.raman.tv@gmail.com>
To: emacs-devel@gnu.org
Cc: tv.raman.tv@gmail.com
Subject: eww.el: Patch to cache the parse tree
Date: Wed, 27 Nov 2013 09:09:05 -0800	[thread overview]
Message-ID: <CADkJX2h8C-sF6DTmpyu4XUPvatmF5mvHosDJOf5aa8Vct6u7gw@mail.gmail.com> (raw)

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 $
-- 

--



             reply	other threads:[~2013-11-27 17:09 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-27 17:09 T.V. Raman [this message]
2013-11-30  1:08 ` eww.el: Patch to cache the parse tree 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CADkJX2h8C-sF6DTmpyu4XUPvatmF5mvHosDJOf5aa8Vct6u7gw@mail.gmail.com \
    --to=tv.raman.tv@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).