all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: Stefan Kangas <stefan@marxist.se>
Cc: Puneeth Chaganti <punchagan@muse-amuse.in>,
	Joakim Verona <joakim@verona.se>,
	24019@debbugs.gnu.org
Subject: bug#24019: 25.1.50; Allow using a custom callback with xwidget
Date: Tue, 11 Aug 2020 16:21:49 +0200	[thread overview]
Message-ID: <87y2mltg8y.fsf@gnus.org> (raw)
In-Reply-To: <87a76hri5t.fsf@marxist.se> (Stefan Kangas's message of "Mon, 20 Jan 2020 21:23:42 +0100")

Stefan Kangas <stefan@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





      reply	other threads:[~2020-08-11 14:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-18 12:30 bug#24019: 25.1.50; Allow using a custom callback with xwidget Puneeth Chaganti
2020-01-20 20:23 ` Stefan Kangas
2020-08-11 14:21   ` Lars Ingebrigtsen [this message]

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y2mltg8y.fsf@gnus.org \
    --to=larsi@gnus.org \
    --cc=24019@debbugs.gnu.org \
    --cc=joakim@verona.se \
    --cc=punchagan@muse-amuse.in \
    --cc=stefan@marxist.se \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.