* kill-word & friends in ZLE @ 1996-05-15 23:02 Hrvoje Niksic 1996-05-15 23:18 ` Zefram 1996-05-15 23:47 ` Bart Schaefer 0 siblings, 2 replies; 9+ messages in thread From: Hrvoje Niksic @ 1996-05-15 23:02 UTC (permalink / raw) To: zsh-workers It is quite irritating for me that in zsh's Emacs mode functions like backward-kill-word and similar behave in a different fashion. Examples: fly% cd /usr/local/lib/gwembljh[Esc-Backspace] and everything is erased, instead of just gwembljh. The same applies for {backward,forward}-word. Since zshparam man-page states that zsh uses the value of WORDCHARS for this purpose, I think the default value should be changed at least not to contain '/', if not to an empty string (for strict Emacs compliance, since Emacs recognizes all of the default wordchars as word boundaries). If I understood the situation correctly, the patch should be something like: *** Src/system.h.orig Thu May 16 00:29:00 1996 --- Src/system.h Thu May 16 01:01:54 1996 *************** *** 305,311 **** # define DEFAULT_WATCHFMT "%n has %a %l." #endif ! #define DEFAULT_WORDCHARS "*?_-.[]~=/&;!#$%^(){}<>" #define DEFAULT_TIMEFMT "%J %U user %S system %P cpu %*E total" /* Posix getpgrp takes no argument, while the BSD version * --- 305,311 ---- # define DEFAULT_WATCHFMT "%n has %a %l." #endif ! #define DEFAULT_WORDCHARS "" /* For Emacs compliance */ #define DEFAULT_TIMEFMT "%J %U user %S system %P cpu %*E total" /* Posix getpgrp takes no argument, while the BSD version * -- hniksic@srce.hr | Student of electrical engineering hniksic@fly.cc.fer.hr | University of Zagreb, Croatia ------------------------------------------------------------------ `VI' - An editor used by those heretics that don't subscribe to the Emacs religion. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: kill-word & friends in ZLE 1996-05-15 23:02 kill-word & friends in ZLE Hrvoje Niksic @ 1996-05-15 23:18 ` Zefram 1996-05-16 14:56 ` Mike Kazda 1996-05-15 23:47 ` Bart Schaefer 1 sibling, 1 reply; 9+ messages in thread From: Zefram @ 1996-05-15 23:18 UTC (permalink / raw) To: hniksic; +Cc: zsh-workers >It is quite irritating for me that in zsh's Emacs mode functions like >backward-kill-word and similar behave in a different fashion. Examples: > >fly% cd /usr/local/lib/gwembljh[Esc-Backspace] > >and everything is erased, instead of just gwembljh. The vi word functions (vi-{for,back}ward-word, etc.) are more like what you want. Or you could just modify WORDCHARS in your .zshrc. -zefram ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: kill-word & friends in ZLE 1996-05-15 23:18 ` Zefram @ 1996-05-16 14:56 ` Mike Kazda 1996-05-16 17:09 ` Barton E. Schaefer 0 siblings, 1 reply; 9+ messages in thread From: Mike Kazda @ 1996-05-16 14:56 UTC (permalink / raw) To: Zefram; +Cc: zsh-workers >>>>> "Zefram" == Zefram <A.Main@dcs.warwick.ac.uk> writes: >> It is quite irritating for me that in zsh's Emacs mode >> functions like backward-kill-word and similar behave in a >> different fashion. Examples: >> >> fly% cd /usr/local/lib/gwembljh[Esc-Backspace] >> >> and everything is erased, instead of just gwembljh. I've had this problem ever since switching to zsh and I never really complained about it. But it is a big complaint of mine. Zefram> The vi word functions (vi-{for,back}ward-word, etc.) are Zefram> more like what you want. Or you could just modify Zefram> WORDCHARS in your .zshrc. I tried setting the following in zsh (beta17) and it had no effect: WORDCHARS='*?_-.[]~=/&;!#$%^(){}<>' Do you have any hints? I feel that the default behavior should work like emacs or ksh using emacs mode. Meaning if you do [Escape-Backspace] on something which has slashes in it (which I would do all the time on pathnames that I mess up in typing) it should kill only back to the next slash. Mike ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: kill-word & friends in ZLE 1996-05-16 14:56 ` Mike Kazda @ 1996-05-16 17:09 ` Barton E. Schaefer 0 siblings, 0 replies; 9+ messages in thread From: Barton E. Schaefer @ 1996-05-16 17:09 UTC (permalink / raw) To: Mike Kazda, hniksic; +Cc: zsh-workers On May 16, 2:00pm, Hrvoje Niksic wrote: } Subject: Re: kill-word & friends in ZLE } } In your mail, you said: } [...] } > Another satisifactory option would be something like "yank-word", so I } > could yank back the most-recently-killed word, rather the whole line, } } Why don't you use C-y? This works for me: } fly% ls foo bar[Esc-Backspace][C-y] } erases and returns bar on the line. Yes, but: % ls foo bar[esc-backspace][esc-backspace][c-y] erases and then returns "foo bar". What I want to do is erase "foo bar" and then return only "foo". "Undo" is the closest approximation. } Furthermore, all the kills enter the } kill-ring and are reaccessible. Doesn't help, because "foo" isn't in the kill ring all by itself, it's in the same kill-ring entry with "bar". On May 16, 10:56am, (Mike Kazda) wrote: } Subject: Re: kill-word & friends in ZLE } } I tried setting the following in zsh (beta17) and it had no effect: } } WORDCHARS='*?_-.[]~=/&;!#$%^(){}<>' } } Do you have any hints? WORDCHARS has always bugged me because it does NOT specify characters that are word *breaks*, it specifies characters *in addition to alphabetics and numerals* that are *included* in words. So you need to *remove* characters from WORDCHARS to get them to be taken as word breaks. That's why this thread started with a patch to default WORDCHARS to nothing at all. -- Bart Schaefer Vice President, Technology, Z-Code Software schaefer@z-code.com Division of NCD Software Corporation http://www.well.com/www/barts http://www.ncdsoft.com/ZMail/ ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: kill-word & friends in ZLE 1996-05-15 23:02 kill-word & friends in ZLE Hrvoje Niksic 1996-05-15 23:18 ` Zefram @ 1996-05-15 23:47 ` Bart Schaefer 1996-05-16 1:12 ` Wayne Davison 1996-05-16 12:00 ` Hrvoje Niksic 1 sibling, 2 replies; 9+ messages in thread From: Bart Schaefer @ 1996-05-15 23:47 UTC (permalink / raw) To: zsh-workers On May 16, 1:02am, Hrvoje Niksic wrote: } Subject: kill-word & friends in ZLE } } It is quite irritating for me that in zsh's Emacs mode functions like } backward-kill-word and similar behave in a different fashion. Examples: } } fly% cd /usr/local/lib/gwembljh[Esc-Backspace] } } and everything is erased, instead of just gwembljh. The same applies for } {backward,forward}-word. An annoying effect of removing '/' from WORDCHARS is: diff -u /usr/tmp/foo ^ With cursor here, press alt-backspace four times. diff ^ Cursor is now here. I really didn't want to erase the -u, just up through the slash. My fingers just don't let go of the alt key automatically enough when I get down to only the single slash. If I switch to vi-backward-kill-word, then you have to press ctrl-W *six* times to erase the whole path. Using kill-word to erase a single slash seems far too jerky, except when the slash is by itself. What I really want is for the word-erase to treat a trailing slash (or one all by itself) as part of a word, but to treat a leading or embedded slash as a word boundary. I'd settle for this: diff -u /usr/tmp/foo ^ With cursor here, something-kill-word leaves you with: diff -u /usr/tmp ^ Cursor here. Two more kills leave: diff -u ^ Cursor here. I.e., consume the word *and* the non-word to its left, up to the end of the previous word. (The emacs behavior is to first kill the non-word at the *right* and then kill the word.) Its much easier to retype the space or slash than to retype an entire accidentally-killed word. Yes, I know this is neither emacs behavior nor vi behavior, but it would be nice if there were some way it could be programmed. Another satisifactory option would be something like "yank-word", so I could yank back the most-recently-killed word, rather the whole line, when I accidentally press alt-backspace once too often. Oh, well, I'm just grumbling. -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.nbn.com/people/lantern New male in /home/schaefer: >N 2 Justin William Schaefer Sat May 11 03:43 53/4040 "Happy Birthday" ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: kill-word & friends in ZLE 1996-05-15 23:47 ` Bart Schaefer @ 1996-05-16 1:12 ` Wayne Davison [not found] ` <wayne@clari.net> 1996-05-16 12:00 ` Hrvoje Niksic 1 sibling, 1 reply; 9+ messages in thread From: Wayne Davison @ 1996-05-16 1:12 UTC (permalink / raw) To: schaefer; +Cc: zsh-workers Bart Schaefer writes: > Another satisifactory option would be something like "yank-word", so I > could yank back the most-recently-killed word, rather the whole line, > when I accidentally press alt-backspace once too often. Use Ctrl-_ (control underscore) to undo the last word delete. ..wayne.. ^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <wayne@clari.net>]
* Re: kill-word & friends in ZLE [not found] ` <wayne@clari.net> @ 1996-05-16 0:49 ` Bart Schaefer 1996-05-16 22:17 ` Wayne Davison 0 siblings, 1 reply; 9+ messages in thread From: Bart Schaefer @ 1996-05-16 0:49 UTC (permalink / raw) To: zsh-workers On May 15, 6:12pm, Wayne Davison wrote: } Subject: Re: kill-word & friends in ZLE } } Bart Schaefer writes: } > yank back the most-recently-killed word, rather the whole line, } } Use Ctrl-_ (control underscore) to undo the last word delete. (Hand smacks forehead) I never think of using that "undo" binding, because ctrl-shift-minus != ctrl-underscore on the keyboards I used to use. I'll just have to think of another key to bind it to ... I'd still rather have more complicated solution, though. :-) -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.nbn.com/people/lantern New male in /home/schaefer: >N 2 Justin William Schaefer Sat May 11 03:43 53/4040 "Happy Birthday" ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: kill-word & friends in ZLE 1996-05-16 0:49 ` Bart Schaefer @ 1996-05-16 22:17 ` Wayne Davison 0 siblings, 0 replies; 9+ messages in thread From: Wayne Davison @ 1996-05-16 22:17 UTC (permalink / raw) To: schaefer; +Cc: zsh-workers Bart Schaefer writes: > I'd still rather have more complicated solution, though. :-) Here's a more complicated solution for you: I've added an environment variable ``WORDCHARS2'' (which should probably have a better name...) that lists the characters that you want to SOMETIMES be treated as word chars (it's OK if WORDCHARS contains these characters as well). In the context of word movement and deletion, the code will allow WORDCHARS words to be broken up by the delimiters listed in WORDCHARS2, but it also allows WORDCHARS2 words to be broken up by non-word characters. It doesn't stop at every single transition from one set to the next, though -- it tries to be smarter than that (whether it succeeds or not is for you to decide). The default value for WORDCHARS2 is empty, so the word functions behave as they did before unless you customize it. To give the new stuff a try, do something like this: WORDCHARS2='''"/' and see if you like it. Internally: I've created a level of wordishness. 0 is never a word character, 1 is sometimes a word character, and 2 is always a word character. When we are searching for words we look for certain increasing or decreasing transitions in the wordishness and stop when we find the one we like. I also removed the support for "wordflag" from the emacsforwardword function since this kludge would only potentially limit some vi word function to any non-word characters before a word. That's not what a vi user would want even if they were silly enough to be using the emacs function in the first place. Otherwise, no vi functions were modified. ..wayne.. ---8<------8<------8<------8<---cut here--->8------>8------>8------>8--- Index: Src/globals.h @@ -332,7 +332,8 @@ EXTERN char *rprompt; /* $RPROMPT */ EXTERN char *sprompt; -EXTERN char *wordchars; +EXTERN char *wordchars; /* $WORDCHARS */ +EXTERN char *wordchars2; /* $WORDCHARS2 */ EXTERN char *rstring, *Rstring; EXTERN char *postedit; Index: Src/hashtable.h @@ -106,6 +106,7 @@ IPDEF2("HOME", homegetfn, homesetfn, 0), IPDEF2("TERM", termgetfn, termsetfn, 0), IPDEF2("WORDCHARS", wordcharsgetfn, wordcharssetfn, 0), +IPDEF2("WORDCHARS2", wordchars2getfn, wordchars2setfn, 0), IPDEF2("IFS", ifsgetfn, ifssetfn, 0), IPDEF2("_", underscoregetfn, IFN(nullsetfn), PM_READONLY), #ifdef LC_ALL Index: Src/init.c @@ -599,6 +599,7 @@ ifs = ztrdup(" \t\n "); ifs[3] = Meta; wordchars = ztrdup(DEFAULT_WORDCHARS); + wordchars2 = ztrdup(""); postedit = ztrdup(""); underscore = ztrdup(""); Index: Src/params.c @@ -1694,6 +1694,29 @@ inittyptab(); } +/* Function to get value for special parameter `WORDCHARS2' */ + +/**/ +char * +wordchars2getfn(Param pm) +{ + return wordchars2; +} + +/* Function to set value of special parameter `WORDCHARS2' */ + +/**/ +void +wordchars2setfn(Param pm, char *x) +{ + zsfree(wordchars2); + if (x) + wordchars2 = x; + else + wordchars2 = ztrdup(""); + inittyptab(); +} + /* Function to get value for special parameter `_' */ /**/ Index: Src/utils.c @@ -2472,6 +2472,8 @@ typtab[STOUC(*s == Meta ? *++s ^ 32 : *s)] |= ISEP; for (s = wordchars; *s; s++) typtab[STOUC(*s == Meta ? *++s ^ 32 : *s)] |= IWORD; + for (s = wordchars2; *s; s++) + typtab[STOUC(*s == Meta ? *++s ^ 32 : *s)] |= IWORD2; for (s = SPECCHARS; *s; s++) typtab[STOUC(*s)] |= ISPECIAL; if (unset(NOBANGHIST) && bangchar) Index: Src/zle_word.c @@ -36,17 +36,20 @@ void forwardword(void) { + int ci, nci; + if (mult < 0) { mult = -mult; backwardword(); return; } while (mult--) { - while (cs != ll && iword(line[cs])) - cs++; - if (wordflag && !mult) + if (wordflag && !mult) { + while (cs != ll && iword(line[cs])) + cs++; return; - while (cs != ll && !iword(line[cs])) + } + for (ci = 2; cs != ll && (nci = iindex(line[cs])) <= ci; ci = nci) cs++; } } @@ -97,17 +100,15 @@ void emacsforwardword(void) { + int ci, nci; + if (mult < 0) { mult = -mult; emacsbackwardword(); return; } while (mult--) { - while (cs != ll && !iword(line[cs])) - cs++; - if (wordflag && !mult) - return; - while (cs != ll && iword(line[cs])) + for (ci = 0; cs != ll && (nci = iindex(line[cs])) >= ci; ci = nci) cs++; } } @@ -156,15 +157,15 @@ void backwardword(void) { + int ci, nci; + if (mult < 0) { mult = -mult; forwardword(); return; } while (mult--) { - while (cs && !iword(line[cs - 1])) - cs--; - while (cs && iword(line[cs - 1])) + for (ci = 0; cs && (nci = iindex(line[cs - 1])) >= ci; ci = nci) cs--; } } @@ -211,15 +212,15 @@ void emacsbackwardword(void) { + int ci, nci; + if (mult < 0) { mult = -mult; emacsforwardword(); return; } while (mult--) { - while (cs && !iword(line[cs - 1])) - cs--; - while (cs && iword(line[cs - 1])) + for (ci = 0; cs && (nci = iindex(line[cs - 1])) >= ci; ci = nci) cs--; } } @@ -228,7 +229,7 @@ void backwarddeleteword(void) { - int x = cs; + int ci, nci, x = cs; if (mult < 0) { mult = -mult; @@ -236,9 +237,7 @@ return; } while (mult--) { - while (x && !iword(line[x - 1])) - x--; - while (x && iword(line[x - 1])) + for (ci = 0; x && (nci = iindex(line[x - 1])) >= ci; ci = nci) x--; } backdel(cs - x); @@ -272,7 +271,7 @@ void backwardkillword(void) { - int x = cs; + int ci, nci, x = cs; if (mult < 0) { mult = -mult; @@ -280,9 +279,7 @@ return; } while (mult--) { - while (x && !iword(line[x - 1])) - x--; - while (x && iword(line[x - 1])) + for (ci = 0; x && (nci = iindex(line[x - 1])) >= ci; ci = nci) x--; } backkill(cs - x, 1); @@ -357,7 +354,7 @@ void deleteword(void) { - int x = cs; + int ci, nci, x = cs; if (mult < 0) { mult = -mult; @@ -365,9 +362,7 @@ return; } while (mult--) { - while (x != ll && !iword(line[x])) - x++; - while (x != ll && iword(line[x])) + for (ci = 0; x != ll && (nci = iindex(line[x])) >= ci; ci = nci) x++; } foredel(x - cs); @@ -377,7 +372,7 @@ void killword(void) { - int x = cs; + int ci, nci, x = cs; if (mult < 0) { mult = -mult; @@ -385,9 +380,7 @@ return; } while (mult--) { - while (x != ll && !iword(line[x])) - x++; - while (x != ll && iword(line[x])) + for (ci = 0; x != ll && (nci = iindex(line[x])) >= ci; ci = nci) x++; } forekill(x - cs, 0); Index: Src/ztype.h @@ -42,6 +42,7 @@ #define IWORD 1024 #define ISPECIAL 2048 #define IMETA 4096 +#define IWORD2 8192 #define _icom(X,Y) (typtab[(int) (unsigned char) (X)] & Y) #define idigit(X) _icom(X,IDIGIT) #define ialnum(X) _icom(X,IALNUM) @@ -56,3 +57,5 @@ #define iword(X) _icom(X,IWORD) #define ispecial(X) _icom(X,ISPECIAL) #define imeta(X) _icom(X,IMETA) +#define iword2(X) _icom(X,IWORD2) +#define iindex(X) (iword2(X)? 1 : (iword(X)? 2 : 0)) ---8<------8<------8<------8<---cut here--->8------>8------>8------>8--- ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: kill-word & friends in ZLE 1996-05-15 23:47 ` Bart Schaefer 1996-05-16 1:12 ` Wayne Davison @ 1996-05-16 12:00 ` Hrvoje Niksic 1 sibling, 0 replies; 9+ messages in thread From: Hrvoje Niksic @ 1996-05-16 12:00 UTC (permalink / raw) To: schaefer; +Cc: zsh-workers In your mail, you said: [...] > Another satisifactory option would be something like "yank-word", so I > could yank back the most-recently-killed word, rather the whole line, > when I accidentally press alt-backspace once too often. Why don't you use C-y? This works for me: fly% ls foo bar[Esc-Backspace][C-y] erases and returns bar on the line. Furthermore, all the kills enter the kill-ring and are reaccessible. -- hniksic@srce.hr | Student of electrical engineering hniksic@fly.cc.fer.hr | University of Zagreb, Croatia ------------------------------------------------------------------ `VI' - An editor used by those heretics that don't subscribe to the Emacs religion. ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~1996-05-16 22:42 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 1996-05-15 23:02 kill-word & friends in ZLE Hrvoje Niksic 1996-05-15 23:18 ` Zefram 1996-05-16 14:56 ` Mike Kazda 1996-05-16 17:09 ` Barton E. Schaefer 1996-05-15 23:47 ` Bart Schaefer 1996-05-16 1:12 ` Wayne Davison [not found] ` <wayne@clari.net> 1996-05-16 0:49 ` Bart Schaefer 1996-05-16 22:17 ` Wayne Davison 1996-05-16 12:00 ` Hrvoje Niksic
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).