zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: revamped history-search-{for,back}ward for 3.1.4
@ 1998-06-09 22:42 Wayne Davison
  1998-06-10  3:58 ` Bart Schaefer
  0 siblings, 1 reply; 7+ messages in thread
From: Wayne Davison @ 1998-06-09 22:42 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers

> It's my assertion that history-search-*ward are now broken and
> should be made to behave the way they used to (but not implemented
> the way they used to be implemented).

Here's one way to implement most of the old behavior without using a
special ZLE flag:

My idea is that most of the time the search gets initialized when we
first leave the "curhist" line, and then we continue to execute the
last search when we're moving around in the history.  This makes the
search more modal than before, since the 3.0.x code used to start a
new search if you did anything but another search.

The new code allows two exceptions to start a new search while up in
the history:  if you set the mark away from the start of the line, or
if the current line becomes too short for the current search to
succeed.

Let me know what you think of the idea.

Since this behavior relies on having a working spaceinline() function
(my code depends on the mark being set to the start of the line),
either apply that patch or just change line 87 of zle_utils.c to be:

    if (mark > cs)

instead of:

    if (mark >= cs)

I happened to find and fix a few other minor problems in zle_hist.c,
but I'll send that stuff separately from this.

..wayne..

---8<------8<------8<------8<---cut here--->8------>8------>8------>8---
Index: Src/Zle/zle_hist.c
@@ -369,17 +369,20 @@
 	feep();
 }
 
+static int histpos;
+
 /**/
 void
 historysearchbackward(void)
 {
-    int histpos, histmpos, hl = histline;
+    int hl = histline;
     char *s;
 
-    for (histpos = histmpos = 0; histpos < ll && !iblank(line[histpos]);
-	histpos++, histmpos++)
-	if(imeta(line[histpos]))
-	    histmpos++;
+    if (histline == curhist || ll < histpos || mark != 0) {
+	for (histpos = 0; histpos < ll && !iblank(line[histpos]); histpos++) ;
+	if (histpos < ll)
+	    histpos++;
+    }
     for (;;) {
 	hl--;
 	if (!(s = zle_get_event(hl))) {
@@ -387,7 +390,6 @@
 	    return;
 	}
 	if (metadiffer(s, (char *) line, histpos) < 0 &&
-	    iblank(s[histmpos] == Meta ? s[histmpos+1]^32 : s[histmpos]) &&
 	    metadiffer(s, (char *) line, ll))
 	    break;
     }
@@ -398,22 +400,21 @@
 void
 historysearchforward(void)
 {
-    int histpos, histmpos, hl = histline;
+    int hl = histline;
     char *s;
 
-    for (histpos = histmpos = 0; histpos < ll && !iblank(line[histpos]);
-	histpos++, histmpos++)
-	if(imeta(line[histpos]))
-	    histmpos++;
+    if (histline == curhist || ll < histpos || mark != 0) {
+	for (histpos = 0; histpos < ll && !iblank(line[histpos]); histpos++) ;
+	if (histpos < ll)
+	    histpos++;
+    }
     for (;;) {
 	hl++;
 	if (!(s = zle_get_event(hl))) {
 	    feep();
 	    return;
 	}
-	if (metadiffer(s, (char *) line, histpos) < (histline == curhist) &&
-	    (!s[histmpos] ||
-	     iblank(s[histmpos] == Meta ? s[histmpos+1]^32 : s[histmpos])) &&
+	if (metadiffer(s, (char *) line, histpos) < (hl == curhist) &&
 	    metadiffer(s, (char *) line, ll))
 	    break;
     }
---8<------8<------8<------8<---cut here--->8------>8------>8------>8---


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

end of thread, other threads:[~1998-06-15 16:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-06-09 22:42 PATCH: revamped history-search-{for,back}ward for 3.1.4 Wayne Davison
1998-06-10  3:58 ` Bart Schaefer
1998-06-10  8:51   ` PATCH: even better " Wayne Davison
1998-06-10  9:23     ` Bart Schaefer
1998-06-10  9:33       ` Wayne Davison
1998-06-13  4:06     ` Bart Schaefer
1998-06-15 16:49       ` Wayne Davison

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).