GNU bug report logs - #24019
25.1.50; Allow using a custom callback with xwidget

Previous Next

Package: emacs;

Reported by: Puneeth Chaganti <punchagan <at> muse-amuse.in>

Date: Mon, 18 Jul 2016 12:32:02 UTC

Severity: wishlist

Tags: fixed, patch

Found in version 25.1.50

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 24019 in the body.
You can then email your comments to 24019 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#24019; Package emacs. (Mon, 18 Jul 2016 12:32:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Puneeth Chaganti <punchagan <at> muse-amuse.in>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 18 Jul 2016 12:32:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Puneeth Chaganti <punchagan <at> muse-amuse.in>
To: bug-gnu-emacs <at> gnu.org
Subject: 25.1.50; Allow using a custom callback with xwidget
Date: Mon, 18 Jul 2016 18:00:48 +0530
[Message part 1 (text/plain, inline)]
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!

[0001-Use-the-callback-set-as-widget-s-property.patch (text/x-diff, attachment)]
[0002-Allow-specifying-the-callback-if-new-session.patch (text/x-diff, attachment)]

Added tag(s) patch. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 28 Jul 2019 10:29:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24019; Package emacs. (Mon, 20 Jan 2020 20:24:02 GMT) Full text and rfc822 format available.

Message #10 received at 24019 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: Joakim Verona <joakim <at> verona.se>
Cc: Puneeth Chaganti <punchagan <at> muse-amuse.in>, 24019 <at> debbugs.gnu.org
Subject: Re: bug#24019: 25.1.50; Allow using a custom callback with xwidget
Date: Mon, 20 Jan 2020 21:23:42 +0100
Hi Joakim,

Puneeth Chaganti <punchagan <at> muse-amuse.in> 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 <punchagan <at> muse-amuse.in>
> 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 <punchagan <at> muse-amuse.in>
> 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)))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24019; Package emacs. (Tue, 11 Aug 2020 14:23:01 GMT) Full text and rfc822 format available.

Message #13 received at 24019 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Stefan Kangas <stefan <at> marxist.se>
Cc: Puneeth Chaganti <punchagan <at> muse-amuse.in>,
 Joakim Verona <joakim <at> verona.se>, 24019 <at> debbugs.gnu.org
Subject: Re: bug#24019: 25.1.50; Allow using a custom callback with xwidget
Date: Tue, 11 Aug 2020 16:21:49 +0200
Stefan Kangas <stefan <at> marxist.se> writes:

>> `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.

I've re-spun the patch for Emacs 28.  It seems "obviously correct", and
by doing some cursory testing, it doesn't seem to have broken anything,
so I'll just push it.  If this leads to any problems, Joakim, feel free
to revert it.

diff --git a/lisp/xwidget.el b/lisp/xwidget.el
index aed6c09122..a4c15a1e26 100644
--- a/lisp/xwidget.el
+++ b/lisp/xwidget.el
@@ -207,12 +207,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.
@@ -481,10 +477,11 @@ xwidget-webkit-adjust-size-in-frame
   (add-to-list 'window-size-change-functions
                'xwidget-webkit-adjust-size-in-frame))
 
-(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)))
@@ -494,7 +491,7 @@ xwidget-webkit-new-session
     (setq xw (xwidget-insert 1 'webkit bufname
                              (window-pixel-width)
                              (window-pixel-height)))
-    (xwidget-put xw 'callback 'xwidget-webkit-callback)
+    (xwidget-put xw 'callback callback)
     (xwidget-webkit-mode)
     (xwidget-webkit-goto-uri (xwidget-webkit-last-session) url)))
 


-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 11 Aug 2020 14:24:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.1, send any further explanations to 24019 <at> debbugs.gnu.org and Puneeth Chaganti <punchagan <at> muse-amuse.in> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 11 Aug 2020 14:24:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 09 Sep 2020 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 224 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.