1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-26 07:33:47 +00:00

xwidget: Get URL asynchronously.

* lisp/xwidget.el (xwidget-webkit-current-url): Kill URL in callback.
This commit is contained in:
Ricardo Wurmus 2016-10-25 23:00:35 -07:00 committed by Paul Eggert
parent 4aa7c4b4aa
commit 8809002052

View File

@ -474,11 +474,11 @@ For example, use this to display an anchor."
(defun xwidget-webkit-current-url ()
"Get the webkit url and place it on the kill-ring."
(interactive)
(let* ((rv (xwidget-webkit-execute-script-rv (xwidget-webkit-current-session)
"document.URL"))
(url (kill-new (or rv ""))))
(message "url: %s" url)
url))
(xwidget-webkit-execute-script
(xwidget-webkit-current-session)
"document.URL" (lambda (rv)
(let ((url (kill-new (or rv ""))))
(message "url: %s" url)))))
(defun xwidget-webkit-execute-script-rv (xw script &optional default)
"Same as `xwidget-webkit-execute-script' but with return value.