From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Puneeth Chaganti Newsgroups: gmane.emacs.bugs Subject: bug#24019: 25.1.50; Allow using a custom callback with xwidget Date: Mon, 18 Jul 2016 18:00:48 +0530 Message-ID: <87vb03qgav.fsf@muse-amuse.in> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1468845146 7898 80.91.229.3 (18 Jul 2016 12:32:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 18 Jul 2016 12:32:26 +0000 (UTC) To: 24019@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jul 18 14:32:16 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bP7iZ-0003Zb-IG for geb-bug-gnu-emacs@m.gmane.org; Mon, 18 Jul 2016 14:32:15 +0200 Original-Received: from localhost ([::1]:46586 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bP7iY-0007a2-LM for geb-bug-gnu-emacs@m.gmane.org; Mon, 18 Jul 2016 08:32:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45139) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bP7iQ-0007Zf-47 for bug-gnu-emacs@gnu.org; Mon, 18 Jul 2016 08:32:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bP7iM-0003FI-P4 for bug-gnu-emacs@gnu.org; Mon, 18 Jul 2016 08:32:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:42750) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bP7iM-0003FC-L6 for bug-gnu-emacs@gnu.org; Mon, 18 Jul 2016 08:32:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bP7iM-0004sf-HX for bug-gnu-emacs@gnu.org; Mon, 18 Jul 2016 08:32:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Puneeth Chaganti Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 18 Jul 2016 12:32:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 24019 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.146884507318697 (code B ref -1); Mon, 18 Jul 2016 12:32:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 18 Jul 2016 12:31:13 +0000 Original-Received: from localhost ([127.0.0.1]:55087 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bP7hZ-0004rV-Fw for submit@debbugs.gnu.org; Mon, 18 Jul 2016 08:31:13 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:53929) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bP7hX-0004rH-Tw for submit@debbugs.gnu.org; Mon, 18 Jul 2016 08:31:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bP7hO-00035T-55 for submit@debbugs.gnu.org; Mon, 18 Jul 2016 08:31:06 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:49764) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bP7hO-00035J-1a for submit@debbugs.gnu.org; Mon, 18 Jul 2016 08:31:02 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44897) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bP7hL-0007XO-MF for bug-gnu-emacs@gnu.org; Mon, 18 Jul 2016 08:31:00 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bP7hH-00034o-HK for bug-gnu-emacs@gnu.org; Mon, 18 Jul 2016 08:30:59 -0400 Original-Received: from muse-amuse.in ([213.239.211.233]:56732) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bP7hH-00034a-6L for bug-gnu-emacs@gnu.org; Mon, 18 Jul 2016 08:30:55 -0400 Original-Received: from authenticated-user (unknown [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by muse-amuse.in (Postfix) with ESMTPSA id 26881B6013D for ; Mon, 18 Jul 2016 14:30:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=muse-amuse.in; s=mail; t=1468845053; bh=9cR7AiXwylrGIcPp5CKuzi3YwzsBn53ttERddeOgMls=; h=From:To:Subject:Date:From; b=XdsT3hrFzNvITxRkKMVNl3N5zam7mEOIgwFN7XA0h9y3A88ogMs0ZidvB4bZ/5b3O AZmaQxVeJ/RzzMs+8VXw1YDe8VOd+D+6TsWV5To/Fh2/QMnt8G7O6jhiCAyWDxZWlb JYetDOGkGXZ+/r3IEf7tC/FmDX783GHBWWXowXOA= Original-Received: from authenticated-user (unknown [127.0.0.1]) Mon, 18 Jul 2016 12:30:48 -0000 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:121213 Archived-At: --=-=-= Content-Type: text/plain Hello, `xwidgets.el' seems to have some commented code that used to allow using a different callback on each xwidget. This functionality is useful to have and this is a patch that uncomments this code. I've tested the code, and it seems to work, and I'm not really sure, why this was commented in the first place. Thanks! --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Use-the-callback-set-as-widget-s-property.patch >From 63d1b53583263065edea3ee53d708693415a6057 Mon Sep 17 00:00:00 2001 From: Puneeth Chaganti Date: Mon, 18 Jul 2016 16:34:24 +0530 Subject: [PATCH 1/2] Use the callback set as widget's property Revert a commented piece of code, that allows using a different callback for each xwidget on an event, instead of a single global one. * lisp/xwidget.el (xwidget-event-handler): Use callback widget property --- lisp/xwidget.el | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lisp/xwidget.el b/lisp/xwidget.el index 7a0ca8b..3434e24 100644 --- a/lisp/xwidget.el +++ b/lisp/xwidget.el @@ -172,12 +172,8 @@ xwidget-event-handler (let* ((xwidget-event-type (nth 1 last-input-event)) (xwidget (nth 2 last-input-event)) - ;;(xwidget-callback (xwidget-get xwidget 'callback)) - ;;TODO stopped working for some reason - ) - ;;(funcall xwidget-callback xwidget xwidget-event-type) - (message "xw callback %s" xwidget) - (funcall 'xwidget-webkit-callback xwidget xwidget-event-type))) + (xwidget-callback (xwidget-get xwidget 'callback))) + (funcall xwidget-callback xwidget xwidget-event-type))) (defun xwidget-webkit-callback (xwidget xwidget-event-type) "Callback for xwidgets. -- 2.7.4 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0002-Allow-specifying-the-callback-if-new-session.patch >From 095f02a5581c2c5c157ec312a64288b0c675da74 Mon Sep 17 00:00:00 2001 From: Puneeth Chaganti Date: Mon, 18 Jul 2016 17:46:19 +0530 Subject: [PATCH 2/2] Allow specifying the callback if new session This change makes it easier to create xwidgets with their callbacks that are invoked by the event handler * lisp/xwidget.el (xwidget-webkit-new-session): Optional callback arg --- lisp/xwidget.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lisp/xwidget.el b/lisp/xwidget.el index 3434e24..0f6751e 100644 --- a/lisp/xwidget.el +++ b/lisp/xwidget.el @@ -416,16 +416,17 @@ xwidget-webkit-fit-width (car (window-inside-pixel-edges))) 1000)) -(defun xwidget-webkit-new-session (url) +(defun xwidget-webkit-new-session (url &optional callback) "Create a new webkit session buffer with URL." (let* ((bufname (generate-new-buffer-name "*xwidget-webkit*")) + (callback (or callback #'xwidget-webkit-callback)) xw) (setq xwidget-webkit-last-session-buffer (switch-to-buffer (get-buffer-create bufname))) (insert " 'a' adjusts the xwidget size.") (setq xw (xwidget-insert 1 'webkit bufname 1000 1000)) - (xwidget-put xw 'callback 'xwidget-webkit-callback) + (xwidget-put xw 'callback callback) (xwidget-webkit-mode) (xwidget-webkit-goto-uri (xwidget-webkit-last-session) url))) -- 2.7.4 --=-=-=--