Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: (rfc) HIST_FIND_DUPS option



Add HIST_FIND_DUPS option so ctrl-r finds identical lines, useful when
you want to ctrl-o through some and it found the wrong sequence. For
example if you have this history:

command you remember
command you want to run
5000 other commands
command you remember
useless command

I am currently unsure why unsetting HIST_FIND_NO_DUPS doesn't have
this behaviour already. Possibly it only finds the same line after
finding another line in between that also matches the search, this
seems like a weird distinction to make to me (if this is the case).

patch if someone wants to try it, not for committing of course since i
didn't add docs:
http://cgit.mika.l3ib.org/cgit/zsh-cvs/commit/?id=034f471caa87

corrupted patch to look at:
diff --git a/Src/Zle/zle_hist.c b/Src/Zle/zle_hist.c
index ed524d3..51d8667 100644
--- a/Src/Zle/zle_hist.c
+++ b/Src/Zle/zle_hist.c
@@ -1415,7 +1415,9 @@ doisearch(char **args, int dir, int pattern)
 		else
 		    skip_line = isset(HISTFINDNODUPS)
 			? !!(he->node.flags & HIST_DUP)
-			: !strcmp(zt, last_line);
+			: isset(HISTFINDDUPS)
+			  ? 0
+			  : !strcmp(zt, last_line);
 	    }
 	    dup_ok = 0;
 	    /*
diff --git a/Src/options.c b/Src/options.c
index 1ce9f41..2b88c7a 100644
--- a/Src/options.c
+++ b/Src/options.c
@@ -146,6 +146,7 @@ static struct optname optns[] = {
 {{NULL, "histbeep",	      OPT_ALL},			 HISTBEEP},
 {{NULL, "histexpiredupsfirst",0},			 HISTEXPIREDUPSFIRST},
 {{NULL, "histfcntllock",      0},			 HISTFCNTLLOCK},
+{{NULL, "histfinddups",       0},			 HISTFINDDUPS},
 {{NULL, "histfindnodups",     0},			 HISTFINDNODUPS},
 {{NULL, "histignorealldups",  0},			 HISTIGNOREALLDUPS},
 {{NULL, "histignoredups",     0},			 HISTIGNOREDUPS},
diff --git a/Src/zsh.h b/Src/zsh.h
index 7f28f69..ba324ac 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -1988,6 +1988,7 @@ enum {
     HISTBEEP,
     HISTEXPIREDUPSFIRST,
     HISTFCNTLLOCK,
+    HISTFINDDUPS,
     HISTFINDNODUPS,
     HISTIGNOREALLDUPS,
     HISTIGNOREDUPS,


-- 
Mikael Magnusson



Messages sorted by: Reverse Date, Date, Thread, Author