zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: expand-or-complete-prefix
       [not found] <199802200231.TAA11243@empire.Central.Sun.COM>
@ 1998-02-20 14:00 ` Peter Stephenson
  1998-02-20 17:16   ` Bart Schaefer
  0 siblings, 1 reply; 8+ messages in thread
From: Peter Stephenson @ 1998-02-20 14:00 UTC (permalink / raw)
  To: Steve Talley, Zsh hackers list

Steve Talley wrote:
> With expand-or-complete-prefix:
> 
> % cd /etc/[TAB]
> 
> produces no matches.

I didn't locate this, but looking at the code
expand-or-complete-prefix is a bit of a hack --- or rather the whole
completion code is a hack but this is hacked in on top of it, which is
not a recipe for success.  I've rewritten it as part of the standard
repertoire of hacks.  For once, the new code is considerably shorter
than the old.

This part of zsh is somewhere near the end of my `All Time Top
1,000,000,000 Easily Understandable Pieces of Code', but there's quite
a reasonable chance this is OK.  The most likely problem I can think
of is that I've made the completion code get the word beginning index
(wb) right from the start, so there could be somewhere innocently
subtracting 1 from it which shouldn't.

It would now be trivial to make this behaviour into an option.

(There are some useless hunks because somehow some whitespace got
trimmed.  It seemed silly to put it back in specially.)

*** Src/Zle/zle_tricky.c.ecp	Tue Jan 20 10:04:14 1998
--- Src/Zle/zle_tricky.c	Fri Feb 20 14:52:15 1998
***************
*** 173,179 ****
  static int ab, ae, fab, fae;
  
  /* This variable says what we are currently adding to the list of matches. */
!    
  static int addwhat;
  
  /* firstm hold the first match we found, shortest contains the shortest *
--- 173,179 ----
  static int ab, ae, fab, fae;
  
  /* This variable says what we are currently adding to the list of matches. */
! 
  static int addwhat;
  
  /* firstm hold the first match we found, shortest contains the shortest *
***************
*** 196,206 ****
  
  static int amenu;
  
- /* This is used by expandorcompleteprefix to save the position of the *
-  * inserted space (so that we can remove it later).                   */
- 
- static int remove_at = -1;
- 
  /* Find out if we have to insert a tab (instead of trying to complete). */
  
  /**/
--- 196,201 ----
***************
*** 524,530 ****
  	do_menucmp(lst);
  	return;
      }
!     
      /* Check if we have to start a menu-completion (via automenu). */
  
      if ((amenu = (isset(AUTOMENU) && lastambig)))
--- 519,525 ----
  	do_menucmp(lst);
  	return;
      }
! 
      /* Check if we have to start a menu-completion (via automenu). */
  
      if ((amenu = (isset(AUTOMENU) && lastambig)))
***************
*** 777,782 ****
--- 772,780 ----
  /* 1 if we are completing in a string */
  static int instring;
  
+ /* 1 if we are completing the prefix */
+ static int comppref;
+ 
  /* This function inserts an `x' in the command line at the cursor position. *
   *                                                                          *
   * Oh, you want to know why?  Well, if completion is tried somewhere on an  *
***************
*** 786,807 ****
   * command we are completing and such things).  So we temporarily add a `x' *
   * (any character without special meaning would do the job) at the cursor   *
   * position, than the lexer gives us the word `x' and its beginning and end *
!  * positions and we can remove the `x'.                                     */
  
  /**/
  static void
  addx(char **ptmp)
  {
      if (!line[cs] || line[cs] == '\n' ||
  	(iblank(line[cs]) && (!cs || line[cs-1] != '\\')) ||
  	line[cs] == ')' || line[cs] == '`' ||
! 	(instring && (line[cs] == '"' || line[cs] == '\''))) {
  	*ptmp = (char *)line;
! 	line = (unsigned char *)halloc(strlen((char *)line) + 3);
  	memcpy(line, *ptmp, cs);
  	line[cs] = 'x';
! 	strcpy((char *)line + cs + 1, (*ptmp) + cs);
! 	addedx = 1;
      } else {
  	addedx = 0;
  	*ptmp = NULL;
--- 784,817 ----
   * command we are completing and such things).  So we temporarily add a `x' *
   * (any character without special meaning would do the job) at the cursor   *
   * position, than the lexer gives us the word `x' and its beginning and end *
!  * positions and we can remove the `x'.                                     *
!  *									    *
!  * If we are just completing the prefix (comppref set), we also insert a    *
!  * space after the x to end the word.  We never need to remove the space:   *
!  * anywhere we are able to retrieve a word for completion it will be	    *
!  * discarded as whitespace.  It has the effect of making any suffix	    *
!  * referrable to as the next word on the command line when indexing	    *
!  * from a completion function.                                              */
  
  /**/
  static void
  addx(char **ptmp)
  {
+     int addspace = 0;
+ 
      if (!line[cs] || line[cs] == '\n' ||
  	(iblank(line[cs]) && (!cs || line[cs-1] != '\\')) ||
  	line[cs] == ')' || line[cs] == '`' ||
! 	(instring && (line[cs] == '"' || line[cs] == '\'')) ||
! 	(addspace = (comppref && !iblank(line[cs])))) {
  	*ptmp = (char *)line;
! 	line = (unsigned char *)halloc(strlen((char *)line) + 3 + addspace);
  	memcpy(line, *ptmp, cs);
  	line[cs] = 'x';
! 	if (addspace)
! 	    line[cs+1] = ' ';
! 	strcpy((char *)line + cs + 1 + addspace, (*ptmp) + cs);
! 	addedx = 1 + addspace;
      } else {
  	addedx = 0;
  	*ptmp = NULL;
***************
*** 966,972 ****
  		tt = tokstr ? dupstring(tokstr) : NULL;
  		/* If we added a `x', remove it. */
  		if (addedx && tt)
! 		    chuck(tt + cs - wb - 1);
  		tt0 = tok;
  		/* Store the number of this word. */
  		clwpos = i;
--- 976,982 ----
  		tt = tokstr ? dupstring(tokstr) : NULL;
  		/* If we added a `x', remove it. */
  		if (addedx && tt)
! 		    chuck(tt + cs - wb);
  		tt0 = tok;
  		/* Store the number of this word. */
  		clwpos = i;
***************
*** 1000,1007 ****
  	    /* If this is the word the cursor is in and we added a `x', *
  	     * remove it.                                               */
  	    if (clwpos == i++ && addedx)
! 		chuck(&clwords[i - 1][((cs - wb - 1) >= sl) ?
! 				     (sl - 1) : (cs - wb - 1)]);
  	} while (tok != LEXERR && tok != ENDINPUT &&
  		 (tok != SEPER || (zleparse && !tt0)));
  	/* Calculate the number of words stored in the clwords array. */
--- 1010,1017 ----
  	    /* If this is the word the cursor is in and we added a `x', *
  	     * remove it.                                               */
  	    if (clwpos == i++ && addedx)
! 		chuck(&clwords[i - 1][((cs - wb) >= sl) ?
! 				     (sl - 1) : (cs - wb)]);
  	} while (tok != LEXERR && tok != ENDINPUT &&
  		 (tok != SEPER || (zleparse && !tt0)));
  	/* Calculate the number of words stored in the clwords array. */
***************
*** 1014,1021 ****
  	strinend();
  	inpop();
  	errflag = zleparse = 0;
- 	if (addedx)
- 	    wb++;
  	if (parbegin != -1) {
  	    /* We are in command or process substitution */
  	    if (parend >= 0 && !tmp)
--- 1024,1029 ----
***************
*** 1292,1300 ****
  void
  gotword(void)
  {
!     we = ll + 1 - inbufct;
      if (cs <= we) {
! 	wb = ll - wordbeg;
  	zleparse = 0;
      }
  }
--- 1300,1308 ----
  void
  gotword(void)
  {
!     we = ll + 1 - inbufct + (addedx == 2 ? 1 : 0);
      if (cs <= we) {
! 	wb = ll - wordbeg + addedx;
  	zleparse = 0;
      }
  }
***************
*** 1313,1320 ****
  	len = strlen(str);
      spaceinline(len);
      strncpy((char *)(line + cs), str, len);
-     if (remove_at >= cs)
-         remove_at += len;
      if (move)
  	cs += len;
  }
--- 1321,1326 ----
***************
*** 3607,3623 ****
  	}
      }
  
-     /* When called from expandorcompleteprefix, we probably have to
-        remove a space now. */
-     if (remove_at >= 0) {
- 	int ocs = cs;
- 
- 	cs = remove_at;
- 	deletechar();
- 	remove_at = -1;
- 	cs = ocs;
-     }
- 
      /* Set the cursor below the prompt. */
      trashzle();
      showinglist = 0;
--- 3613,3618 ----
***************
*** 3775,3781 ****
  
  		if (aylist) {
  		    zputs(*ap, shout);
! 		    t2 = strlen(*ap);		    
  		} else if (ispattern) {
  		    int cut = strlen(*ap) - boff;
  
--- 3770,3776 ----
  
  		if (aylist) {
  		    zputs(*ap, shout);
! 		    t2 = strlen(*ap);
  		} else if (ispattern) {
  		    int cut = strlen(*ap) - boff;
  
***************
*** 4036,4060 ****
  void
  expandorcompleteprefix(void)
  {
!     /* global c is the current character typed. */
!     int csafe = c;
!     int m = zmult;
! 
!     /* insert a space and backspace. */
!     zmult = 1;
!     c = ' ';
!     selfinsert();		/* insert the extra character */
!     backwardchar();		/* move towards beginning */
!     
!     remove_at = cs;
! 
!     /* do the expansion/completion. */
!     c = csafe;
!     expandorcomplete();		/* complete. */
! 
!     /* remove the inserted space. */
!     if (remove_at >= 0)
! 	deletechar();		/* delete the added space. */
!     zmult = m;
!     remove_at = -1;
  }
--- 4031,4037 ----
  void
  expandorcompleteprefix(void)
  {
!     comppref = 1;
!     expandorcomplete();
!     comppref = 0;
  }

-- 
Peter Stephenson <pws@ifh.de>       Tel: +39 50 911239
WWW:  http://www.ifh.de/~pws/
Gruppo Teorico, Dipartimento di Fisica
Piazza Torricelli 2, 56100 Pisa, Italy


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

* Re: PATCH: expand-or-complete-prefix
  1998-02-20 14:00 ` PATCH: expand-or-complete-prefix Peter Stephenson
@ 1998-02-20 17:16   ` Bart Schaefer
  1998-02-20 17:26     ` Bart Schaefer
  0 siblings, 1 reply; 8+ messages in thread
From: Bart Schaefer @ 1998-02-20 17:16 UTC (permalink / raw)
  To: Peter Stephenson, Steve Talley, Zsh hackers list

On Feb 20,  3:00pm, Peter Stephenson wrote:
} Subject: PATCH: expand-or-complete-prefix
}
} I've rewritten it as part of the standard repertoire of hacks.
} 
} (There are some useless hunks because somehow some whitespace got
} trimmed.  It seemed silly to put it back in specially.)

Here's the patch against 3.0.5, with some whitespace differences cleaned
up -- I had to hand-apply Peter's patch, hopefully this one doesn't have
that problem.

Index: Src/zle_tricky.c
===================================================================
*** zle_tricky.c	1997/11/19 16:40:31	1.6
--- zle_tricky.c	1998/02/20 17:07:25
***************
*** 166,172 ****
  static int ab, ae, fab, fae;
  
  /* This variable says what we are currently adding to the list of matches. */
!    
  static int addwhat;
  
  /* firstm hold the first match we found, shortest contains the shortest *
--- 166,172 ----
  static int ab, ae, fab, fae;
  
  /* This variable says what we are currently adding to the list of matches. */
! 
  static int addwhat;
  
  /* firstm hold the first match we found, shortest contains the shortest *
***************
*** 189,199 ****
  
  static int amenu;
  
- /* This is used by expandorcompleteprefix to save the position of the *
-  * inserted space (so that we can remove it later).                   */
- 
- static int remove_at = -1;
- 
  /* Find out if we have to insert a tab (instead of trying to complete). */
  
  /**/
--- 189,194 ----
***************
*** 505,511 ****
  	do_menucmp(lst);
  	return;
      }
!     
      /* Check if we have to start a menu-completion (via automenu). */
  
      if ((amenu = (isset(AUTOMENU) &&
--- 500,506 ----
  	do_menucmp(lst);
  	return;
      }
! 
      /* Check if we have to start a menu-completion (via automenu). */
  
      if ((amenu = (isset(AUTOMENU) &&
***************
*** 765,770 ****
--- 760,768 ----
  /* 1 if we are completing in a string */
  int instring;
  
+ /* 1 if we are completing the prefix */
+ static int comppref;
+ 
  /* This function inserts an `x' in the command line at the cursor position. *
   *                                                                          *
   * Oh, you want to know why?  Well, if completion is tried somewhere on an  *
***************
*** 774,795 ****
   * command we are completing and such things).  So we temporarily add a `x' *
   * (any character without special meaning would do the job) at the cursor   *
   * position, than the lexer gives us the word `x' and its beginning and end *
!  * positions and we can remove the `x'.                                     */
  
  /**/
  void
  addx(char **ptmp)
  {
      if (!line[cs] || line[cs] == '\n' ||
  	(iblank(line[cs]) && (!cs || line[cs-1] != '\\')) ||
  	line[cs] == ')' || line[cs] == '`' ||
! 	(instring && (line[cs] == '"' || line[cs] == '\''))) {
  	*ptmp = (char *)line;
! 	line = (unsigned char *)halloc(strlen((char *)line) + 3);
  	memcpy(line, *ptmp, cs);
  	line[cs] = 'x';
! 	strcpy((char *)line + cs + 1, (*ptmp) + cs);
! 	addedx = 1;
      } else {
  	addedx = 0;
  	*ptmp = NULL;
--- 772,805 ----
   * command we are completing and such things).  So we temporarily add a `x' *
   * (any character without special meaning would do the job) at the cursor   *
   * position, than the lexer gives us the word `x' and its beginning and end *
!  * positions and we can remove the `x'.                                     *
!  *									    *
!  * If we are just completing the prefix (comppref set), we also insert a    *
!  * space after the x to end the word.  We never need to remove the space:   *
!  * anywhere we are able to retrieve a word for completion it will be	    *
!  * discarded as whitespace.  It has the effect of making any suffix	    *
!  * referrable to as the next word on the command line when indexing	    *
!  * from a completion function.                                              */
  
  /**/
  void
  addx(char **ptmp)
  {
+     int addspace = 0;
+ 
      if (!line[cs] || line[cs] == '\n' ||
  	(iblank(line[cs]) && (!cs || line[cs-1] != '\\')) ||
  	line[cs] == ')' || line[cs] == '`' ||
! 	(instring && (line[cs] == '"' || line[cs] == '\'')) ||
! 	(addspace = (comppref && !iblank(line[cs])))) {
  	*ptmp = (char *)line;
! 	line = (unsigned char *)halloc(strlen((char *)line) + 3 + addspace);
  	memcpy(line, *ptmp, cs);
  	line[cs] = 'x';
! 	if (addspace)
! 	    line[cs+1] = ' ';
! 	strcpy((char *)line + cs + 1 + addspace, (*ptmp) + cs);
! 	addedx = 1 + addspace;
      } else {
  	addedx = 0;
  	*ptmp = NULL;
***************
*** 953,959 ****
  		tt = tokstr ? dupstring(tokstr) : NULL;
  		/* If we added a `x', remove it. */
  		if (addedx && tt)
! 		    chuck(tt + cs - wb - 1);
  		tt0 = tok;
  		/* Store the number of this word. */
  		clwpos = i;
--- 963,969 ----
  		tt = tokstr ? dupstring(tokstr) : NULL;
  		/* If we added a `x', remove it. */
  		if (addedx && tt)
! 		    chuck(tt + cs - wb);
  		tt0 = tok;
  		/* Store the number of this word. */
  		clwpos = i;
***************
*** 987,994 ****
  	    /* If this is the word the cursor is in and we added a `x', *
  	     * remove it.                                               */
  	    if (clwpos == i++ && addedx)
! 		chuck(&clwords[i - 1][((cs - wb - 1) >= sl) ?
! 				     (sl - 1) : (cs - wb - 1)]);
  	} while (tok != LEXERR && tok != ENDINPUT &&
  		 (tok != SEPER || (zleparse && !tt0)));
  	/* Calculate the number of words stored in the clwords array. */
--- 997,1004 ----
  	    /* If this is the word the cursor is in and we added a `x', *
  	     * remove it.                                               */
  	    if (clwpos == i++ && addedx)
! 		chuck(&clwords[i - 1][((cs - wb) >= sl) ?
! 				     (sl - 1) : (cs - wb)]);
  	} while (tok != LEXERR && tok != ENDINPUT &&
  		 (tok != SEPER || (zleparse && !tt0)));
  	/* Calculate the number of words stored in the clwords array. */
***************
*** 1001,1008 ****
  	strinend();
  	inpop();
  	errflag = zleparse = 0;
- 	if (addedx)
- 	    wb++;
  	if (parbegin != -1) {
  	    /* We are in command or process substitution */
  	    if (parend >= 0 && !tmp)
--- 1011,1016 ----
***************
*** 1211,1219 ****
  void
  gotword(void)
  {
!     we = ll + 1 - inbufct;
      if (cs <= we) {
! 	wb = ll - wordbeg;
  	zleparse = 0;
      }
  }
--- 1219,1227 ----
  void
  gotword(void)
  {
!     we = ll + 1 - inbufct + (addedx == 2 ? 1 : 0);
      if (cs <= we) {
! 	wb = ll - wordbeg + addedx;
  	zleparse = 0;
      }
  }
***************
*** 1232,1239 ****
  	len = strlen(str);
      spaceinline(len);
      strncpy((char *)(line + cs), str, len);
-     if (remove_at >= cs)
-         remove_at += len;
      if (move)
  	cs += len;
  }
--- 1240,1245 ----
***************
*** 3503,3519 ****
      nboff = ispattern && psuf && *psuf &&
  	!(haswhat & (HAS_MISC | HAS_PATHPAT)) ? niceztrlen(psuf) : 0;
  
-     /* When called from expandorcompleteprefix, we probably have to
-        remove a space now. */
-     if (remove_at >= 0) {
- 	int ocs = cs;
- 
- 	cs = remove_at;
- 	deletechar();
- 	remove_at = -1;
- 	cs = ocs;
-     }
- 
      /* Set the cursor below the prompt. */
      trashzle();
      ct = nmatches;
--- 3509,3514 ----
***************
*** 3946,3971 ****
  void
  expandorcompleteprefix(void)
  {
!     /* global c is the current character typed. */
!     int csafe = c;
! 
!     /* insert a space and backspace. */
!     c = ' ';
!     selfinsert();		/* insert the extra character */
!     forwardchar();		/* move towards beginning */
!     
!     remove_at = cs;
! 
!     /* do the expansion/completion. */
!     c = csafe;
!     zmult = 1;
!     expandorcomplete();		/* complete. */
!     zmult = -1;
! 
!     /* remove the inserted space. */
!     if (remove_at >= 0) {
! 	backwardchar();		/* move towards ends */
! 	deletechar();		/* delete the added space. */
!     }
!     remove_at = -1;
  }
--- 3941,3947 ----
  void
  expandorcompleteprefix(void)
  {
!     comppref = 1;
!     expandorcomplete();
!     comppref = 0;
  }

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


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

* Re: PATCH: expand-or-complete-prefix
  1998-02-20 17:16   ` Bart Schaefer
@ 1998-02-20 17:26     ` Bart Schaefer
  1998-02-20 17:50       ` Adam Spiers
  1998-02-21 10:00       ` PATCH: expand-or-complete-prefix Peter Stephenson
  0 siblings, 2 replies; 8+ messages in thread
From: Bart Schaefer @ 1998-02-20 17:26 UTC (permalink / raw)
  To: Zsh hackers list

On Feb 20,  9:16am, Bart Schaefer wrote:
} Subject: Re: PATCH: expand-or-complete-prefix
}
} On Feb 20,  3:00pm, Peter Stephenson wrote:
} } Subject: PATCH: expand-or-complete-prefix
} }
} } I've rewritten it as part of the standard repertoire of hacks.
} 
} Here's the patch against 3.0.5

I've just been testing this, and it breaks on menu completion:

zagzig% bindkey '\t' expand-or-complete-prefix 
zagzig% setopt menucomplete 
zagzig% ls zlc
             ^ with cursor here, press TAB, and you get
zagzig% ls zle_bindings.oc
                         ^ press TAB again
zagzig% ls zle_hist.oc
                     ^ press TAB again
zagzig% ls zle_hist.proc
                       ^ and so forth

Hmm, I just tried several other versions and this is broken at least back
to 3.0.0, so it's not Peter's fault.  Maybe it'll be easier to fix now,
though ...

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


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

* Re: PATCH: expand-or-complete-prefix
  1998-02-20 17:26     ` Bart Schaefer
@ 1998-02-20 17:50       ` Adam Spiers
  1998-02-21 10:02         ` Peter Stephenson
  1998-02-21 10:00       ` PATCH: expand-or-complete-prefix Peter Stephenson
  1 sibling, 1 reply; 8+ messages in thread
From: Adam Spiers @ 1998-02-20 17:50 UTC (permalink / raw)
  To: Zsh hackers list

While we're on the subject of patching zle_tricky.c etc., has
anyone had a chance to try my dabbrev patch yet?  I'm quite keen
to get some feedback on it.  Should I release it to zsh-users
for testing if everyone here is too busy to check it out?

--
Adam Spiers, Computing Officer, New College, Oxford University, UK **
cello/modern jazz/juggling/cycling/Perl/Linux/Quake fanatic, M$ hater
e-mail: adam.spiers@new.ox.ac.uk  WWW: http://www.new.ox.ac.uk/~adam/


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

* Re: PATCH: expand-or-complete-prefix
  1998-02-20 17:26     ` Bart Schaefer
  1998-02-20 17:50       ` Adam Spiers
@ 1998-02-21 10:00       ` Peter Stephenson
  1998-02-21 17:09         ` Bart Schaefer
  1 sibling, 1 reply; 8+ messages in thread
From: Peter Stephenson @ 1998-02-21 10:00 UTC (permalink / raw)
  To: Bart Schaefer, Zsh hackers list

"Bart Schaefer" wrote:
> I've just been testing this, and it breaks on menu completion:
> 
> zagzig% bindkey '\t' expand-or-complete-prefix 
> zagzig% setopt menucomplete 
> zagzig% ls zlc
>              ^ with cursor here, press TAB, and you get
> zagzig% ls zle_bindings.oc
>                          ^ press TAB again
> zagzig% ls zle_hist.oc
>                      ^ press TAB again
> zagzig% ls zle_hist.proc
>                        ^ and so forth

Is that really a bug?  The prefix is 'zl', and that's what you're
completing according to what the doctor ordered: ignore the suffix,
just complete what's left of the cursor.  It's intrinsically
incompatible with complete-in-word, if that's what you mean, but then
you will have to use the usual exapnd-or-complete to get that; there's
just no way of having both possibilities at once.  Or am I missing
something?  Do you want the suffix to be deleted, a real space
inserted before it...?

-- 
Peter Stephenson <pws@ifh.de>       Tel: +39 50 911239
WWW:  http://www.ifh.de/~pws/
Gruppo Teorico, Dipartimento di Fisica
Piazza Torricelli 2, 56100 Pisa, Italy


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

* Re: PATCH: expand-or-complete-prefix
  1998-02-20 17:50       ` Adam Spiers
@ 1998-02-21 10:02         ` Peter Stephenson
  1998-02-21 13:48           ` PATCH: complete-history Adam Spiers
  0 siblings, 1 reply; 8+ messages in thread
From: Peter Stephenson @ 1998-02-21 10:02 UTC (permalink / raw)
  To: Adam Spiers, Zsh hackers list

Adam Spiers wrote:
> While we're on the subject of patching zle_tricky.c etc., has
> anyone had a chance to try my dabbrev patch yet?  I'm quite keen
> to get some feedback on it.  Should I release it to zsh-users
> for testing if everyone here is too busy to check it out?

I haven't tried it because I assumed it did the same job as my
completion patch where you can bind special sorts of completion to a
key (zle -C complete-history -H '' 0; bindkey "\M-/"
complete-history).  Maybe I got the wrong end of the stick?

-- 
Peter Stephenson <pws@ifh.de>       Tel: +39 50 911239
WWW:  http://www.ifh.de/~pws/
Gruppo Teorico, Dipartimento di Fisica
Piazza Torricelli 2, 56100 Pisa, Italy



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

* PATCH: complete-history
  1998-02-21 10:02         ` Peter Stephenson
@ 1998-02-21 13:48           ` Adam Spiers
  0 siblings, 0 replies; 8+ messages in thread
From: Adam Spiers @ 1998-02-21 13:48 UTC (permalink / raw)
  To: Zsh hackers list

Peter Stephenson (pws@ifh.de) wrote:
> Adam Spiers wrote:
> > While we're on the subject of patching zle_tricky.c etc., has
> > anyone had a chance to try my dabbrev patch yet?  I'm quite keen
> > to get some feedback on it.  Should I release it to zsh-users
> > for testing if everyone here is too busy to check it out?
> 
> I haven't tried it because I assumed it did the same job as my
> completion patch where you can bind special sorts of completion to a
> key (zle -C complete-history -H '' 0; bindkey "\M-/"
> complete-history).  Maybe I got the wrong end of the stick?

Nope, I don't think you did ... I guess the moral of this story
is, if you're a newbie who asks on zsh-users whether something
is possible, gets no response and decides to write a patch to do
it, join zsh-workers before you start work on it rather than
when it's ready for release :-/

Sorry if this is a silly question, but where can I get your
patch?  It sounds a bit more generalised than the one you posted
here dated 16th Jan 1998.  My patch is very similar to the
latter, with some small differences:

- yours is probably better, as you know far more about zsh
  internals
- yours doesn't have a reverse-complete-history thing (correct
  me if I'm wrong)
- I introduced an extra state to `validlist' so that if you
  press M-/ and then TAB it reverts to the normal completion.

--
Adam Spiers, Computing Officer, New College, Oxford University, UK **
cello/modern jazz/juggling/cycling/Perl/Linux/Quake fanatic, M$ hater
e-mail: adam.spiers@new.ox.ac.uk  WWW: http://www.new.ox.ac.uk/~adam/


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

* Re: PATCH: expand-or-complete-prefix
  1998-02-21 10:00       ` PATCH: expand-or-complete-prefix Peter Stephenson
@ 1998-02-21 17:09         ` Bart Schaefer
  0 siblings, 0 replies; 8+ messages in thread
From: Bart Schaefer @ 1998-02-21 17:09 UTC (permalink / raw)
  To: Peter Stephenson, Zsh hackers list

On Feb 21, 11:00am, Peter Stephenson wrote:
} Subject: Re: PATCH: expand-or-complete-prefix
}
} "Bart Schaefer" wrote:
} > I've just been testing this, and it breaks on menu completion:
} > 
} > zagzig% bindkey '\t' expand-or-complete-prefix 
} > zagzig% setopt menucomplete 
} > zagzig% ls zlc
} >              ^ with cursor here, press TAB, and you get
} > zagzig% ls zle_bindings.oc
} >                          ^ press TAB again
} > zagzig% ls zle_hist.oc
} >                      ^ press TAB again
} > zagzig% ls zle_hist.proc
} >                        ^ and so forth
} 
} Is that really a bug?  The prefix is 'zl', and that's what you're
} completing

Oh, of course; silly me.  I was misled by (with-out- menucomplete):

zagzig% ls zlc
             ^ with cursor here, press TAB, and you get
zagzig% ls zle_c
               ^ press h then TAB again
zagzig% ls zle_hist.c

But the reason it stopped there is because "zle_hist." is an ambiguous
completion (a prefix of both zle_hist.o and zle_hist.pro), not because
it matched the file zle_hist.c, which is what I thought caused it to
stop.

So you're right, there's no bug there.

Although I do notice one thing:

zagzig% zlc
          ^ with cursor here, press TAB, and I get
zagzig% zless c
             ^ note space before cursor

But in this case:

zagzig% zc
zagzig% zcatc
            ^ note no space
zagzig% zdumpc
zagzig% zlessc

I realize that's an artifact of the way a unique completion works, so I'm
not prepared to suggest changing it yet, but it's not like e.g. bash:

zagzig% bash -f
[schaefer@zagzig zsh-3.0.5-build]$ zlc
                                     ^
[schaefer@zagzig zsh-3.0.5-build]$ zlessc
                                        ^
[schaefer@zagzig zsh-3.0.5-build]$ zl
                                     ^
[schaefer@zagzig zsh-3.0.5-build]$ zless 
                                         ^
                                     Space inserted only if at end of line

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


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

end of thread, other threads:[~1998-02-21 17:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <199802200231.TAA11243@empire.Central.Sun.COM>
1998-02-20 14:00 ` PATCH: expand-or-complete-prefix Peter Stephenson
1998-02-20 17:16   ` Bart Schaefer
1998-02-20 17:26     ` Bart Schaefer
1998-02-20 17:50       ` Adam Spiers
1998-02-21 10:02         ` Peter Stephenson
1998-02-21 13:48           ` PATCH: complete-history Adam Spiers
1998-02-21 10:00       ` PATCH: expand-or-complete-prefix Peter Stephenson
1998-02-21 17:09         ` Bart Schaefer

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