From be0fecf81911622ad166be00c59900033fcfde71 Mon Sep 17 00:00:00 2001 From: Puneeth Chaganti Date: Tue, 11 Aug 2020 16:23:10 +0200 Subject: [PATCH] Allow specifying the callback in new xwidget sessions * lisp/xwidget.el (xwidget-webkit-new-session): Optional callback arg (bug#24019). (xwidget-event-handler): Respect the 'callback parameter. --- lisp/xwidget.el | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/lisp/xwidget.el b/lisp/xwidget.el index aed6c09122c..a4c15a1e266 100644 --- a/lisp/xwidget.el +++ b/lisp/xwidget.el @@ -207,12 +207,8 @@ Interactively, URL defaults to the string looking like a url around point." (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 @@ For example, use this to display an anchor." (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 @@ For example, use this to display an anchor." (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))) -- 2.39.5