]> git.eshelyaron.com Git - emacs.git/commitdiff
xwidget: Get selection with asynchronous JavaScript
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-get-selection): Add PROC argument to
process selection.
(xwidget-webkit-copy-selection-as-kill): Kill selection in callback.

lisp/xwidget.el

index d7ef44d389fd527f017f2b0d49bed03f39101cf7..dc31b850552bcd51c92d25c98d84e2db215306bd 100644 (file)
@@ -504,15 +504,17 @@ DEFAULT is the default return value."
     title))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(defun xwidget-webkit-get-selection ()
-  "Get the webkit selection."
-  (xwidget-webkit-execute-script-rv (xwidget-webkit-current-session)
-                                    "window.getSelection().toString();"))
+(defun xwidget-webkit-get-selection (proc)
+  "Get the webkit selection and pass it to PROC."
+  (xwidget-webkit-execute-script
+   (xwidget-webkit-current-session)
+   "window.getSelection().toString();"
+   proc))
 
 (defun xwidget-webkit-copy-selection-as-kill ()
   "Get the webkit selection and put it on the kill-ring."
   (interactive)
-  (kill-new (xwidget-webkit-get-selection)))
+  (xwidget-webkit-get-selection (lambda (selection) (kill-new selection))))
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;