From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Ricardo Wurmus Newsgroups: gmane.emacs.devel Subject: [PATCH 08/15] xwidget: Get selection with asynchronous JavaScript Date: Mon, 24 Oct 2016 18:40:54 +0200 Message-ID: <20161024164101.26043-9-rekado@elephly.net> References: <20161024164101.26043-1-rekado@elephly.net> NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1477327904 27006 195.159.176.226 (24 Oct 2016 16:51:44 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 24 Oct 2016 16:51:44 +0000 (UTC) Cc: Ricardo Wurmus To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Oct 24 18:51:40 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1byiSx-0004AI-IU for ged-emacs-devel@m.gmane.org; Mon, 24 Oct 2016 18:51:15 +0200 Original-Received: from localhost ([::1]:48190 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1byiSz-0006dV-T5 for ged-emacs-devel@m.gmane.org; Mon, 24 Oct 2016 12:51:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41657) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1byiLM-00082r-Lj for emacs-devel@gnu.org; Mon, 24 Oct 2016 12:43:25 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1byiLL-0002xs-VF for emacs-devel@gnu.org; Mon, 24 Oct 2016 12:43:24 -0400 Original-Received: from sender163-mail.zoho.com ([74.201.84.163]:21499) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1byiLL-0002wx-NX for emacs-devel@gnu.org; Mon, 24 Oct 2016 12:43:23 -0400 Original-Received: from localhost (89.204.138.233 [89.204.138.233]) by mx.zohomail.com with SMTPS id 14773274011397.9759183785814685; Mon, 24 Oct 2016 09:43:21 -0700 (PDT) X-Mailer: git-send-email 2.10.1 In-Reply-To: <20161024164101.26043-1-rekado@elephly.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 74.201.84.163 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:208719 Archived-At: * 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