1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-02-04 06:31:13 -08:00

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.
This commit is contained in:
Ricardo Wurmus 2016-10-25 23:00:35 -07:00 committed by Paul Eggert
parent efa269d146
commit 4aa7c4b4aa

View 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))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;