From: Ricardo Wurmus <rekado@elephly.net>
To: emacs-devel@gnu.org
Cc: Ricardo Wurmus <rekado@elephly.net>
Subject: [PATCH 08/15] xwidget: Get selection with asynchronous JavaScript
Date: Mon, 24 Oct 2016 18:40:54 +0200 [thread overview]
Message-ID: <20161024164101.26043-9-rekado@elephly.net> (raw)
In-Reply-To: <20161024164101.26043-1-rekado@elephly.net>
* 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 | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/lisp/xwidget.el b/lisp/xwidget.el
index d7ef44d..dc31b85 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))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
--
2.10.1
next prev parent reply other threads:[~2016-10-24 16:40 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-24 16:40 [PATCH v2 00/15] xwidget webkit improvements Ricardo Wurmus
2016-10-24 16:40 ` [PATCH 01/15] xwidget: Use WebKit2 API Ricardo Wurmus
2016-10-24 16:40 ` [PATCH 02/15] xwidget: Pass JavaScript return value to optional callback procedure Ricardo Wurmus
2016-10-24 16:40 ` [PATCH 03/15] Remove scrolled window container around WebKit widget Ricardo Wurmus
2016-10-24 16:40 ` [PATCH 04/15] xwidget: Do not use `xwidget-execute-script-rv' to insert string Ricardo Wurmus
2016-10-24 16:40 ` [PATCH 05/15] xwidget: Get title via asynchronous JavaScript Ricardo Wurmus
2016-10-24 16:40 ` [PATCH 06/15] xwidget: Simplify functions to scroll to elements Ricardo Wurmus
2016-10-24 16:40 ` [PATCH 07/15] xwidget: Add function to find element by CSS selector Ricardo Wurmus
2016-10-24 16:40 ` Ricardo Wurmus [this message]
2016-10-24 16:40 ` [PATCH 09/15] xwidget: Get URL asynchronously Ricardo Wurmus
2016-10-24 16:40 ` [PATCH 10/15] xwidget: Remove title hack Ricardo Wurmus
2016-10-24 16:40 ` [PATCH 11/15] Let initial WebKit view fill window Ricardo Wurmus
2016-10-24 16:40 ` [PATCH 12/15] Dynamically resize WebKit widget Ricardo Wurmus
2016-10-24 16:40 ` [PATCH 13/15] Implement zoom for " Ricardo Wurmus
2016-10-24 16:41 ` [PATCH 14/15] xwidget: Bind "beginning-of-buffer" and "end-of-buffer" Ricardo Wurmus
2016-10-24 16:41 ` [PATCH 15/15] xwidget: Map "previous-line" and "next-line" to scroll Ricardo Wurmus
2016-10-25 15:30 ` [PATCH v2 00/15] xwidget webkit improvements Paul Eggert
2016-10-26 5:12 ` Ricardo Wurmus
2016-10-26 6:08 ` Paul Eggert
2016-10-26 9:18 ` joakim
2016-10-26 9:19 ` joakim
2016-10-26 8:08 ` Live System User
2016-10-26 8:14 ` Live System User
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161024164101.26043-9-rekado@elephly.net \
--to=rekado@elephly.net \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).