From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Po Lu via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#52856: 29.0.50; Problematic handling of webkit xwidget bookmarks Date: Fri, 31 Dec 2021 08:56:58 +0800 Message-ID: <87mtkhmw11.fsf@yahoo.com> References: <875yr8wn9e.fsf@gmx.net> <87ilv7ub1o.fsf@yahoo.com> <87sfubfzwt.fsf@gmx.net> <874k6rtzy7.fsf@yahoo.com> <877dbm1i1n.fsf@gmx.net> <87ee5unxwe.fsf@yahoo.com> <8735ma16km.fsf@gmx.net> Reply-To: Po Lu Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31038"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.60 (gnu/linux) Cc: 52856@debbugs.gnu.org To: Stephen Berman Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Dec 31 02:11:02 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n36Ri-0007qO-A3 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 31 Dec 2021 02:11:02 +0100 Original-Received: from localhost ([::1]:53572 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n36Rf-0006fS-EC for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 30 Dec 2021 20:11:00 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:40730) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n36F9-0005Fm-Ml for bug-gnu-emacs@gnu.org; Thu, 30 Dec 2021 19:58:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:43280) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n36F9-0004N2-Bu for bug-gnu-emacs@gnu.org; Thu, 30 Dec 2021 19:58:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1n36F8-0003YN-9o for bug-gnu-emacs@gnu.org; Thu, 30 Dec 2021 19:58:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Po Lu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 31 Dec 2021 00:58:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52856 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 52856-submit@debbugs.gnu.org id=B52856.164091223613587 (code B ref 52856); Fri, 31 Dec 2021 00:58:02 +0000 Original-Received: (at 52856) by debbugs.gnu.org; 31 Dec 2021 00:57:16 +0000 Original-Received: from localhost ([127.0.0.1]:54826 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n36EN-0003X5-Ku for submit@debbugs.gnu.org; Thu, 30 Dec 2021 19:57:16 -0500 Original-Received: from sonic308-10.consmr.mail.ne1.yahoo.com ([66.163.187.33]:36920) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n36EL-0003Wk-Cd for 52856@debbugs.gnu.org; Thu, 30 Dec 2021 19:57:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1640912227; bh=bcQrB9W27TaC96VoerbTWUKSfQr8wFBBhcWEWY7F2yM=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From:Subject:Reply-To; b=j5/fgNb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SS19koMAtYTXRPg2Gr5ac4uK.QfF.RlYtoIHTtvR_CszYI8peDscq5y3VuOfraKrd k_r6Gs_ej.GUSP6H8mUzIWta.riNo31M16jqIEuF.Mpg8dDhuGxr0.SJXvJYsBWhgSFenRJoeMrV Sn_uUj4nj0DNB.HM7cqW2iXV2umgI2G.4sS_70uHSZEKCsOw0jJve4toyH4.51UJap40GlrWgSSd Np_cxrLUMx_r2bLxvl_tInH1Y1ysIGP1oRDzpZHIlsaHo4G2NOj99bmKsnCtfFZC21AKBu4etx_9 y6wXPbziQdIROfMuBe7UquuVJntpxONogtmaobSPb1kqiCGopO186jh4S_N0APemJsv2NirFFBYr 85dV7IURFxhgo1j5rndbNeJCjAf_8Z9LWlsY4IRn__pmwLVs1jfmivqX0Wcibd1wOklWoGTklIw0 _nOEu2xYaz0uJAv3ECfo1SvAt4A_HmA9g.Y.CmcIr1OvYsa7Ixf30etQbY8QSrghLCvSljgwXrD2 wrRIo9jyuHM5W9LSFnJ4ZdPxCv1pX6G3lYnd93B.IEt5bQmzhpC70Yz77.GDe2EWVBpYDf0eraOK kyF6Ml5RWKGfGpYbBC4bqFAjGnCcAlIppRM5lF81FO X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic308.consmr.mail.ne1.yahoo.com with HTTP; Fri, 31 Dec 2021 00:57:07 +0000 Original-Received: by kubenode510.mail-prod1.omega.sg3.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID ead3cf1019ae8f97012b63ce791cb0dd; Fri, 31 Dec 2021 00:57:03 +0000 (UTC) In-Reply-To: <8735ma16km.fsf@gmx.net> (Stephen Berman's message of "Thu, 30 Dec 2021 16:00:09 +0100") X-Mailer: WebService/1.1.19551 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:223459 Archived-At: Stephen Berman writes: > How's this: "Jump to the web page bookmarked by the bookmark record > BOOKMARK."? Sure. > Thanks. Here's the latest version: Thanks, LGTM. Have you signed the copyright papers yet? > 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 and > refactor new session code used by the bookmark code (bug#52856). > In addition, make xwidget-webkit-clone-* commands work. > > * lisp/xwidget.el (xwidget-webkit-clone-and-split-below) > (xwidget-webkit-clone-and-split-right): Unbreak these functions by > passing just the URL to them, not the message displaying it. > (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. > > diff --git a/lisp/xwidget.el b/lisp/xwidget.el > index ce9839ebd3..1f92966492 100644 > --- a/lisp/xwidget.el > +++ b/lisp/xwidget.el > @@ -138,7 +138,7 @@ xwidget-webkit-clone-and-split-below > Get the URL of current session, then browse to the URL > in `split-window-below' with a new xwidget webkit session." > (interactive nil xwidget-webkit-mode) > - (let ((url (xwidget-webkit-current-url))) > + (let ((url (xwidget-webkit-uri (xwidget-webkit-current-session)))) > (with-selected-window (split-window-below) > (xwidget-webkit-new-session url)))) > > @@ -147,7 +147,7 @@ xwidget-webkit-clone-and-split-right > Get the URL of current session, then browse to the URL > in `split-window-right' with a new xwidget webkit session." > (interactive nil xwidget-webkit-mode) > - (let ((url (xwidget-webkit-current-url))) > + (let ((url (xwidget-webkit-uri (xwidget-webkit-current-session)))) > (with-selected-window (split-window-right) > (xwidget-webkit-new-session url)))) > > @@ -531,24 +531,31 @@ xwidget-webkit-save-as-file > ;;; Bookmarks integration > > (defcustom xwidget-webkit-bookmark-jump-new-session nil > - "Control bookmark jump to use new session or not. > -If non-nil, use a new xwidget webkit session after bookmark jump. > -Otherwise, it will use `xwidget-webkit-last-session'. > -When you set this variable to nil, consider further customization with > -`xwidget-webkit-last-session-buffer'." > + "Whether to jump to a bookmarked URL in a new xwidget webkit session. > +If non-nil, create a new xwidget webkit session, otherwise use > +the value of `xwidget-webkit-last-session'." > :version "28.1" > :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 (bookmark) > + "Jump to the web page bookmarked by the bookmark record BOOKMARK. > +If `xwidget-webkit-bookmark-jump-new-session' is non-nil, create > +a new xwidget-webkit session, otherwise use an existing session." > + (let* ((url (bookmark-prop-get bookmark 'page)) > + (xwbuf (if (or xwidget-webkit-bookmark-jump-new-session > + (not (xwidget-webkit-current-session))) > + (xwidget-webkit--create-new-session-buffer url) > + (xwidget-buffer (xwidget-webkit-current-session))))) > + (with-current-buffer xwbuf > + (xwidget-webkit-goto-uri (xwidget-webkit-current-session) url)) > + (set-buffer xwbuf))) > > ;;; xwidget webkit session > > @@ -796,37 +803,44 @@ 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 &optional callback) > - "Create a new webkit session buffer with URL." > +(defun xwidget-webkit--create-new-session-buffer (url &optional callback) > + "Create a new webkit session buffer to display URL in an xwidget. > +Optional function CALLBACK specifies the callback for webkit xwidgets; > +see `xwidget-webkit-callback'." > (let* ((bufname > - ;; Generate a temp-name based on current buffer name. it > - ;; will be renamed by `xwidget-webkit-callback' in the > - ;; future. This approach can limit flicker of buffer-name in > - ;; mode-line. > + ;; Generate a temp-name based on current buffer name. The > + ;; buffer will subsequently be renamed by > + ;; `xwidget-webkit-callback'. This approach can avoid > + ;; flicker of buffer-name in mode-line. > (generate-new-buffer-name (buffer-name))) > (callback (or callback #'xwidget-webkit-callback)) > (current-session (xwidget-webkit-current-session)) > xw) > - (setq xwidget-webkit-last-session-buffer (switch-to-buffer > - (get-buffer-create bufname))) > + (setq xwidget-webkit-last-session-buffer (get-buffer-create bufname)) > ;; The xwidget id is stored in a text property, so we need to have > ;; at least character in this buffer. > ;; Insert invisible url, good default for next `g' to browse url. > - (let ((start (point))) > - (insert url) > - (put-text-property start (+ start (length url)) 'invisible t) > - (setq xw (xwidget-insert > - start 'webkit bufname > - (xwidget-window-inside-pixel-width (selected-window)) > - (xwidget-window-inside-pixel-height (selected-window)) > - nil current-session))) > - (when xwidget-webkit-cookie-file > - (xwidget-webkit-set-cookie-storage-file > - xw (expand-file-name xwidget-webkit-cookie-file))) > - (xwidget-put xw 'callback callback) > - (xwidget-put xw 'display-callback #'xwidget-webkit-display-callback) > - (xwidget-webkit-mode) > - (xwidget-webkit-goto-uri (xwidget-webkit-last-session) url))) > + (with-current-buffer xwidget-webkit-last-session-buffer > + (let ((start (point))) > + (insert url) > + (put-text-property start (+ start (length url)) 'invisible t) > + (setq xw (xwidget-insert > + start 'webkit bufname > + (xwidget-window-inside-pixel-width (selected-window)) > + (xwidget-window-inside-pixel-height (selected-window)) > + nil current-session))) > + (when xwidget-webkit-cookie-file > + (xwidget-webkit-set-cookie-storage-file > + xw (expand-file-name xwidget-webkit-cookie-file))) > + (xwidget-put xw 'callback callback) > + (xwidget-put xw 'display-callback #'xwidget-webkit-display-callback) > + (xwidget-webkit-mode)) > + xwidget-webkit-last-session-buffer)) > + > +(defun xwidget-webkit-new-session (url) > + "Display URL in a new webkit xwidget." > + (switch-to-buffer (xwidget-webkit--create-new-session-buffer url)) > + (xwidget-webkit-goto-uri (xwidget-webkit-last-session) url)) > > (defun xwidget-webkit-import-widget (xwidget) > "Create a new webkit session buffer from XWIDGET, an existing xwidget.