diff options
| author | Ricardo Wurmus | 2016-10-25 23:00:35 -0700 |
|---|---|---|
| committer | Paul Eggert | 2016-10-25 23:07:13 -0700 |
| commit | 4aa7c4b4aa2cedbc401b624846285905fb9f8a43 (patch) | |
| tree | 71394f53e7d35cd7aa468909b04c89783de442b3 | |
| parent | efa269d14685042912cfed96b617d4824a78a1cb (diff) | |
| download | emacs-4aa7c4b4aa2cedbc401b624846285905fb9f8a43.tar.gz emacs-4aa7c4b4aa2cedbc401b624846285905fb9f8a43.zip | |
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.
| -rw-r--r-- | lisp/xwidget.el | 12 |
1 files changed, 7 insertions, 5 deletions
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." | |||
| 504 | title)) | 504 | title)) |
| 505 | 505 | ||
| 506 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 506 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 507 | (defun xwidget-webkit-get-selection () | 507 | (defun xwidget-webkit-get-selection (proc) |
| 508 | "Get the webkit selection." | 508 | "Get the webkit selection and pass it to PROC." |
| 509 | (xwidget-webkit-execute-script-rv (xwidget-webkit-current-session) | 509 | (xwidget-webkit-execute-script |
| 510 | "window.getSelection().toString();")) | 510 | (xwidget-webkit-current-session) |
| 511 | "window.getSelection().toString();" | ||
| 512 | proc)) | ||
| 511 | 513 | ||
| 512 | (defun xwidget-webkit-copy-selection-as-kill () | 514 | (defun xwidget-webkit-copy-selection-as-kill () |
| 513 | "Get the webkit selection and put it on the kill-ring." | 515 | "Get the webkit selection and put it on the kill-ring." |
| 514 | (interactive) | 516 | (interactive) |
| 515 | (kill-new (xwidget-webkit-get-selection))) | 517 | (xwidget-webkit-get-selection (lambda (selection) (kill-new selection)))) |
| 516 | 518 | ||
| 517 | 519 | ||
| 518 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 520 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |