Add a hook to be run after eww has rendered a page

* net/eww.el (eww-after-render-hook): New variable.
(eww-render): Use it.
This commit is contained in:
Lars Magne Ingebrigtsen 2014-11-13 22:41:55 +01:00
parent f7a192cb5c
commit 790ad0171d
5 changed files with 23 additions and 1 deletions

View file

@ -1,3 +1,7 @@
2014-11-13 Lars Magne Ingebrigtsen <larsi@gnus.org>
* eww.texi (Variable Index): Mention `eww-after-render-hook'.
2014-11-10 Lars Magne Ingebrigtsen <larsi@gnus.org>
* eww.texi (Basics): Document `eww-readable'.

View file

@ -235,6 +235,11 @@ developers started contributing to it as well.
@node Variable Index
@unnumbered Variable Index
@vindex eww-after-render-hook
After eww has rendered the data in the buffer,
@code{eww-after-render-hook} is called. It can be used to alter the
contents, for instance.
@printindex vr
@node Lisp Function Index

View file

@ -156,6 +156,9 @@ the like off the page.
*** You can now use several eww buffers in parallel by renaming eww
buffers you want to keep separate.
*** `eww-after-render-hook' is now called after eww has rendered
the data in the buffer.
** Message mode
*** text/html messages that contain inline image parts will be

View file

@ -1,5 +1,8 @@
2014-11-13 Lars Magne Ingebrigtsen <larsi@gnus.org>
* net/eww.el (eww-after-render-hook): New variable.
(eww-render): Use it.
* net/shr.el (shr-descend): Don't descend further than
`max-specpdl-size' allows (bug#16587).
(shr-depth): New variable.

View file

@ -73,6 +73,12 @@
:type '(choice (const :tag "Never" nil)
regexp))
(defcustom eww-after-render-hook nil
"A hook called after eww has finished rendering the buffer."
:version "25.1"
:group 'eww
:type 'hook)
(defcustom eww-form-checkbox-selected-symbol "[X]"
"Symbol used to represent a selected checkbox.
See also `eww-form-checkbox-symbol'."
@ -227,7 +233,8 @@ word(s) will be searched for via `eww-search-prefix'."
(eww-display-raw buffer)
(eww-update-header-line-format)))
(plist-put eww-data :title url)
(setq eww-history-position 0))
(setq eww-history-position 0)
(run-hooks 'eww-after-render-hook))
(kill-buffer data-buffer))))
(defun eww-parse-headers ()