On Wed, 29 Dec 2021 19:25:52 +0800 Po Lu wrote: > Stephen Berman writes: > >> I did, but that just ensures that jumping to the bookmarked xwidget >> creates a new xwidget session -- it does not prevent the xwidget from >> being displayed both in the other window/frame and in the originally >> selected window. My patch ensures that the bookmarked xwidget is >> displayed only in the other window/frame, which is consistent with the >> behavior of `bookmark-jump-other-window' and `bookmark-jump-other-frame' >> with other types of bookmarks (e.g. to PDFs in the pdf-tools package), >> regardless of whether a new xwidget session is created. > > Okay, thanks -- some comments below: > >> + (with-temp-buffer >> + (xwidget-webkit-new-session url) >> + (current-buffer)) > > Why with-temp-buffer? Oh, that's a faux pas, the residue of an earlier version; `progn' would have sufficed, but the new version below does it differently anyway. > xwidget-webkit-new-session creates a new buffer and switches to it, > which is not appropriate if you want to obtain a buffer containing the > new xwidget. I suggest that you write a new function that creates the > buffer, displays the xwidget, and returns the buffer, preferably also > updating xwidget-webkit-new-session to use it as well. > >> + (switch-to-buffer curbuf) >> + (set-buffer xwbuf))) > > See above. Thanks for the suggestion, see the patch below. Since the previous bookmark handler was the only user of `xwidget-webkit-browse-url''s `new-session' parameter, I removed that, and took the opportunity to make some other cleanups to that function, see the commit message. While testing the refactored `xwidget-webkit-new-session' I found that the xwidget-webkit-clone-* commands were broken because `xwidget-webkit-current-url' returned the message instead of the URL, so I fixed that. And I removed from the doc string of `xwidget-webkit-bookmark-jump-new-session' the suggestion to customize `xwidget-webkit-last-session-buffer', since, for one thing, it's not a defcustom, but more importantly, changing it has no effect, since it gets set by `xwidget-webkit--create-new-session-buffer' (previously by `xwidget-webkit-new-session'), overriding any user change to its value. 2021-12-30 Stephen Berman Fix handling of webkit xwidget bookmarks Make jumping to a bookmarked webkit xwidget in another window or another frame show the xwidget only in that window or frame. Adjust xwidget.el code accordingly. Make xwidget-webkit-clone-* commands work. (Bug#52856) * lisp/xwidget.el (xwidget-webkit-browse-url): Remove `new-session' parameter, since the bookmark handler, which was its only user, no longer calls this function. Remove superfluous `browse-url' require from interactive spec and discard the unused flag returned by `browse-url-interactive-arg'. Incorporate the code of the now removed `xwidget-webkit-goto-url', since this function was its only caller. (xwidget-webkit-goto-url): Remove. (xwidget-webkit-bookmark-jump-new-session): Adjust doc string, rephrasing and removing a customization suggestion that cannot take effect. (xwidget-webkit-bookmark-jump-handler): New autoloaded function. (xwidget-webkit-bookmark-make-record): Use it. (xwidget-webkit--create-new-session-buffer): New function extracted from `xwidget-webkit-new-session'. (xwidget-webkit-new-session): Use it. (xwidget-webkit-current-url): Return the URL instead of the message displaying it, since the xwidget-webkit-clone-* commands need it.