From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: James Thomas via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#71450: [PATCH] Wrong eww-history-position after desktop restore if within history Date: Tue, 11 Jun 2024 03:06:31 +0530 Message-ID: <86plsobhuo.fsf@gmx.net> References: <86h6e21f0e.fsf@outlook.com> <2fd89234-fab9-a0a3-3bc1-f193983e2cd4@gmail.com> Reply-To: James Thomas Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4921"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Jim Porter To: 71450@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jun 11 21:13:35 2024 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 1sH6w2-000192-Pj for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 11 Jun 2024 21:13:34 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sH6vZ-00034v-KB; Tue, 11 Jun 2024 15:13:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sH6vX-00034S-Uw for bug-gnu-emacs@gnu.org; Tue, 11 Jun 2024 15:13:03 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sH6vX-0004PJ-KD for bug-gnu-emacs@gnu.org; Tue, 11 Jun 2024 15:13:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sH6vV-0000im-I0 for bug-gnu-emacs@gnu.org; Tue, 11 Jun 2024 15:13:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: James Thomas Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 11 Jun 2024 19:13:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71450 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 71450-submit@debbugs.gnu.org id=B71450.17181331472722 (code B ref 71450); Tue, 11 Jun 2024 19:13:01 +0000 Original-Received: (at 71450) by debbugs.gnu.org; 11 Jun 2024 19:12:27 +0000 Original-Received: from localhost ([127.0.0.1]:36248 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sH6uw-0000hq-PF for submit@debbugs.gnu.org; Tue, 11 Jun 2024 15:12:27 -0400 Original-Received: from mout.gmx.net ([212.227.17.21]:48775) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sH6uv-0000ha-8B for 71450@debbugs.gnu.org; Tue, 11 Jun 2024 15:12:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1718133140; x=1718737940; i=jimjoe@gmx.net; bh=ZUIhPKYI1yzvuyi0GnJgZNtZW+MoKBWZSwZU89RKbxg=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=qPfT7e8GFnPXFb2AIwrx4xsRPaCsCO4pXL/lAdEQ1wlJHoHfBOafE/yKKdWUjpZ1 j6L94UlhXS2MURZIc3ejbNQNLz5LNonyTKL9x3mnyFyNuoIEFx4FuvcV1giWzZfe7 C2M5bm9BFU+EX7Ne1gxfkT9NChl1vKoXvYsX4ktdp7d3y5lCXn8WH6m0D8d2MtSKj dfMDBE2b8m/9xS2kVyqgsOeqUmVvGOrhfUkxQdFaDlXCT/iKLVwAJT+c+rMrBIkYD tMFHf9ME+QNfHaIJjUGd0UnmaZllwra+r3RefmkcYCZE0VxkoDY3gthIw+iV14I2f IzQNaViu2oJEYyU6VA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from user-Inspiron-3493 ([117.206.130.35]) by mail.gmx.net (mrgmx105 [212.227.17.174]) with ESMTPSA (Nemesis) id 1M9nxt-1sJnMn1KJp-00BzIe; Mon, 10 Jun 2024 23:36:37 +0200 In-Reply-To: <2fd89234-fab9-a0a3-3bc1-f193983e2cd4@gmail.com> (Jim Porter's message of "Sun, 9 Jun 2024 14:20:56 -0700") X-Provags-ID: V03:K1:8NJGmYdokI1SPbk3zQ0utEwqh8QvOTCsgfsPiaOfX18AGzrPfWK fI33ZBzSpu+s68O8GKYlrDH83NzABiRMDqX2Nl9OOkdYTFA/RoRGRTcr8FfoE81rEUW3CKU wN4CPxIie5YsaONXYv5v8UmneinX8LVjcq1gzEaxN+uGjNydHRdmdGmrY5huYZIl3FFEg0G 9JnRQtQIh5FXrOESBRfUg== UI-OutboundReport: notjunk:1;M01:P0:I7dMtrHhM/Y=;7rIOaAeG8CXf8oYkGXryeom8tK4 kulTnDNU38rC6t1XVbM11JWN0t/Vw/n3nUpd4Tadhcchuq0w0QDa5LV6VhQ4hw4pd0Nix3aQ0 mIYTE8RO9sAyY5wP4q0Ap5NvFbvS+bzWoT42JsYCN9rmBdDQ+WReefOBVsm4dC98P3RpI3Lj+ w0gAL7HfNAph3H2swy8v3Gp/Qwew1xWs0DDnw4s5OyluNogMW4zy+SChP8phzkVYnzMoK8o+C MGoK7/jzh7jmdUBD2lU4m9lKoM8VbCKfMmEzUdc7O8NxiwJgn85HyaFrqx1vLyp0WJdElyxsz mlBYm5dnLk5eWeVHGi4RLJ7osSfRuI87LftxnJbZIk8Okm58XY0bYUZnEMu0fGKQSKijEpMwb stHiNtqx/L5Iu2jrylyk40S1idXuv2GCd59DzsDKSifrX3LZlt2r5jx3qRCNSB+839kjBf4cd BaykE0KUIDls+YFIyWSwhQu5Wp3dM6xytfzlrfAhMq9iZKxjoO54hy/Iytggug+B92gaIPepY lZUdGaQY0zAOPgSJM3DGZGycYO9vtDMDI/j6ArzqHFGJ+DVGnLN4TqQUWe9bJ8FzzdC7aNWnI RDmuTX2ZHpP0G3oFlejmPuwpD8kFkVjbO8QYX6ly3BQZqIFZKI43HTyiYcSQm3Jn+yW7DwAnx UG+1wEG2daAQPMzQ2essgNbLoZWxyskSX0T67MZNBgYg5B99O1/XhZjGzlB4DTe258DZS/Bfp O+d5mIiHLJE4uNERUibNEgBe4yud+fWs8BV3tTVH7Sot9GQy4zBnH3AQfvIC+Qq0CRlkp9ps 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:287106 Archived-At: --=-=-= Content-Type: text/plain Jim Porter wrote: > On 6/9/2024 5:23 AM, James Thomas via Bug reports for GNU Emacs, the > Swiss army knife of text editors wrote: >> This is a patch that I think is simple enough to forgo the extensive >> testing which it hasn't been subjected to. > > Thanks for the patch. > >> + :history-position >> + (cl-position >> + (elt history eww-history-position) >> + rval :test #'eww-desktop-history-duplicate)))) > > Two questions here: > > 1. Is that the right test function? I'd have expected 'eq', since we > want to find the position where our history index has moved to, right? > > 2. Should this part check for 'eww-desktop-remove-duplicates' too? If > that option is nil, I think we could avoid the 'cl-position' call. Or > maybe lift the 'eww-desktop-remove-duplicates' call outside of the > 'list' and just construct two totally different lists in the THEN/ELSE > blocks. Here's an updated patch, which I've tested somewhat: --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Account-for-duplicate-removal-on-restoring.patch Content-Description: [PATCH] Account for duplicate removal on restoring Content-Transfer-Encoding: quoted-printable =46rom bc0e3f2653e1c4c1f683d4b10ff139dbf963ee8d Mon Sep 17 00:00:00 2001 From: James Thomas Date: Tue, 11 Jun 2024 03:00:33 +0530 Subject: [PATCH] Account for duplicate removal on restoring eww-history-position. * lisp/net/eww.el (eww-desktop-misc-data): Add :history-position (eww-restore-desktop): Use it. (desktop-locals-to-save): Remove the raw variable. =2D-- lisp/net/eww.el | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/lisp/net/eww.el b/lisp/net/eww.el index 977210e9cc8..fd8f80065b1 100644 =2D-- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -2754,11 +2754,20 @@ eww-desktop-misc-data Generally, the list should not include the (usually overly large) :dom, :source and :text properties." (let ((history (mapcar #'eww-desktop-data-1 - (cons eww-data eww-history)))) - (list :history (if eww-desktop-remove-duplicates - (cl-remove-duplicates - history :test #'eww-desktop-history-duplicate) - history)))) + (cons eww-data eww-history))) + (posn eww-history-position) rval) + (list :history + (if eww-desktop-remove-duplicates + (prog1 + (setq + rval (cl-remove-duplicates + history :test #'eww-desktop-history-duplicate)) + (setq posn + (cl-position + (elt history eww-history-position) + rval :test #'eq))) + history) + :history-position posn))) (defun eww-restore-desktop (file-name buffer-name misc-data) "Restore an eww buffer from its desktop file record. @@ -2772,7 +2781,8 @@ eww-restore-desktop (setq eww-history (cdr (plist-get misc-data :history)) eww-data (or (car (plist-get misc-data :history)) ;; backwards compatibility - (list :url (plist-get misc-data :uri)))) + (list :url (plist-get misc-data :uri))) + eww-history-position (plist-get misc-data :history-position)) (unless file-name (when (plist-get eww-data :url) (cl-case eww-restore-desktop @@ -2784,8 +2794,6 @@ eww-restore-desktop ;; . (current-buffer))) -(add-to-list 'desktop-locals-to-save - 'eww-history-position) (add-to-list 'desktop-buffer-mode-handlers '(eww-mode . eww-restore-desktop)) =2D- 2.40.1 --=-=-= Content-Type: text/plain Regards, James --=-=-=--