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.
This commit is contained in:
James Thomas 2024-06-11 03:00:33 +05:30 committed by Jim Porter
parent 2c201bbba5
commit 65b7f87a31

View file

@ -2754,11 +2754,20 @@ Only the properties listed in `eww-desktop-data-save' are included.
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 @@ Otherwise, the restored buffer will contain a prompt to do so by using
(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 @@ Otherwise, the restored buffer will contain a prompt to do so by using
;; .
(current-buffer)))
(add-to-list 'desktop-locals-to-save
'eww-history-position)
(add-to-list 'desktop-buffer-mode-handlers
'(eww-mode . eww-restore-desktop))