* bug#24019: 25.1.50; Allow using a custom callback with xwidget
@ 2016-07-18 12:30 Puneeth Chaganti
2020-01-20 20:23 ` Stefan Kangas
0 siblings, 1 reply; 3+ messages in thread
From: Puneeth Chaganti @ 2016-07-18 12:30 UTC (permalink / raw)
To: 24019
[-- Attachment #1: Type: text/plain, Size: 328 bytes --]
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!
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Use-the-callback-set-as-widget-s-property.patch --]
[-- Type: text/x-diff, Size: 1295 bytes --]
From 63d1b53583263065edea3ee53d708693415a6057 Mon Sep 17 00:00:00 2001
From: Puneeth Chaganti <punchagan@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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-Allow-specifying-the-callback-if-new-session.patch --]
[-- Type: text/x-diff, Size: 1508 bytes --]
From 095f02a5581c2c5c157ec312a64288b0c675da74 Mon Sep 17 00:00:00 2001
From: Puneeth Chaganti <punchagan@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)))
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* bug#24019: 25.1.50; Allow using a custom callback with xwidget
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
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Kangas @ 2020-01-20 20:23 UTC (permalink / raw)
To: Joakim Verona; +Cc: Puneeth Chaganti, 24019
Hi Joakim,
Puneeth Chaganti <punchagan@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@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@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)))
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#24019: 25.1.50; Allow using a custom callback with xwidget
2020-01-20 20:23 ` Stefan Kangas
@ 2020-08-11 14:21 ` Lars Ingebrigtsen
0 siblings, 0 replies; 3+ messages in thread
From: Lars Ingebrigtsen @ 2020-08-11 14:21 UTC (permalink / raw)
To: Stefan Kangas; +Cc: Puneeth Chaganti, Joakim Verona, 24019
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-08-11 14:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).