From: James Thomas via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 71450@debbugs.gnu.org
Cc: Jim Porter <jporterbugs@gmail.com>
Subject: bug#71450: [PATCH] Wrong eww-history-position after desktop restore if within history
Date: Tue, 11 Jun 2024 03:06:31 +0530 [thread overview]
Message-ID: <86plsobhuo.fsf@gmx.net> (raw)
In-Reply-To: <2fd89234-fab9-a0a3-3bc1-f193983e2cd4@gmail.com> (Jim Porter's message of "Sun, 9 Jun 2024 14:20:56 -0700")
[-- Attachment #1: Type: text/plain, Size: 972 bytes --]
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:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: [PATCH] Account for duplicate removal on restoring --]
[-- Type: text/x-patch, Size: 2524 bytes --]
From bc0e3f2653e1c4c1f683d4b10ff139dbf963ee8d Mon Sep 17 00:00:00 2001
From: James Thomas <jimjoe@gmx.net>
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.
---
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
--- 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))
--
2.40.1
[-- Attachment #3: Type: text/plain, Size: 16 bytes --]
Regards,
James
next prev parent reply other threads:[~2024-06-10 21:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-09 12:23 bug#71450: [PATCH] Wrong eww-history-position after desktop restore if within history James Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-09 21:20 ` Jim Porter
2024-06-09 23:33 ` James Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-10 21:36 ` James Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-06-16 0:01 ` Jim Porter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86plsobhuo.fsf@gmx.net \
--to=bug-gnu-emacs@gnu.org \
--cc=71450@debbugs.gnu.org \
--cc=jimjoe@gmx.net \
--cc=jporterbugs@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).