zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH 0/2] Useful default of HISTSIZE
@ 2022-08-31  3:18 Felipe Contreras
  2022-08-31  3:18 ` [PATCH 1/2] Set SAVEHIST to $HISTSIZE by default Felipe Contreras
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Felipe Contreras @ 2022-08-31  3:18 UTC (permalink / raw)
  To: zsh-workers
  Cc: Peter Stephenson, Daniel Shahaf, Bart Schaefer, Felipe Contreras

If we are going to recommend to most new users to set HISTSIZE to 1000,
then it makes more sense to set that as default instead of 30. The less
options we bother new users with, the better.

We are not in 1990 anymore (when in fact the default was 128).

Felipe Contreras (2):
  Set SAVEHIST to $HISTSIZE by default
  Increase default HISTSIZE to 1000

 Etc/FAQ.yo                            | 17 +++++++----------
 Functions/Newuser/zsh-newuser-install |  3 +--
 StartupFiles/zshrc                    |  2 +-
 configure.ac                          |  2 +-
 4 files changed, 10 insertions(+), 14 deletions(-)

-- 
2.37.2.351.g9bf691b78c.dirty



^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/2] Set SAVEHIST to $HISTSIZE by default
  2022-08-31  3:18 [PATCH 0/2] Useful default of HISTSIZE Felipe Contreras
@ 2022-08-31  3:18 ` Felipe Contreras
  2022-09-02  8:59   ` Daniel Shahaf
  2022-08-31  3:18 ` [PATCH 2/2] Increase default HISTSIZE to 1000 Felipe Contreras
  2022-08-31  3:39 ` [PATCH 0/2] Useful default of HISTSIZE Lawrence Velázquez
  2 siblings, 1 reply; 12+ messages in thread
From: Felipe Contreras @ 2022-08-31  3:18 UTC (permalink / raw)
  To: zsh-workers
  Cc: Peter Stephenson, Daniel Shahaf, Bart Schaefer, Felipe Contreras

If they are the same, this makes it clearer that they are the same.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 Etc/FAQ.yo                            | 2 +-
 Functions/Newuser/zsh-newuser-install | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Etc/FAQ.yo b/Etc/FAQ.yo
index 8c795685a..dd573767e 100644
--- a/Etc/FAQ.yo
+++ b/Etc/FAQ.yo
@@ -1631,7 +1631,7 @@ label(321)
   verb(
     HISTSIZE=200
     HISTFILE=~/.zsh_history
-    SAVEHIST=200
+    SAVEHIST=$HISTSIZE
   )
   tt($HISTSIZE) tells the shell how many lines to keep internally,
   tt($HISTFILE) tells it where to write the history, and tt($SAVEHIST),
diff --git a/Functions/Newuser/zsh-newuser-install b/Functions/Newuser/zsh-newuser-install
index 9e911d07c..386844a71 100644
--- a/Functions/Newuser/zsh-newuser-install
+++ b/Functions/Newuser/zsh-newuser-install
@@ -792,7 +792,7 @@ __zni_history_config() {
   __zni_apply_defaults -p \
     HISTSIZE 1000 "Number of lines of history kept within the shell." \
     HISTFILE $zdmsg/.histfile "File where history is saved." \
-    SAVEHIST 1000 "Number of lines of history to save to \$HISTFILE."
+    SAVEHIST \$HISTSIZE "Number of lines of history to save to \$HISTFILE."
 
   if __zni_display_and_edit "History configuration"; then
     install_state[history]="Unsaved changes"
-- 
2.37.2.351.g9bf691b78c.dirty



^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 2/2] Increase default HISTSIZE to 1000
  2022-08-31  3:18 [PATCH 0/2] Useful default of HISTSIZE Felipe Contreras
  2022-08-31  3:18 ` [PATCH 1/2] Set SAVEHIST to $HISTSIZE by default Felipe Contreras
@ 2022-08-31  3:18 ` Felipe Contreras
  2022-09-02  9:01   ` Daniel Shahaf
  2022-08-31  3:39 ` [PATCH 0/2] Useful default of HISTSIZE Lawrence Velázquez
  2 siblings, 1 reply; 12+ messages in thread
From: Felipe Contreras @ 2022-08-31  3:18 UTC (permalink / raw)
  To: zsh-workers
  Cc: Peter Stephenson, Daniel Shahaf, Bart Schaefer, Felipe Contreras

If the default is sensible it's not necessary for the user to change it.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 Etc/FAQ.yo                            | 13 +++++--------
 Functions/Newuser/zsh-newuser-install |  1 -
 StartupFiles/zshrc                    |  2 +-
 configure.ac                          |  2 +-
 4 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/Etc/FAQ.yo b/Etc/FAQ.yo
index dd573767e..4c058c363 100644
--- a/Etc/FAQ.yo
+++ b/Etc/FAQ.yo
@@ -1626,19 +1626,16 @@ work?)
 sect(Why is my history not being saved?)
 label(321)
 
-  In zsh, you need to set three variables to make sure your history is
+  In zsh, you need to set two variables to make sure your history is
   written out when the shell exits.  For example,
   verb(
-    HISTSIZE=200
     HISTFILE=~/.zsh_history
     SAVEHIST=$HISTSIZE
   )
-  tt($HISTSIZE) tells the shell how many lines to keep internally,
-  tt($HISTFILE) tells it where to write the history, and tt($SAVEHIST),
-  the easiest one to forget, tells it how many to write out.  The
-  simplest possibility is to set it to the same as tt($HISTSIZE) as
-  above.  There are also various options affecting history; see the
-  manual.
+  tt($HISTFILE) tells the shell where to write the history, and tt($SAVEHIST)
+  tells it how many lines to write out.  The simplest possibility is to set it
+  to the same as tt($HISTSIZE) as above.  There are also various options
+  affecting history; see the manual.
 
 sect(How do I get a variable's value to be evaluated as another variable?)
 
diff --git a/Functions/Newuser/zsh-newuser-install b/Functions/Newuser/zsh-newuser-install
index 386844a71..46b1639c5 100644
--- a/Functions/Newuser/zsh-newuser-install
+++ b/Functions/Newuser/zsh-newuser-install
@@ -790,7 +790,6 @@ ${(F)unparsed}
 
 __zni_history_config() {
   __zni_apply_defaults -p \
-    HISTSIZE 1000 "Number of lines of history kept within the shell." \
     HISTFILE $zdmsg/.histfile "File where history is saved." \
     SAVEHIST \$HISTSIZE "Number of lines of history to save to \$HISTFILE."
 
diff --git a/StartupFiles/zshrc b/StartupFiles/zshrc
index d4e1d03cc..f8a0233bf 100644
--- a/StartupFiles/zshrc
+++ b/StartupFiles/zshrc
@@ -79,7 +79,7 @@ export HELPDIR=/usr/share/zsh/$ZSH_VERSION/help  # directory for run-help functi
 unalias run-help && autoload -Uz run-help
 
 MAILCHECK=300
-HISTSIZE=200
+HISTSIZE=1000
 DIRSTACKSIZE=20
 
 # Watch for my friends
diff --git a/configure.ac b/configure.ac
index 890ef8dd2..6ca5c9189 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3213,7 +3213,7 @@ AH_TOP([/***** begin user configuration section *****/
 #define USE_SUSPENDED 1
  
 /* The default history buffer size in lines */
-#define DEFAULT_HISTSIZE 30
+#define DEFAULT_HISTSIZE 1000
 
 /* The default editor for the fc builtin */
 #define DEFAULT_FCEDIT "vi"
-- 
2.37.2.351.g9bf691b78c.dirty



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/2] Useful default of HISTSIZE
  2022-08-31  3:18 [PATCH 0/2] Useful default of HISTSIZE Felipe Contreras
  2022-08-31  3:18 ` [PATCH 1/2] Set SAVEHIST to $HISTSIZE by default Felipe Contreras
  2022-08-31  3:18 ` [PATCH 2/2] Increase default HISTSIZE to 1000 Felipe Contreras
@ 2022-08-31  3:39 ` Lawrence Velázquez
  2022-08-31  5:57   ` Felipe Contreras
  2 siblings, 1 reply; 12+ messages in thread
From: Lawrence Velázquez @ 2022-08-31  3:39 UTC (permalink / raw)
  To: Felipe Contreras; +Cc: zsh-workers

On Tue, Aug 30, 2022, at 11:18 PM, Felipe Contreras wrote:
> Felipe Contreras (2):
>   Set SAVEHIST to $HISTSIZE by default
>   Increase default HISTSIZE to 1000

Do these supersede your patches from workers/50500 and workers/50501?

-- 
vq


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/2] Useful default of HISTSIZE
  2022-08-31  3:39 ` [PATCH 0/2] Useful default of HISTSIZE Lawrence Velázquez
@ 2022-08-31  5:57   ` Felipe Contreras
  0 siblings, 0 replies; 12+ messages in thread
From: Felipe Contreras @ 2022-08-31  5:57 UTC (permalink / raw)
  To: Lawrence Velázquez; +Cc: zsh-workers

On Tue, Aug 30, 2022 at 10:40 PM Lawrence Velázquez <larryv@zsh.org> wrote:
>
> On Tue, Aug 30, 2022, at 11:18 PM, Felipe Contreras wrote:
> > Felipe Contreras (2):
> >   Set SAVEHIST to $HISTSIZE by default
> >   Increase default HISTSIZE to 1000
>
> Do these supersede your patches from workers/50500 and workers/50501?

Yes and no. Those patches were for discussion purposes only, that's
why they are marked as RFC.

This patch superseeds workers/50501, but not workers/50500. Depending
on the result of this series I might send another one that supersedes
workers/50500.

-- 
Felipe Contreras


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/2] Set SAVEHIST to $HISTSIZE by default
  2022-08-31  3:18 ` [PATCH 1/2] Set SAVEHIST to $HISTSIZE by default Felipe Contreras
@ 2022-09-02  8:59   ` Daniel Shahaf
  2022-09-02  9:29     ` Felipe Contreras
  0 siblings, 1 reply; 12+ messages in thread
From: Daniel Shahaf @ 2022-09-02  8:59 UTC (permalink / raw)
  To: zsh-workers

Felipe Contreras wrote on Tue, Aug 30, 2022 at 22:18:53 -0500:
> If they are the same, this makes it clearer that they are the same.
> 
> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> ---
>  Etc/FAQ.yo                            | 2 +-
>  Functions/Newuser/zsh-newuser-install | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/Etc/FAQ.yo b/Etc/FAQ.yo
> index 8c795685a..dd573767e 100644
> --- a/Etc/FAQ.yo
> +++ b/Etc/FAQ.yo
> @@ -1631,7 +1631,7 @@ label(321)
>    verb(
>      HISTSIZE=200
>      HISTFILE=~/.zsh_history
> -    SAVEHIST=200
> +    SAVEHIST=$HISTSIZE

Personally, I'm not going to commit this since I find the increased
semantic precision / DRY compliance to be outweighed by the reduced
readability (both here and in the code below, but for different
reasons).

>    )
>    tt($HISTSIZE) tells the shell how many lines to keep internally,
>    tt($HISTFILE) tells it where to write the history, and tt($SAVEHIST),
> diff --git a/Functions/Newuser/zsh-newuser-install b/Functions/Newuser/zsh-newuser-install
> index 9e911d07c..386844a71 100644
> --- a/Functions/Newuser/zsh-newuser-install
> +++ b/Functions/Newuser/zsh-newuser-install
> @@ -792,7 +792,7 @@ __zni_history_config() {
>    __zni_apply_defaults -p \
>      HISTSIZE 1000 "Number of lines of history kept within the shell." \
>      HISTFILE $zdmsg/.histfile "File where history is saved." \
> -    SAVEHIST 1000 "Number of lines of history to save to \$HISTFILE."
> +    SAVEHIST \$HISTSIZE "Number of lines of history to save to \$HISTFILE."
>  
>    if __zni_display_and_edit "History configuration"; then
>      install_state[history]="Unsaved changes"


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/2] Increase default HISTSIZE to 1000
  2022-08-31  3:18 ` [PATCH 2/2] Increase default HISTSIZE to 1000 Felipe Contreras
@ 2022-09-02  9:01   ` Daniel Shahaf
  2022-09-02  9:49     ` Felipe Contreras
  0 siblings, 1 reply; 12+ messages in thread
From: Daniel Shahaf @ 2022-09-02  9:01 UTC (permalink / raw)
  To: Felipe Contreras; +Cc: zsh-workers

Felipe Contreras wrote on Tue, Aug 30, 2022 at 22:18:54 -0500:
> If the default is sensible it's not necessary for the user to change it.
> 
> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> ---
>  Etc/FAQ.yo                            | 13 +++++--------
>  Functions/Newuser/zsh-newuser-install |  1 -
>  StartupFiles/zshrc                    |  2 +-
>  configure.ac                          |  2 +-
>  4 files changed, 7 insertions(+), 11 deletions(-)
> 
> diff --git a/Etc/FAQ.yo b/Etc/FAQ.yo
> index dd573767e..4c058c363 100644
> --- a/Etc/FAQ.yo
> +++ b/Etc/FAQ.yo
> @@ -1626,19 +1626,16 @@ work?)
>  sect(Why is my history not being saved?)
>  label(321)
>  
> -  In zsh, you need to set three variables to make sure your history is
> +  In zsh, you need to set two variables to make sure your history is

If 1/2 is accepted, this sentence will be true for zsh 5.10, but the FAQ
is online and we may assume it's read by users of older releases as
well, so it'd be advisable for the answer to continue to cover 5.9
and older.

>    written out when the shell exits.  For example,
>    verb(
> -    HISTSIZE=200
>      HISTFILE=~/.zsh_history
>      SAVEHIST=$HISTSIZE
>    )
> -  tt($HISTSIZE) tells the shell how many lines to keep internally,
> -  tt($HISTFILE) tells it where to write the history, and tt($SAVEHIST),
> -  the easiest one to forget, tells it how many to write out.  The
> -  simplest possibility is to set it to the same as tt($HISTSIZE) as
> -  above.  There are also various options affecting history; see the
> -  manual.
> +  tt($HISTFILE) tells the shell where to write the history, and tt($SAVEHIST)
> +  tells it how many lines to write out.  The simplest possibility is to set it
> +  to the same as tt($HISTSIZE) as above.  There are also various options
> +  affecting history; see the manual.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/2] Set SAVEHIST to $HISTSIZE by default
  2022-09-02  8:59   ` Daniel Shahaf
@ 2022-09-02  9:29     ` Felipe Contreras
  2022-09-02 10:01       ` Daniel Shahaf
  0 siblings, 1 reply; 12+ messages in thread
From: Felipe Contreras @ 2022-09-02  9:29 UTC (permalink / raw)
  To: Daniel Shahaf; +Cc: zsh-workers

On Fri, Sep 2, 2022 at 3:59 AM Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
> Felipe Contreras wrote on Tue, Aug 30, 2022 at 22:18:53 -0500:

> > If they are the same, this makes it clearer that they are the same.
> >
> > Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> > ---
> >  Etc/FAQ.yo                            | 2 +-
> >  Functions/Newuser/zsh-newuser-install | 2 +-
> >  2 files changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/Etc/FAQ.yo b/Etc/FAQ.yo
> > index 8c795685a..dd573767e 100644
> > --- a/Etc/FAQ.yo
> > +++ b/Etc/FAQ.yo
> > @@ -1631,7 +1631,7 @@ label(321)
> >    verb(
> >      HISTSIZE=200
> >      HISTFILE=~/.zsh_history
> > -    SAVEHIST=200
> > +    SAVEHIST=$HISTSIZE
>
> Personally, I'm not going to commit this since I find the increased
> semantic precision / DRY compliance to be outweighed by the reduced
> readability (both here and in the code below, but for different
> reasons).

But you only need to read it *once* and forget about it forever (or at
least as long as you keep the same history strategy).

On the other hand you might change HISTSIZE more than once. One user
mentioned he added one 0 every time he hit the limit.

-- 
Felipe Contreras


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/2] Increase default HISTSIZE to 1000
  2022-09-02  9:01   ` Daniel Shahaf
@ 2022-09-02  9:49     ` Felipe Contreras
  0 siblings, 0 replies; 12+ messages in thread
From: Felipe Contreras @ 2022-09-02  9:49 UTC (permalink / raw)
  To: Daniel Shahaf; +Cc: zsh-workers

On Fri, Sep 2, 2022 at 4:01 AM Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
> Felipe Contreras wrote on Tue, Aug 30, 2022 at 22:18:54 -0500:

> > If the default is sensible it's not necessary for the user to change it.
> >
> > Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> > ---
> >  Etc/FAQ.yo                            | 13 +++++--------
> >  Functions/Newuser/zsh-newuser-install |  1 -
> >  StartupFiles/zshrc                    |  2 +-
> >  configure.ac                          |  2 +-
> >  4 files changed, 7 insertions(+), 11 deletions(-)
> >
> > diff --git a/Etc/FAQ.yo b/Etc/FAQ.yo
> > index dd573767e..4c058c363 100644
> > --- a/Etc/FAQ.yo
> > +++ b/Etc/FAQ.yo
> > @@ -1626,19 +1626,16 @@ work?)
> >  sect(Why is my history not being saved?)
> >  label(321)
> >
> > -  In zsh, you need to set three variables to make sure your history is
> > +  In zsh, you need to set two variables to make sure your history is
>
> If 1/2 is accepted, this sentence will be true for zsh 5.10

No, it's true for all versions of zsh.

Right now the default value of HISTSIZE is 30, therefore the text is
wrong, you don't need 3 variables, you only need 2: HISTFILE and
SAVEHIST.

In fact, I just learned APPEND_HISTORY is on by default, this means a
HISTSIZE of 30 is actually quite useful. You don't need to increase it
to make sure your history is written, you only need to increase it to
make sure you don't lose any history of your current shell instance.

Either way you don't *need* to set it, with this patch or without it.

And patch 1 certainly doesn't change the situation. All it does is
make sure SAVEHIST is the same as HISTSIZE, whether it's 1000, 200, or
30. HISTSIZE can be removed regardless of the previous patch.

-- 
Felipe Contreras


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/2] Set SAVEHIST to $HISTSIZE by default
  2022-09-02  9:29     ` Felipe Contreras
@ 2022-09-02 10:01       ` Daniel Shahaf
  2022-09-02 13:25         ` Felipe Contreras
  0 siblings, 1 reply; 12+ messages in thread
From: Daniel Shahaf @ 2022-09-02 10:01 UTC (permalink / raw)
  To: Felipe Contreras; +Cc: zsh-workers

Felipe Contreras wrote on Fri, Sep 02, 2022 at 04:29:30 -0500:
> On Fri, Sep 2, 2022 at 3:59 AM Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
> > Felipe Contreras wrote on Tue, Aug 30, 2022 at 22:18:53 -0500:
> 
> > > If they are the same, this makes it clearer that they are the same.
> > >
> > > Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> > > ---
> > >  Etc/FAQ.yo                            | 2 +-
> > >  Functions/Newuser/zsh-newuser-install | 2 +-
> > >  2 files changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/Etc/FAQ.yo b/Etc/FAQ.yo
> > > index 8c795685a..dd573767e 100644
> > > --- a/Etc/FAQ.yo
> > > +++ b/Etc/FAQ.yo
> > > @@ -1631,7 +1631,7 @@ label(321)
> > >    verb(
> > >      HISTSIZE=200
> > >      HISTFILE=~/.zsh_history
> > > -    SAVEHIST=200
> > > +    SAVEHIST=$HISTSIZE
> >
> > Personally, I'm not going to commit this since I find the increased
> > semantic precision / DRY compliance to be outweighed by the reduced
> > readability (both here and in the code below, but for different
> > reasons).
> 
> But you only need to read it *once* and forget about it forever (or at
> least as long as you keep the same history strategy).

You're summing over the wrong variable.  This isn't jrandom's zshrc;
this is the FAQ.  So, don't sum over how often jrandom will read this
passage of their zshrc, but over how often this part of the FAQ will be
read by existing and prospective users.

That's similar to how example code often uses --long-options in
preference to the equivalent one-letter short options, even though
regular users might not /know/ the long option equivalent to a short
option they use daily.

Daniel


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/2] Set SAVEHIST to $HISTSIZE by default
  2022-09-02 10:01       ` Daniel Shahaf
@ 2022-09-02 13:25         ` Felipe Contreras
  2022-09-06 20:13           ` Felipe Contreras
  0 siblings, 1 reply; 12+ messages in thread
From: Felipe Contreras @ 2022-09-02 13:25 UTC (permalink / raw)
  To: Daniel Shahaf; +Cc: zsh-workers

On Fri, Sep 2, 2022 at 5:01 AM Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
> Felipe Contreras wrote on Fri, Sep 02, 2022 at 04:29:30 -0500:
> > On Fri, Sep 2, 2022 at 3:59 AM Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
> > > Felipe Contreras wrote on Tue, Aug 30, 2022 at 22:18:53 -0500:

> > > > If they are the same, this makes it clearer that they are the same.
> > > >
> > > > Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> > > > ---
> > > >  Etc/FAQ.yo                            | 2 +-
> > > >  Functions/Newuser/zsh-newuser-install | 2 +-
> > > >  2 files changed, 2 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/Etc/FAQ.yo b/Etc/FAQ.yo
> > > > index 8c795685a..dd573767e 100644
> > > > --- a/Etc/FAQ.yo
> > > > +++ b/Etc/FAQ.yo
> > > > @@ -1631,7 +1631,7 @@ label(321)
> > > >    verb(
> > > >      HISTSIZE=200
> > > >      HISTFILE=~/.zsh_history
> > > > -    SAVEHIST=200
> > > > +    SAVEHIST=$HISTSIZE
> > >
> > > Personally, I'm not going to commit this since I find the increased
> > > semantic precision / DRY compliance to be outweighed by the reduced
> > > readability (both here and in the code below, but for different
> > > reasons).
> >
> > But you only need to read it *once* and forget about it forever (or at
> > least as long as you keep the same history strategy).
>
> You're summing over the wrong variable.  This isn't jrandom's zshrc;
> this is the FAQ.  So, don't sum over how often jrandom will read this
> passage of their zshrc, but over how often this part of the FAQ will be
> read by existing and prospective users.

First of all the text is wrong, setting HISTFILE is not necessary to
save history, the default is 30, and that works fine.

Now, let's imagine a world in which the text is fixed and HISTSIZE is
not mentioned, what value do we recommend our users to set? By inertia
we would do what we are currently doing, but there's a discrepancy:

    The simplest possibility is to set it to the same as tt($HISTSIZE) as above.

Why is it the simplest possibility? Well, because if you have one next
to the other, you can simply set both to the same value. But now
that's not true, because we don't have the value of HISTSIZE at hand.
We could explain what is the default value of HISTSIZE, and recommend
the users to set that, but it's 30, which is not very useful, we would
want something at least the current recommended value, so this works:

  HISTFILE=~/.zsh_history
  SAVEHIST=200

But what happens if the default value of HISTSIZE is increased? (as it
happens in patch 2) If the value is bigger than 200, it will basically
be ignored, so if the new HISTSIZE is 1000, you potentially could lose
800 entries. Therefore the usefulness of the new default is lost.

And what happens in the year 2050 when computers have 8 TB of RAM and
we decide our users can probably afford a default HISTSIZE of 10000?
Are we going to update the FAQ yet again? Are we going to recommend
users to increase the SAVEHIST accordingly?

None of this is *necessary* for what the objective of the text
initially was, which is to explain why the history is not being saved.

The answer is simple: the history is not saved because SAVEHIST isn't
set and the simplest way to set it is to $HISTSIZE. There is no need
to care what the value of HISTSIZE is, or whether the user sets it or
not, setting SAVEHIST to $HISTSIZE just works, now and forever.

-- 
Felipe Contreras


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/2] Set SAVEHIST to $HISTSIZE by default
  2022-09-02 13:25         ` Felipe Contreras
@ 2022-09-06 20:13           ` Felipe Contreras
  0 siblings, 0 replies; 12+ messages in thread
From: Felipe Contreras @ 2022-09-06 20:13 UTC (permalink / raw)
  To: Daniel Shahaf; +Cc: zsh-workers

On Fri, Sep 2, 2022 at 8:25 AM Felipe Contreras
<felipe.contreras@gmail.com> wrote:
> On Fri, Sep 2, 2022 at 5:01 AM Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
> > Felipe Contreras wrote on Fri, Sep 02, 2022 at 04:29:30 -0500:
> > > On Fri, Sep 2, 2022 at 3:59 AM Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
> > > > Felipe Contreras wrote on Tue, Aug 30, 2022 at 22:18:53 -0500:

> > > > > If they are the same, this makes it clearer that they are the same.
> > > > >
> > > > > Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> > > > > ---
> > > > >  Etc/FAQ.yo                            | 2 +-
> > > > >  Functions/Newuser/zsh-newuser-install | 2 +-
> > > > >  2 files changed, 2 insertions(+), 2 deletions(-)
> > > > >
> > > > > diff --git a/Etc/FAQ.yo b/Etc/FAQ.yo
> > > > > index 8c795685a..dd573767e 100644
> > > > > --- a/Etc/FAQ.yo
> > > > > +++ b/Etc/FAQ.yo
> > > > > @@ -1631,7 +1631,7 @@ label(321)
> > > > >    verb(
> > > > >      HISTSIZE=200
> > > > >      HISTFILE=~/.zsh_history
> > > > > -    SAVEHIST=200
> > > > > +    SAVEHIST=$HISTSIZE
> > > >
> > > > Personally, I'm not going to commit this since I find the increased
> > > > semantic precision / DRY compliance to be outweighed by the reduced
> > > > readability (both here and in the code below, but for different
> > > > reasons).
> > >
> > > But you only need to read it *once* and forget about it forever (or at
> > > least as long as you keep the same history strategy).
> >
> > You're summing over the wrong variable.  This isn't jrandom's zshrc;
> > this is the FAQ.  So, don't sum over how often jrandom will read this
> > passage of their zshrc, but over how often this part of the FAQ will be
> > read by existing and prospective users.
>
> First of all the text is wrong, setting HISTFILE is not necessary to
> save history, the default is 30, and that works fine.
>
> Now, let's imagine a world in which the text is fixed and HISTSIZE is
> not mentioned, what value do we recommend our users to set? By inertia
> we would do what we are currently doing, but there's a discrepancy:
>
>     The simplest possibility is to set it to the same as tt($HISTSIZE) as above.
>
> Why is it the simplest possibility? Well, because if you have one next
> to the other, you can simply set both to the same value. But now
> that's not true, because we don't have the value of HISTSIZE at hand.
> We could explain what is the default value of HISTSIZE, and recommend
> the users to set that, but it's 30, which is not very useful, we would
> want something at least the current recommended value, so this works:
>
>   HISTFILE=~/.zsh_history
>   SAVEHIST=200
>
> But what happens if the default value of HISTSIZE is increased? (as it
> happens in patch 2) If the value is bigger than 200, it will basically
> be ignored, so if the new HISTSIZE is 1000, you potentially could lose
> 800 entries. Therefore the usefulness of the new default is lost.
>
> And what happens in the year 2050 when computers have 8 TB of RAM and
> we decide our users can probably afford a default HISTSIZE of 10000?
> Are we going to update the FAQ yet again? Are we going to recommend
> users to increase the SAVEHIST accordingly?
>
> None of this is *necessary* for what the objective of the text
> initially was, which is to explain why the history is not being saved.
>
> The answer is simple: the history is not saved because SAVEHIST isn't
> set and the simplest way to set it is to $HISTSIZE. There is no need
> to care what the value of HISTSIZE is, or whether the user sets it or
> not, setting SAVEHIST to $HISTSIZE just works, now and forever.

OK. Since I didn't get a reply to my arguments, I went ahead and
increased HISTSIZE first:

https://www.zsh.org/mla/workers/2022/msg00938.html

All my arguments should be more obvious now.

-- 
Felipe Contreras


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2022-09-06 20:13 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-31  3:18 [PATCH 0/2] Useful default of HISTSIZE Felipe Contreras
2022-08-31  3:18 ` [PATCH 1/2] Set SAVEHIST to $HISTSIZE by default Felipe Contreras
2022-09-02  8:59   ` Daniel Shahaf
2022-09-02  9:29     ` Felipe Contreras
2022-09-02 10:01       ` Daniel Shahaf
2022-09-02 13:25         ` Felipe Contreras
2022-09-06 20:13           ` Felipe Contreras
2022-08-31  3:18 ` [PATCH 2/2] Increase default HISTSIZE to 1000 Felipe Contreras
2022-09-02  9:01   ` Daniel Shahaf
2022-09-02  9:49     ` Felipe Contreras
2022-08-31  3:39 ` [PATCH 0/2] Useful default of HISTSIZE Lawrence Velázquez
2022-08-31  5:57   ` Felipe Contreras

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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 NNTP newsgroup(s).