Re: vi: don't escape backspace with backslash
On Mon, Nov 23, 2015 at 12:04:31PM +0100, Claudio Jeker wrote: > On Mon, Nov 23, 2015 at 01:31:11AM -0700, Anthony J. Bentley wrote: > > When I hit backspace after a backslash, usually I just want to delete > > the backslash. I don't think I've ever intended to input a literal ^?. > > If I ever did want to insert ^H, ^?, or ^U, I would just type ^V first. > > > > I've passed this diff around privately before and gotten a tepid > > response, but it was pointed out to me that it would fit better on tech@. > > Original vi had this behaviour. AFAIK no modern vi (esp. all the vim > clones) behaves like this. I never depended on this feature and so think > we can follow the others and drop this magic. I agree. Since there were no objections, I think this would be a welcome change. ok tb@
Re: vi: don't escape backspace with backslash
On 2015-11-23, "Anthony J. Bentley" wrote: > When I hit backspace after a backslash, usually I just want to delete > the backslash. I don't think I've ever intended to input a literal ^?. > If I ever did want to insert ^H, ^?, or ^U, I would just type ^V first. FWIW, I suspect this feature simply predates the existence of LNEXT (^V). The 1992 edition of Stevens calls LNEXT a SVR4 and 4.3+BSD extension. -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: vi: don't escape backspace with backslash
On Mon, Nov 23, 2015 at 01:31:11AM -0700, Anthony J. Bentley wrote: > [...] > I've passed this diff around privately before and gotten a tepid > response, but it was pointed out to me that it would fit better on tech@. > [...] Yes, please. -- Gregor
Re: vi: don't escape backspace with backslash
On Mon, Nov 23, 2015 at 01:31:11AM -0700, Anthony J. Bentley wrote: > When I hit backspace after a backslash, usually I just want to delete > the backslash. I don't think I've ever intended to input a literal ^?. > If I ever did want to insert ^H, ^?, or ^U, I would just type ^V first. > > I've passed this diff around privately before and gotten a tepid > response, but it was pointed out to me that it would fit better on tech@. Original vi had this behaviour. AFAIK no modern vi (esp. all the vim clones) behaves like this. I never depended on this feature and so think we can follow the others and drop this magic. > Index: vi/v_txt.c > === > RCS file: /cvs/src/usr.bin/vi/vi/v_txt.c,v > retrieving revision 1.27 > diff -u -p -u -p -r1.27 v_txt.c > --- vi/v_txt.c12 Nov 2014 04:28:41 - 1.27 > +++ vi/v_txt.c19 Nov 2014 01:17:45 - > @@ -618,30 +617,21 @@ replay: if (LF_ISSET(TXT_REPLAY)) > > /* >* !!! > - * If this character was quoted by a K_VLNEXT or a backslash, replace > - * the placeholder (a carat or a backslash) with the new character. > - * If it was quoted by a K_VLNEXT, we've already adjusted the cursor > - * because it has to appear on top of the placeholder character. If > - * it was quoted by a backslash, adjust the cursor now, the cursor > - * doesn't appear on top of it. Historic practice in both cases. > + * If this character was quoted by a K_VLNEXT, replace the placeholder > + * (a carat) with the new character. We've already adjusted the cursor > + * because it has to appear on top of the placeholder character. > + * Historic practice. >* >* Skip tests for abbreviations; ":ab xa XA" followed by "ixa^V" >* doesn't perform an abbreviation. Special case, ^V^J (not ^V^M) is >* the same as ^J, historically. >*/ > - if (quote == Q_BTHIS || quote == Q_VTHIS) { > + if (quote == Q_VTHIS) { > FL_CLR(ec_flags, EC_QUOTED); > if (LF_ISSET(TXT_MAPINPUT)) > FL_SET(ec_flags, EC_MAPINPUT); > > - if (quote == Q_BTHIS && > - (evp->e_value == K_VERASE || evp->e_value == K_VKILL)) { > - quote = Q_NOTSET; > - --tp->cno; > - ++tp->owrite; > - goto insl_ch; > - } > - if (quote == Q_VTHIS && evp->e_value != K_NL) { > + if (evp->e_value != K_NL) { > quote = Q_NOTSET; > goto insl_ch; > } > @@ -1201,31 +1191,6 @@ leftmargin:tp->lb[tp->cno - 1] = ' '; > if (LF_ISSET(TXT_SHOWMATCH)) > showmatch = 1; > goto ins_ch; > - case K_BACKSLASH: /* Quote next erase/kill. */ > - /* > - * !!! > - * Historic vi tried to make abbreviations after a backslash > - * escape work. If you did ":ab x y", and inserted "x\^H", > - * (assuming the erase character was ^H) you got "x^H", and > - * no abbreviation was done. If you inserted "x\z", however, > - * it tried to back up and do the abbreviation, i.e. replace > - * 'x' with 'y'. The problem was it got it wrong, and you > - * ended up with "zy\". > - * > - * This is really hard to do (you have to remember the > - * word/non-word state, for example), and doesn't make any > - * sense to me. Both backslash and the characters it > - * (usually) escapes will individually trigger the > - * abbreviation, so I don't see why the combination of them > - * wouldn't. I don't expect to get caught on this one, > - * particularly since it never worked right, but I've been > - * wrong before. > - * > - * Do the tests for abbreviations, so ":ab xa XA", > - * "ixa\" performs the abbreviation. > - */ > - quote = Q_BNEXT; > - goto insq_ch; > case K_VLNEXT: /* Quote next character. */ > evp->e_c = '^'; > quote = Q_VNEXT; > @@ -1363,8 +1328,6 @@ ebuf_chk: if (tp->cno >= tp->len) { > > /* Step the quote state forward. */ > if (quote != Q_NOTSET) { > - if (quote == Q_BNEXT) > - quote = Q_BTHIS; > if (quote == Q_VNEXT) > quote = Q_VTHIS; > } > Index: vi/vi.h > === > RCS file: /cvs/src/usr.bin/vi/vi/vi.h,v > retrieving revision 1.7 > diff -u -p -u -p -r1.7 vi.h > --- vi/vi.h 28 Nov 2013 22:12:40 - 1.7
vi: don't escape backspace with backslash
When I hit backspace after a backslash, usually I just want to delete the backslash. I don't think I've ever intended to input a literal ^?. If I ever did want to insert ^H, ^?, or ^U, I would just type ^V first. I've passed this diff around privately before and gotten a tepid response, but it was pointed out to me that it would fit better on tech@. Index: vi/v_txt.c === RCS file: /cvs/src/usr.bin/vi/vi/v_txt.c,v retrieving revision 1.27 diff -u -p -u -p -r1.27 v_txt.c --- vi/v_txt.c 12 Nov 2014 04:28:41 - 1.27 +++ vi/v_txt.c 19 Nov 2014 01:17:45 - @@ -618,30 +617,21 @@ replay: if (LF_ISSET(TXT_REPLAY)) /* * !!! -* If this character was quoted by a K_VLNEXT or a backslash, replace -* the placeholder (a carat or a backslash) with the new character. -* If it was quoted by a K_VLNEXT, we've already adjusted the cursor -* because it has to appear on top of the placeholder character. If -* it was quoted by a backslash, adjust the cursor now, the cursor -* doesn't appear on top of it. Historic practice in both cases. +* If this character was quoted by a K_VLNEXT, replace the placeholder +* (a carat) with the new character. We've already adjusted the cursor +* because it has to appear on top of the placeholder character. +* Historic practice. * * Skip tests for abbreviations; ":ab xa XA" followed by "ixa^V" * doesn't perform an abbreviation. Special case, ^V^J (not ^V^M) is * the same as ^J, historically. */ - if (quote == Q_BTHIS || quote == Q_VTHIS) { + if (quote == Q_VTHIS) { FL_CLR(ec_flags, EC_QUOTED); if (LF_ISSET(TXT_MAPINPUT)) FL_SET(ec_flags, EC_MAPINPUT); - if (quote == Q_BTHIS && - (evp->e_value == K_VERASE || evp->e_value == K_VKILL)) { - quote = Q_NOTSET; - --tp->cno; - ++tp->owrite; - goto insl_ch; - } - if (quote == Q_VTHIS && evp->e_value != K_NL) { + if (evp->e_value != K_NL) { quote = Q_NOTSET; goto insl_ch; } @@ -1201,31 +1191,6 @@ leftmargin: tp->lb[tp->cno - 1] = ' '; if (LF_ISSET(TXT_SHOWMATCH)) showmatch = 1; goto ins_ch; - case K_BACKSLASH: /* Quote next erase/kill. */ - /* -* !!! -* Historic vi tried to make abbreviations after a backslash -* escape work. If you did ":ab x y", and inserted "x\^H", -* (assuming the erase character was ^H) you got "x^H", and -* no abbreviation was done. If you inserted "x\z", however, -* it tried to back up and do the abbreviation, i.e. replace -* 'x' with 'y'. The problem was it got it wrong, and you -* ended up with "zy\". -* -* This is really hard to do (you have to remember the -* word/non-word state, for example), and doesn't make any -* sense to me. Both backslash and the characters it -* (usually) escapes will individually trigger the -* abbreviation, so I don't see why the combination of them -* wouldn't. I don't expect to get caught on this one, -* particularly since it never worked right, but I've been -* wrong before. -* -* Do the tests for abbreviations, so ":ab xa XA", -* "ixa\" performs the abbreviation. -*/ - quote = Q_BNEXT; - goto insq_ch; case K_VLNEXT: /* Quote next character. */ evp->e_c = '^'; quote = Q_VNEXT; @@ -1363,8 +1328,6 @@ ebuf_chk: if (tp->cno >= tp->len) { /* Step the quote state forward. */ if (quote != Q_NOTSET) { - if (quote == Q_BNEXT) - quote = Q_BTHIS; if (quote == Q_VNEXT) quote = Q_VTHIS; } Index: vi/vi.h === RCS file: /cvs/src/usr.bin/vi/vi/vi.h,v retrieving revision 1.7 diff -u -p -u -p -r1.7 vi.h --- vi/vi.h 28 Nov 2013 22:12:40 - 1.7 +++ vi/vi.h 19 Nov 2014 01:17:45 - @@ -218,7 +218,7 @@ typedef struct _smap { typedef enum { CNOTSET, FSEARCH, fSEARCH, TSEARCH, tSEARCH } cdir_t; typedef enum { AB_NOTSET, AB_NOTWORD, AB_INWORD } abb_t; -typedef enum { Q_NOTSET, Q_BNEXT, Q_BTHIS, Q_VNEXT, Q_VTHIS } quote_t; +typedef enum { Q_NOTSET, Q_VNEX