]> git.eshelyaron.com Git - emacs.git/commitdiff
xwidget: Get URL asynchronously.
authorRicardo Wurmus <rekado@elephly.net>
Wed, 26 Oct 2016 06:00:35 +0000 (23:00 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 26 Oct 2016 06:07:13 +0000 (23:07 -0700)
* lisp/xwidget.el (xwidget-webkit-current-url): Kill URL in callback.

lisp/xwidget.el

index dc31b850552bcd51c92d25c98d84e2db215306bd..37edd5254ec63024495726d2afed9b54d9661283 100644 (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.