emacs-devel
[Top][All Lists]
Advanced

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

eww.el: Patch to cache the parse tree


From: T.V. Raman
Subject: eww.el: Patch to cache the parse tree
Date: Fri, 29 Nov 2013 17:08:08 -0800

Following up to myself:

To see how I am leveraging this patch,  see the sections on DOM
Filtering in
http://emacspeak.googlecode.com/svn/trunk/lisp/emacspeak-eww.el


-- 

-- 


On 11/27/13, T.V. Raman <address@hidden> wrote:
> 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 via email to

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