From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Stefan Kangas Newsgroups: gmane.emacs.bugs Subject: bug#24019: 25.1.50; Allow using a custom callback with xwidget Date: Mon, 20 Jan 2020 21:23:42 +0100 Message-ID: <87a76hri5t.fsf@marxist.se> References: <87vb03qgav.fsf@muse-amuse.in> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="120947"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Puneeth Chaganti , 24019@debbugs.gnu.org To: Joakim Verona Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jan 20 21:24:21 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1itdau-000VPa-RN for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 20 Jan 2020 21:24:21 +0100 Original-Received: from localhost ([::1]:43848 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1itdat-0007Yh-TS for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 20 Jan 2020 15:24:19 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41798) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1itdag-0007V8-S7 for bug-gnu-emacs@gnu.org; Mon, 20 Jan 2020 15:24:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1itdac-0006CF-If for bug-gnu-emacs@gnu.org; Mon, 20 Jan 2020 15:24:06 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:40166) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1itdac-0006AB-9N for bug-gnu-emacs@gnu.org; Mon, 20 Jan 2020 15:24:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1itdac-0002Se-5W for bug-gnu-emacs@gnu.org; Mon, 20 Jan 2020 15:24:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Kangas Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 20 Jan 2020 20:24:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24019 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 24019-submit@debbugs.gnu.org id=B24019.15795518369446 (code B ref 24019); Mon, 20 Jan 2020 20:24:02 +0000 Original-Received: (at 24019) by debbugs.gnu.org; 20 Jan 2020 20:23:56 +0000 Original-Received: from localhost ([127.0.0.1]:46139 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1itdaV-0002SH-Ny for submit@debbugs.gnu.org; Mon, 20 Jan 2020 15:23:56 -0500 Original-Received: from ted.gofardesign.uk ([67.225.143.91]:43810) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1itdaS-0002Ry-Vl for 24019@debbugs.gnu.org; Mon, 20 Jan 2020 15:23:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=marxist.se; s=default; h=Content-Type:MIME-Version:Message-ID:Date:References: In-Reply-To:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=AZE7POi1aOfZeW8UViQBM4NnC7REgsWlgRCdb7vCU2Q=; b=p82+Vt9T0SzKOopb5b+Wv3b7UF APjUvlU7rWqMw/oTBB7B8J/4lsUBzhnx8A53G0LE4OeIrAHp+2iMALxhKOSfwanU3EKHlCfHy9JeI R47UkbI22bbHnev3wlqhTvT7U+oSsXkY+C683aRqfmBUqiWom60FJ1ADJstDYqk9v0wfBWYJv6Z16 WR/lB/65CNQo8FLsuyOqROWxCvi1ZISe0Sa3glNPJ0cmAtPQZXPM8QKaQSqrVu6nB+HH9KVNFwBy8 8ne2gzXcv4reiKyy5h54RBlkXfhkktDCkA2mbeTWxQ1Ng0piRL5fFzN+cdhbfAkrcMQ9Hy+EyQ1hM 1Ne2LoJw==; Original-Received: from h-70-69.a785.priv.bahnhof.se ([155.4.70.69]:33270 helo=localhost) by ted.gofardesign.uk with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1itdaJ-000Cia-Fp; Mon, 20 Jan 2020 15:23:43 -0500 In-Reply-To: <87vb03qgav.fsf@muse-amuse.in> (Puneeth Chaganti's message of "Mon, 18 Jul 2016 18:00:48 +0530") X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - ted.gofardesign.uk X-AntiAbuse: Original Domain - debbugs.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - marxist.se X-Get-Message-Sender-Via: ted.gofardesign.uk: authenticated_id: stefan@marxist.se X-Authenticated-Sender: ted.gofardesign.uk: stefan@marxist.se 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: 209.51.188.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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:174956 Archived-At: Hi Joakim, Puneeth Chaganti writes: > 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! Could you please help review the below patches? They were submitted to the Emacs bug list in 2016, but no one has followed up on them. Best regards, Stefan Kangas > >>>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 > > >>>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)))