zsh-workers
 help / color / mirror / code / Atom feed
* Re: Two missing completion functions that bug me
@ 2001-03-30  8:23 Sven Wischnowsky
  0 siblings, 0 replies; 13+ messages in thread
From: Sven Wischnowsky @ 2001-03-30  8:23 UTC (permalink / raw)
  To: zsh-workers


I wrote:

> ...
> 
> You could try the patch below ...

Ahem.

Bye
 Sven

Index: Completion/Base/_arguments
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/_arguments,v
retrieving revision 1.34
diff -u -r1.34 _arguments
--- Completion/Base/_arguments	2001/03/28 09:50:38	1.34
+++ Completion/Base/_arguments	2001/03/30 08:22:57
@@ -335,14 +335,16 @@
           if [[ "$single" = direct ]]; then
             _all_labels options expl option \
 	        compadd -QS '' - "${PREFIX}${SUFFIX}"
-          elif [[ "$single" = next ]]; then
-            _all_labels options expl option \
-	        compadd -Q - "${PREFIX}${SUFFIX}"
           elif [[ "$single" = equal ]]; then
             _all_labels options expl option \
 	        compadd -QqS= - "${PREFIX}${SUFFIX}"
           else
+
 	    tmp1=( "$next[@]" "$direct[@]" "$odirect[@]" "$equal[@]" )
+
+            [[ "$single" = next ]] &&
+                tmp1=( "${(@)tmp1:#[-+]${PREFIX[-1]}((#e)|:*)}" )
+
 	    [[ "$PREFIX" != --* ]] && tmp1=( "${(@)tmp1:#--*}" )
 	    tmp3=( "${(M@)tmp1:#[-+]?[^:]*}" )
 	    tmp1=( "${(M@)tmp1:#[-+]?(|:*)}" )
@@ -351,6 +353,11 @@
             _describe -o option \
                       tmp1 tmp2 -Q -S '' -- \
 		      tmp3 -Q
+
+            [[ "$single" = next && nm -eq $compstate[nmatches] ]] &&
+                _all_labels options expl option \
+	            compadd -Q - "${PREFIX}${SUFFIX}"
+
           fi
           single=yes
         else

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 13+ messages in thread
* Re: Two missing completion functions that bug me
@ 2001-04-02  9:15 Sven Wischnowsky
  2001-04-02 12:04 ` Oliver Kiddle
  0 siblings, 1 reply; 13+ messages in thread
From: Sven Wischnowsky @ 2001-04-02  9:15 UTC (permalink / raw)
  To: zsh-workers


Oliver Kiddle wrote:

> --- Bart Schaefer <schaefer@candle.brasslantern.com> wrote:
> 
> > Yes, but when you're allowed to have other options intervene between
> > an
> > option and its argument (as in `tar -fxv file' for example) there has
> > to
> > be some way to prevent completion from inserting the space after
> > `-f'.
> 
> I accept this but would argue that there are more commands which don't
> allow other options to intervene. Things like tar can be achieved with
> with states. Maybe _arguments needs some way to describe whether or not
> options can intervene between an option and its argument.

Yes, I was beginning to think the same.  Would it be enough to make my 
other patch optional (i.e. adding a option to _arguments to select
either that behaviour or to de-select it)?  Which should be the
default?

> Things get
> messy if more than one of the options take an argument.

If I understand you correctly... I said in one of my previous messages 
that _arguments can do that.  Do we have to disallow it?  I'd prefer
it if we could keep it, mostly because I don't see a reason to make it 
optional -- either it's the intended reason or the specs given to
_arguments or the command line are messed up (only in the last case
there may be a reason to make _arguments smart enough to detect it and 
notify the user).

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 13+ messages in thread
* Re: Two missing completion functions that bug me
@ 2001-03-30  8:21 Sven Wischnowsky
  2001-03-30 16:11 ` Bart Schaefer
  0 siblings, 1 reply; 13+ messages in thread
From: Sven Wischnowsky @ 2001-03-30  8:21 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> On Mar 29, 11:09am, Oliver Kiddle wrote:
> }
> } >     '-c+[create parameter or change type]' \
> } 
> } I'm not sure you need the + after -c, or at least that is the only
> } difference to my function (other than wording for the help info).
> 
> You're right; upon another attempt, none of -c, -e, nor -h need the `+'.
> I was thinking it was needed to get other options to be completed in the
> same word, because of:
> 
> % vared -a<TAB>
> % vared -a 
>          ^cursor silently moves here
> 
> but in fact that's because -a takes an argument, not (only) because it
> does not have the `+'.  (Is there a way *other than* adding a ->state
> machine to get other options to complete in the same word but arguments
> in the next for an option like -a?  I was thinking not, and in fact I
> was thinking that I was one who asserted that ->state was a sufficient
> solution for this, a position I'm not inclined to change.)

You could try the patch below, which does that (automatically) for
me.  I'll commit it if we don't find any nasty side effect (or should
I apply it and take it back if we find problems?  feel free to commit
it if you like it...)

> ... [ comp* funcs ]
> 
> I suppose one could provide completions for them anyway, in case one is
> editing a new completion function on the fly, but it seems a lot of work
> for not a lot of benefit.

Yes, I thought the same.

> These don't need completions because they're keywords:
> 
>   break     continue
> 
> Which leaves:
> 
>   :            echo         pushln       suspend      umask
>   [            exit         pwd          test         zformat
>   bye          getln        r            ttyctl       zparseopts
>   dirs         logout       return       ulimit       zprof

zparseopts and zformat aren't of much use interactively either.

And completion for bye, exit and return seems weird, too.  Although
that would probably just be `_message "${${words[1]#bye}:-exit} value"'.

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 13+ messages in thread
* Two missing completion functions that bug me
@ 2001-03-29  7:59 Bart Schaefer
  2001-03-29 10:09 ` Oliver Kiddle
  0 siblings, 1 reply; 13+ messages in thread
From: Bart Schaefer @ 2001-03-29  7:59 UTC (permalink / raw)
  To: zsh-workers

I won't commit these yet (hence they're not presented in diff form); either
Sven can add them at the Great Renaming, or I'll add them after it happens.

The only reason for using _arguments in fned is to get "no more arguments"
behavior after the first name is completed; otherwise it could simply
call _functions directly.

---- 8< ---- _zed ---- 8< ---
#compdef zed fned
case $service in
(fned) _arguments ':shell function:_functions';;
(zed) _arguments '(-):file:_files' \
	'(:)-f[edit function]:shell function:_functions';;
esac
---- 8< ---- _zed ---- 8< ---

When adding this next one, remember to remove vared from _vars.

---- 8< ---- _vared ---- 8< ---
#compdef vared
_arguments -s -A '-*' ':parameter spec:_vars' \
    '(-A)-a[edit array parameter]:parameter name:_parameters -g array\*' \
    '(-a)-A[edit associative array]:parameter name:_parameters -g assoc\*' \
    '-c+[create parameter or change type]' \
    '-h+[enable history]' \
    '-e+[exit on EOF (^D)]' \
    '-p[specify left prompt]:prompt string:' \
    '-r[specify right prompt]:prompt string:'
---- 8< ---- _vared ---- 8< ---

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

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


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

end of thread, other threads:[~2001-04-02 12:04 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-03-30  8:23 Two missing completion functions that bug me Sven Wischnowsky
  -- strict thread matches above, loose matches on Subject: below --
2001-04-02  9:15 Sven Wischnowsky
2001-04-02 12:04 ` Oliver Kiddle
2001-03-30  8:21 Sven Wischnowsky
2001-03-30 16:11 ` Bart Schaefer
2001-03-29  7:59 Bart Schaefer
2001-03-29 10:09 ` Oliver Kiddle
2001-03-29 16:24   ` Bart Schaefer
2001-03-30  9:16     ` Oliver Kiddle
2001-03-30 15:38       ` Bart Schaefer
2001-03-30 15:59         ` Bart Schaefer
2001-03-30 16:35         ` Oliver Kiddle
2001-03-30 16:53           ` 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).