diff --git a/lisp/xwidget.el b/lisp/xwidget.el index ce9839ebd3..eed35b7312 100644 --- a/lisp/xwidget.el +++ b/lisp/xwidget.el @@ -540,15 +540,26 @@ xwidget-webkit-bookmark-jump-new-session :type 'boolean) (defun xwidget-webkit-bookmark-make-record () - "Create bookmark record in webkit xwidget. -See `xwidget-webkit-bookmark-jump-new-session' for whether this -should create a new session or not." + "Create a bookmark record for a webkit xwidget." (nconc (bookmark-make-record-default t t) `((page . ,(xwidget-webkit-uri (xwidget-webkit-current-session))) - (handler . (lambda (bmk) - (xwidget-webkit-browse-url - (bookmark-prop-get bmk 'page) - xwidget-webkit-bookmark-jump-new-session)))))) + (handler . xwidget-webkit-bookmark-jump-handler)))) + +;;;###autoload +(defun xwidget-webkit-bookmark-jump-handler (bmk) + "Function for jumping to the webkit xwidget bookmarked by BMK. +If `xwidget-webkit-bookmark-jump-new-session' is non-nil, create +a new xwidget-webkit session, otherwise use an existing session." + (let* ((curbuf (current-buffer)) + (url (bookmark-prop-get bmk 'page)) + (xwbuf (if xwidget-webkit-bookmark-jump-new-session + (with-temp-buffer + (xwidget-webkit-new-session url) + (current-buffer)) + (xwidget-webkit-goto-url url) + (current-buffer)))) + (switch-to-buffer curbuf) + (set-buffer xwbuf))) ;;; xwidget webkit session