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

Re: Bug#357934: zsh: '-', '.' etc. shouldn't be recognized as word chars



> Hi,
> 
> Vi mode now recognizes '-', '.', as word chars:
> 
> $ a-b
> 
> When pressing 'w' with cursor on 'a', the cursor skips the whole "a-b"
> string. But it should rather stop at '-'.
> 
> One can override this by defining WORDCHARS to letters, but the default
> should really be what documentation says:
> 
> « word characters are alphanumeric characters »
> (which include all characters for which libc's isalnum() returns true).
> 
> This wasn't the case in version 4.3.1-1. The fix for #357313 probably
> needs fixing.

This will do alphanumerics and underscores.  I no longer have any idea
what the correct behavior is supposed to be.

Index: Src/Zle/zle.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle.h,v
retrieving revision 1.27
diff -u -r1.27 zle.h
--- Src/Zle/zle.h	9 Feb 2006 22:12:54 -0000	1.27
+++ Src/Zle/zle.h	20 Mar 2006 14:27:14 -0000
@@ -72,6 +72,7 @@
 
 /* Functions that operate on ZLE_CHAR_T. */
 #define ZC_ialpha iswalpha
+#define ZC_ialnum iswalnum
 #define ZC_iblank wcsiblank
 #define ZC_icntrl iswcntrl
 #define ZC_idigit iswdigit
@@ -137,6 +138,7 @@
 
 /* Functions that operate on ZLE_CHAR_T. */
 #define ZC_ialpha ialpha
+#define ZC_ialpha ialnum
 #define ZC_iblank iblank
 #define ZC_icntrl icntrl
 #define ZC_idigit idigit
Index: Src/Zle/zle_word.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_word.c,v
retrieving revision 1.8
diff -u -r1.8 zle_word.c
--- Src/Zle/zle_word.c	17 Mar 2006 23:45:44 -0000	1.8
+++ Src/Zle/zle_word.c	20 Mar 2006 14:27:14 -0000
@@ -54,7 +54,7 @@
     return 0;
 }
 
-#define Z_vident(X) (ZC_iword(X) || (ZWC('_') == X))
+#define Z_vialnum(X) (ZC_ialnum(X) || (ZWC('_') == X))
 
 /**/
 int
@@ -70,11 +70,11 @@
 	return ret;
     }
     while (n--) {
-	if (Z_vident(zleline[zlecs]))
-	    while (zlecs != zlell && Z_vident(zleline[zlecs]))
+	if (Z_vialnum(zleline[zlecs]))
+	    while (zlecs != zlell && Z_vialnum(zleline[zlecs]))
 		zlecs++;
 	else
-	    while (zlecs != zlell && !Z_vident(zleline[zlecs]) && !ZC_iblank(zleline[zlecs]))
+	    while (zlecs != zlell && !Z_vialnum(zleline[zlecs]) && !ZC_iblank(zleline[zlecs]))
 		zlecs++;
 	if (wordflag && !n)
 	    return 0;
@@ -168,11 +168,11 @@
 	if (ZC_iblank(zleline[zlecs + 1]))
 	    while (zlecs != zlell && ZC_iblank(zleline[zlecs + 1]))
 		zlecs++;
-	if (Z_vident(zleline[zlecs + 1]))
-	    while (zlecs != zlell && Z_vident(zleline[zlecs + 1]))
+	if (Z_vialnum(zleline[zlecs + 1]))
+	    while (zlecs != zlell && Z_vialnum(zleline[zlecs + 1]))
 		zlecs++;
 	else
-	    while (zlecs != zlell && !Z_vident(zleline[zlecs + 1]) && !ZC_iblank(zleline[zlecs + 1]))
+	    while (zlecs != zlell && !Z_vialnum(zleline[zlecs + 1]) && !ZC_iblank(zleline[zlecs + 1]))
 		zlecs++;
     }
     if (zlecs != zlell && virangeflag)
@@ -218,11 +218,11 @@
     while (n--) {
 	while (zlecs && ZC_iblank(zleline[zlecs - 1]))
 	    zlecs--;
-	if (Z_vident(zleline[zlecs - 1]))
-	    while (zlecs && Z_vident(zleline[zlecs - 1]))
+	if (Z_vialnum(zleline[zlecs - 1]))
+	    while (zlecs && Z_vialnum(zleline[zlecs - 1]))
 		zlecs--;
 	else
-	    while (zlecs && !Z_vident(zleline[zlecs - 1]) && !ZC_iblank(zleline[zlecs - 1]))
+	    while (zlecs && !Z_vialnum(zleline[zlecs - 1]) && !ZC_iblank(zleline[zlecs - 1]))
 		zlecs--;
     }
     return 0;
@@ -308,11 +308,11 @@
     while (n--) {
 	while ((x > lim) && ZC_iblank(zleline[x - 1]))
 	    x--;
-	if (Z_vident(zleline[x - 1]))
-	    while ((x > lim) && Z_vident(zleline[x - 1]))
+	if (Z_vialnum(zleline[x - 1]))
+	    while ((x > lim) && Z_vialnum(zleline[x - 1]))
 		x--;
 	else
-	    while ((x > lim) && !Z_vident(zleline[x - 1]) && !ZC_iblank(zleline[x - 1]))
+	    while ((x > lim) && !Z_vialnum(zleline[x - 1]) && !ZC_iblank(zleline[x - 1]))
 		x--;
     }
     backkill(zlecs - x, 1);



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