From: Ricardo Wurmus Date: Wed, 26 Oct 2016 06:00:35 +0000 (-0700) Subject: xwidget: Get selection with asynchronous JavaScript X-Git-Tag: emacs-26.0.90~1422 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=4aa7c4b4aa2cedbc401b624846285905fb9f8a43;p=emacs.git xwidget: Get selection with asynchronous JavaScript * lisp/xwidget.el (xwidget-webkit-get-selection): Add PROC argument to process selection. (xwidget-webkit-copy-selection-as-kill): Kill selection in callback. --- diff --git a/lisp/xwidget.el b/lisp/xwidget.el index d7ef44d389f..dc31b850552 100644 --- a/lisp/xwidget.el +++ b/lisp/xwidget.el @@ -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)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;