1

In my elisp code, I am trying to use (eww url) to open a page. How can I know that the page loaded? I need to process the eww buffer.

Emacs 24.4

BinaryButterfly
  • 18,137
  • 13
  • 50
  • 91
Enze Chi
  • 1,733
  • 17
  • 28

1 Answers1

2

Unfortunately, eww doesn't appear to call a hook after it finishes rendering a page, so you'll need to hook into eww at a lower level:

(defun eww-render-and-do-stuff (status url &optional point)
  (eww-render status url point)
  (do-stuff))

(let ((url "http://emacs.stackexchange.com"))
  (url-retrieve url 'eww-render-and-do-stuff (list url)))
jch
  • 5,382
  • 22
  • 41
  • thanks for your answer. It works for me. But I have some questions about your answer. I tried to replace "eww-render-and-do-stuff" with "eww-render" and put the real do stuff code after "url-retrieve", it doesn't work as expected. So my question is what's different between use eww-render-and-do-stuff function and inline code directly? – Enze Chi Oct 30 '14 at 22:01
  • See `C-h f url-retrieve` and the `CALLBACK` argument. – phils Oct 30 '14 at 22:14
  • @EnzoChi, `url-retrieve` runs asynchronously — it may return before the page has finished downloading, and let the download continue in the background. If you put `do-stuff` after `url-retrieve`, it will probably run before the download is finished, and, due to limitations in the Emacs Lisp engine, probably prevent the download from completing. – jch Nov 01 '14 at 18:34