I'm trying to write the simplest function: send a query to w3m browser and then find a particular place on the webpage:
(defun w3m-define-word (word)
(interactive "sDefine: ")
(progn (w3m-search "Dictionary" word)
(set-window-start nil (search-forward "Search Results"))))
What is wrong here is that w3m-search
does not wait until page reloads and set-window-start
executes on the older page. Then the page reloads and places a cursor at the beginning of the buffer.
(sleep-for ..)
between w3m-search
and set-window-start
helps, but since loading time is arbitrary, it is not very convenient.
How can I rewrite this function, so it would wait until buffer reloads and only then do the rest?