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: Mon, 10 Jun 2024 05:03:59 +0530 Message-ID: <86v82h1yjc.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="30089"; 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 Mon Jun 10 03:11:09 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 1sGTYy-0007g2-1W for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 10 Jun 2024 03:11:08 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sGTYe-0001Ef-Po; Sun, 09 Jun 2024 21:10:48 -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 1sGTYc-0001E9-75 for bug-gnu-emacs@gnu.org; Sun, 09 Jun 2024 21:10:46 -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 1sGTYb-0003Gy-VX for bug-gnu-emacs@gnu.org; Sun, 09 Jun 2024 21:10:45 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sGTYs-0001VU-JS for bug-gnu-emacs@gnu.org; Sun, 09 Jun 2024 21:11:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: James Thomas Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 10 Jun 2024 01:11:02 +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.17179818285640 (code B ref 71450); Mon, 10 Jun 2024 01:11:02 +0000 Original-Received: (at 71450) by debbugs.gnu.org; 10 Jun 2024 01:10:28 +0000 Original-Received: from localhost ([127.0.0.1]:44963 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sGTYJ-0001Sn-MT for submit@debbugs.gnu.org; Sun, 09 Jun 2024 21:10:28 -0400 Original-Received: from mout.gmx.net ([212.227.17.21]:54921) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sGSFd-0005zp-Db for 71450@debbugs.gnu.org; Sun, 09 Jun 2024 19:47:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1717976802; x=1718581602; i=jimjoe@gmx.net; bh=wZKpQjavQaTVKOl94YSYJ/SR2jmZrNF4fljMxiRWMro=; 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=OltwkCoKBjDZx66Ab0t20pZCvCo6X0fSxUWl/64+lWL6lpx8rYJThUsFzQsChEx8 ss+aCy9wUO1PwfWby+WavGM16TwBAuMMIjQlxIRrEJGh8LZjSBzpqWEgack7/+rwu HQmngJQwRtMdzTwk9gYjdo3SOpOF96hPniTAL/VfN60/7lRTu/ILUqfGfvD84peon hdjt4NAArl5RcHahuNgzuIsi3ye6pmNVhDC/sBoNBOeLPDjaQt+oo598OQmgpIfyF 0IQoNX5D8lnToPmllkeu3JGVdfsTfLpl6w94Gf74KbvCByAe4lm8Kha0NPMrFmYHp cNDunb5IBfavvTPGtg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from user-Inspiron-3493 ([42.108.28.97]) by mail.gmx.net (mrgmx104 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MwQXN-1sXQy236ur-00umO6; Mon, 10 Jun 2024 01:34:09 +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:c7o6fvMAEmvzF5/yG2gXT1K2I5DzJQkGC0Jbo9eJsxf03xh5TZD Gp6nvFXHiuuWMym5HARksRpfIUmeCfDnh8Rh3ALCvoAmQCxVezYWWaIJ4wbGuujt6JHQWrd Y7nqPerpaI/MR4n0t9wDrimm1cr6gtUMZnq0MwfwGVvBLFvDFsjgKwLfr32zMulrhOZLq5q LJEySx9bVA3i81ZlvSu6A== UI-OutboundReport: notjunk:1;M01:P0:131nEz3cewM=;2icQXh5hNN77f3kUybReLLcRdx6 5SWXHqjkUxe5M4ZPWF0LrYjLopUMQaEwPCc+7ByIE7qGeKXvuW37Emy9vr03yirm9EY072yoL Yf4FjMXZ/k3HFKOWFAbbcn9Uy92rRYRpIGQQVbmJdg5HQNoppfq5My14/Brgp2hoSlb72iK4G tQrs7EcRnAfdBIgThLwQxYqQUizo2B4kPXcXwzMzF9J1pMwO4/6uaFl+mkJ9itcPSJjhchIIV VVo5tuEErUS9HwhhoNtRqLpcm93Oqe0/irI6Jggk8hb7tTBt2n5an6SxHkEQxexHawF4Qwg3S flCVlHpUKiFsetWWCTMS1PZhi4KShYhcg86A37QE3dlaNXmuk2ixS4hieo7eO2WH/mGb2CwdI 5a52u1QI0BZLkgSfTCsGF23qH+cMbk1PvnAGNJNDtjFy+7tJ4SR3MSDMeW5v/KkZO6Vj9zc03 GSjfKDZNlLZYX2iFMhbp2C3eG4LfmUANsxwPTfvwOBvG8ht9nr5uzGkG3wkSvrI1HIq0qe+lM OMfxH0z7dPSBxtcGJjS9Gj4HPe4i6/X9AjDyRhec+CUQbwDv/HBPrG7ZROzWr8KdiruYSqtTa OW7Hgrw2QRfSLuxcOvlkxZ4STeQF8zxNuWixGc/ExwumZaYboSpVXZiH069ZnQ5y9BX9irMba /Iny6HyyzaGnIQ2Qze1NvnBrD6ujcEgDJB7ZoOKe4HIUnmFeNZSH/y5Uota7GWjoLwGDdw37A 72dj56K968D1oZ0kvTLgELfnojaAM8qfA23pA/EqfEVVVrHk06Idyyf9fQx8bfyTtuTIuK1o 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:287004 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? I'd thought that this would be more robust because it was used for the original removal. But I guess 'eq' would be enough since only succeeding duplicates are removed. > 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. In fact, the following patch was the one with which I got it working originally, before favouring the earlier one for simplicity: --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=alternate.patch Content-Description: Alternate patch Content-Transfer-Encoding: quoted-printable diff --git a/lisp/net/eww.el b/lisp/net/eww.el index 977210e9cc8..98421828bb9 100644 =2D-- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -2755,10 +2755,19 @@ eww-desktop-misc-data :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)))) + (let ((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 #'eww-desktop-history-duplicate))) + 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)) --=-=-= Content-Type: text/plain Regards, James --=-=-=--