Subject: Re: bug#69232: 30.0.50; [PATCH] EWW history navigation gets caught in a loop

From: Eli Zaretskii <[email-masked]>
Date: Fri, 01 Mar 2024 09:26:41 +0200

> Date: Thu, 29 Feb 2024 18:10:19 -0800
> From: Jim Porter <[email-masked]>
> Cc: Eli Zaretskii <[email-masked]>, [email-masked]
> 
> On 2/29/2024 5:00 PM, Jim Porter wrote:
> > I already found one issue with reloading messing up history, but that 
> > was an easy fix. Once I finish up the other parts of my v3 patch, I'll 
> > post it here.
> 
> I've only lightly tested this so far, but this version adds an 
> 'eww-before-browse-function' option which lets you customize how EWW 
> manipulates history before browsing to a new page. I've added functions 
> for the default behavior ('eww-clear-future-history'), and for cloning 
> all the "parent" entries ('eww-clone-previous-history')[1]. You can also 
> set it to 'ignore', which will just preserve the old entries and add the 
> new page to the end (which is the behavior v1 of my patch had).
> 
> I've also added more regression tests to make sure this all works as 
> expected.
> 
> How does this look?

Thanks.  I have a usability comment below.

> --- a/etc/NEWS
> +++ b/etc/NEWS
> @@ -1004,6 +1004,18 @@ When invoked with the prefix argument ('C-u'),
>  This is useful for continuing reading the URL in the current buffer
>  when the new URL is fetched.
>  
> +---
> +*** History navigation in EWW now works like other browsers.
> +Previously, when navigating back and forward through page history, EWW
> +would add a duplicate entry to the end of the history list each time.
> +This made it impossible to navigate to the "end" of the history list.
> +Now, navigating through history in EWW simply changes your position in
> +the history list, allowing you to reach the end as expected.  In
> +addition, when navigating to a new page from a historical one, EWW

"historical" here should be in quotes (and perhaps explained in
parentheses), otherwise people might misinterpret or fail to
understand what it alludes to.

> +(defcustom eww-before-browse-function #'eww-clear-future-history
> +  "A function to call before browsing to a new page.
> +By default, this removes any entries in the history that come after the
> +current page (see `eww-clear-future-history')."

The doc string should describe the known possible values of the
option.

Now for the usability issue: It's okay to have this is a variable (to
allow future extensions, which might be unrelated to history), but
having a function for user option, and one that is more general than
being about history traversal, is not the best ides: it makes
customization harder for users who are not Lisp programmers.

Therefore, I suggest a history-specific defcustom, whose possible
values could be 'clear', 'clone', and 'add', and whose effect will be
to call the corresponding function via eww-before-browse-function.
The defcustom could also have a user-defined function value to allow
additional functions, of course.