zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: HIST_IGNORE_DUPS ignores lines which differ by a different number of spaces
Date: Fri, 19 Apr 2013 20:01:13 -0700	[thread overview]
Message-ID: <130419200113.ZM9865@torch.brasslantern.com> (raw)
In-Reply-To: <20130419134238.7a8a05a3@pwslap01u.europe.root.pri>

I haven't ever really dug into this code, and the last person who did
so I think was probably Wayne when working on HIST_EXPIRE_DUPS_FIRST
back in 1999 and 2002.  It appears Zoltan did most of the work on the
*DUPS* -related stuff even longer ago than that.

With that caveat ...

On Apr 19,  1:42pm, Peter Stephenson wrote:
} Subject: Re: HIST_IGNORE_DUPS ignores lines which differ by a different nu
}
} On Thu, 18 Apr 2013 21:04:11 +0100
} Peter Stephenson <p.w.stephenson@ntlworld.com> wrote:
} > My best guess is it's got something to do with freehistdata(), which
} > appears to be the only way the hash table can affect the history ring.
} 
} Revised theory: when the new node gets added, it retrieves the old node
} (addhistnode() in hashtable.c).  Because of the name mangling it
} retrieves the previous line if that's the same up to (any, even
} significant) white space, even if HIST_IGNORE_DUPS isn't set.  (This is
} what's bamboozling me the most.)

The behavior is supposed to be that the most-recent previous command
line is always retrievable verbatim, regardless of whether history is
ignoring dups or even turned off entirely.  So the editor behavior is
as if HISTSIZE can never be less than 1, even though that line will
never be saved anywhere when HISTSIZE=0.

I vaguely recall from reading the discussions years back that this is
implemented by pushing commands into the "real" history ring only when
the *next* command is accepted, that is, there's some sort of purgatory
where the single previous command goes to wait before being sent to
heaven or hell by the arrival of a new command.

Perhaps that gives some insight into what you're seeing in the code?

} Because there's an old node (at all,
} even if it doesn't match completely) it gets marked as HIST_DUP by
} addhistnode().  Then logic elsewhere removes it.

I would not be surprised to find that the HIST_DUP marker is set for two
reasons:

(1) so HIST_EXPIRE_DUPS_FIRST can work even when NO_HIST_IGNORE_DUPS

(2) to implement HIST_FIND_NO_DUPS even when NO_HIST_IGNORE_DUPS

} It's just occurred to me that while it might get *marked* with HIST_DUP
} undconditionally, the logic to remove duplicates only kicks in if
} HIST_IGNORE_DUPS is set.  That might explain why NO_HIST_IGNORE_DUPS
} works at all.

Don't forget HIST_IGNORE_ALL_DUPS, too ...

Sorry I can't be more helpful.


      reply	other threads:[~2013-04-20  3:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-16 17:05 Vincent Lefevre
2013-04-17 16:41 ` Bart Schaefer
2013-04-18 20:04 ` Peter Stephenson
2013-04-19 12:42   ` Peter Stephenson
2013-04-20  3:01     ` Bart Schaefer [this message]

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=130419200113.ZM9865@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /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.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).