zsh-users
 help / color / mirror / code / Atom feed
* Re: Question about Completion
@ 2001-10-12  6:55 Felix Rosencrantz
  2001-10-12 11:35 ` Goran Koruga
  0 siblings, 1 reply; 7+ messages in thread
From: Felix Rosencrantz @ 2001-10-12  6:55 UTC (permalink / raw)
  To: zsh-users

I received some private replies from Goran and Sven about Clearcase filename
completion back in Sept that I thought I would forward in part to the list. (I
figure there might be a few lurkers who have some interest.)

On Sep 23 23:54:17 2001, Goran Koruga wrote:
>Someone else has told me to use setopt automenu and setopt autolist.
>This works if I don't have my custom completion module - so later on I
>asked if there's a way to get that working.

Check Sven's reply below...

>Right now I am still banging my head with the first problem - it will
>call _cc_files and _cc_co_files even when just arguments are to be
>completed. I have realized that _arguments has -A switch, but that will
>mean I have to change all calls to _arguments to add -A "-*" (I have
>actually found that in one of the man pages ;). I have checked _cvs
>script and it seems quite similar to mine, however for them the file
>completing functions are not called.

Not sure.  It might be useful to look at the trace output to see what is
happening.  If you use the default bindings, there is a nice completion trace
facility via "^X-?".

>All of this completion stuff is quite complex. Right now I will try to
>compare CVS completion against mine to try and figure out the difference.

One problem I noticed with your completion function is that you use the "-s"
flag with _arguments.  This is used if you have single letter options that can
be combined into a single word (e.g. the ls command allows "ls -la"). 
Clearcase has word options, not letter options, so doesn't need this flag like
cvs does.

In response to a message where I mention some comments Sven had made some time
back in zsh-workers #9631.  He makes a another possible to _path_files.  (I
don't have access to clearcase, so I can't test this...)

On Tue Sep 25 05:33:12 2001, Sven Wischnowsky responded.
>From Sven Wischnowsky Tue Sep 25 05:33:12 2001
>I don't remember what I suggested back then and don't have the time to
>look it up now.  But anyway, Goran and others using ClearCase who want
>to help could try the following: make themselves a copy of _path_files
>and insert before line 36 something like:
>
>  if compset -P '*@@'; then
>    # code to complete the version string here...
>    return
>  fi
>
>Instead of that `fi' one could try:
>
>  elif (( ! $pfxsfx[(I)-[a-zA-Z12]S] )); then
>    pfxsfx=( "$pfxsfx[@]" -qS '@@' )
>  fi
>
>To make it always add an automatically removable `@@' suffix if there
>isn't one from the calling function.
>
>Then if we arrive at something usable, we can start thinking about how
>to integrate that into the distribution, maybe with one or more styles
>or by adding generic code into _path_files so that can make it call
>arbitrary helper functions (with one for ClearCase being the first
>implemented) or whatever.

-FR.

__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com


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

* Re: Question about Completion
  2001-10-12  6:55 Question about Completion Felix Rosencrantz
@ 2001-10-12 11:35 ` Goran Koruga
  0 siblings, 0 replies; 7+ messages in thread
From: Goran Koruga @ 2001-10-12 11:35 UTC (permalink / raw)
  To: zsh-users

On Thu, Oct 11 2001, Felix Rosencrantz wrote:

Hi,

> I received some private replies from Goran and Sven about Clearcase filename
> completion back in Sept that I thought I would forward in part to the list. (I
> figure there might be a few lurkers who have some interest.)
> 
> On Sep 23 23:54:17 2001, Goran Koruga wrote:
> >Someone else has told me to use setopt automenu and setopt autolist.
> >This works if I don't have my custom completion module - so later on I
> >asked if there's a way to get that working.
> 
> Check Sven's reply below...

Will do so and experiment with it when I find the time for it.

> >Right now I am still banging my head with the first problem - it will
> >call _cc_files and _cc_co_files even when just arguments are to be
> >completed. I have realized that _arguments has -A switch, but that will
> >mean I have to change all calls to _arguments to add -A "-*" (I have
> >actually found that in one of the man pages ;). I have checked _cvs
> >script and it seems quite similar to mine, however for them the file
> >completing functions are not called.
> 
> Not sure.  It might be useful to look at the trace output to see what is
> happening.  If you use the default bindings, there is a nice completion trace
> facility via "^X-?".
> 
> >All of this completion stuff is quite complex. Right now I will try to
> >compare CVS completion against mine to try and figure out the difference.
> 
> One problem I noticed with your completion function is that you use the "-s"
> flag with _arguments.  This is used if you have single letter options that can
> be combined into a single word (e.g. the ls command allows "ls -la"). 
> Clearcase has word options, not letter options, so doesn't need this flag like
> cvs does.

Hmm looks like I have overlooked this one. I have removed it and didn't
notice anything strange.

> In response to a message where I mention some comments Sven had made some time
> back in zsh-workers #9631.  He makes a another possible to _path_files.  (I
> don't have access to clearcase, so I can't test this...)
> 
> On Tue Sep 25 05:33:12 2001, Sven Wischnowsky responded.
> >From Sven Wischnowsky Tue Sep 25 05:33:12 2001
> >I don't remember what I suggested back then and don't have the time to
> >look it up now.  But anyway, Goran and others using ClearCase who want
> >to help could try the following: make themselves a copy of _path_files
> >and insert before line 36 something like:
> >
> >  if compset -P '*@@'; then
> >    # code to complete the version string here...
> >    return
> >  fi
> >
> >Instead of that `fi' one could try:
> >
> >  elif (( ! $pfxsfx[(I)-[a-zA-Z12]S] )); then
> >    pfxsfx=( "$pfxsfx[@]" -qS '@@' )
> >  fi
> >
> >To make it always add an automatically removable `@@' suffix if there
> >isn't one from the calling function.
> >
> >Then if we arrive at something usable, we can start thinking about how
> >to integrate that into the distribution, maybe with one or more styles
> >or by adding generic code into _path_files so that can make it call
> >arbitrary helper functions (with one for ClearCase being the first
> >implemented) or whatever.

This is definitely a good tip. I will look into this. Thanks.

I have some more questions regarding my completion attempt : my
completions don't get coloured. Where should I look to fix that ? It
would also be nice to cache completions, but that is way beyond me right
now. And is the only way to prevent calling _cc_files by using -A "-*"
arguments to _arguments function ?

Thanks for assistance.

> 
> -FR.
> 
> __________________________________________________
> Do You Yahoo!?
> Make a great connection at Yahoo! Personals.
> http://personals.yahoo.com
> 

Best regards,
Goran

--

Writing about music is like dancing about architecture.
    -- Frank Zappa 


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

* Re: Question about completion
@ 2001-09-21 14:32 Felix Rosencrantz
  0 siblings, 0 replies; 7+ messages in thread
From: Felix Rosencrantz @ 2001-09-21 14:32 UTC (permalink / raw)
  To: zsh-users

Hi Goran,

>My second question is more complicated. In ClearCase, one can access
>different version of file with syntax like this : filename@@version,
>where version is /main/1 for example. So full path for a file may look
>like "foo@@/main/1". Right now, my completion lists only the filenames,
>that is, only "foo" is listed. Is there a way to program completion so
>that if a strng ends with "@@", I could run a custom function which would
>list all the versions available ? I have looked at the manual pages and
>examples, but I can't figure this out.

I use to work at a place that used Clearcase and had this same problem.  I
never did get it to work properly.  Even though, at one point I might have
reported I did, I think I was mistaken.  I believe the problem is in _files, I
believe that it is doing readdir() at the lowest level since it uses the shell
globbing code.

We talked a little about this in zsh-workers #9631 (and related messages). I
suspect the person to deal with this problem would be Sven when he comes back,
unless you are willing to dig into _files.  Sven did suggest some solutions at
that point.  Also, it sounds like Peter might soon have some interest in better
Clearcase support.

I've been working on using XML to generate Clearcase completion function based
on "cleartool help" output.  I'll post something within a week, showing what
I've got.  Mostly this can create the _arguments calls.  But it still would
require some one to write the listing functions, such as the ones you have
_cc_views _cc_files and _cc_co_files.

-FR.

__________________________________________________
Terrorist Attacks on U.S. - How can you help?
Donate cash, emergency relief information
http://dailynews.yahoo.com/fc/US/Emergency_Information/


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

* Re: Question about completion
  2001-09-18 12:54   ` Goran Koruga
@ 2001-09-18 13:41     ` Goran Koruga
  0 siblings, 0 replies; 7+ messages in thread
From: Goran Koruga @ 2001-09-18 13:41 UTC (permalink / raw)
  To: zsh-users

On Tue, Sep 18 2001, Goran Koruga wrote:

I have figured out that I can get the behaviour that Daniel described if
I do setopt automenu and setopt autolist. But this doesn't work if I also
run

autoload -U compinit
compinit

So is there a way to have both ? If not, I guess my second question still
stands, otherwise I jsut need to know how to achieve this.

Thanks.

Goran

> On Tue, Sep 18 2001, Daniel Brahneborg wrote:
> 
> Hi,
> 
> I have tried this already, but it doesn't quite work. The thing is, that
> you have to call opendir() with "foo@@/" in order to get all the matches
> from readdir() and that doesn't seem to be the case here.
> 
> Goran
> 
> > Hi,
> > 
> > > My second question is more complicated. In ClearCase, one can access
> > > different version of file with syntax like this : filename@@version,
> > > where version is /main/1 for example. So full path for a file may look
> > > like "foo@@/main/1". Right now, my completion lists only the
> > > filenames,
> > > that is, only "foo" is listed. Is there a way to program completion so
> > > that if a strng ends with "@@", I could run a custom function
> > > which would
> > > list all the versions available ? I have looked at the manual
> > > pages and
> > > examples, but I can't figure this out.
> > 
> > Try foo@@/, and press tab.  The overloaded readdir() in mvfs will
> > sort it out, and give the list of versions.  Works in 4nt too.
> > 
> > /Basic
> > 
> 
> --
> _______________________________________________________________
> Goran Koruga                            goran.koruga@hermes.si
> 
> HERMES Softlab
> Litijska 51                             phone: +386 1 5865 524
> 1000 Ljubljana, Slovenia
> 

--
_______________________________________________________________
Goran Koruga                            goran.koruga@hermes.si

HERMES Softlab
Litijska 51                             phone: +386 1 5865 524
1000 Ljubljana, Slovenia


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

* Re: Question about completion
  2001-09-18 12:46 ` Daniel Brahneborg
@ 2001-09-18 12:54   ` Goran Koruga
  2001-09-18 13:41     ` Goran Koruga
  0 siblings, 1 reply; 7+ messages in thread
From: Goran Koruga @ 2001-09-18 12:54 UTC (permalink / raw)
  To: zsh-users

On Tue, Sep 18 2001, Daniel Brahneborg wrote:

Hi,

I have tried this already, but it doesn't quite work. The thing is, that
you have to call opendir() with "foo@@/" in order to get all the matches
from readdir() and that doesn't seem to be the case here.

Goran

> Hi,
> 
> > My second question is more complicated. In ClearCase, one can access
> > different version of file with syntax like this : filename@@version,
> > where version is /main/1 for example. So full path for a file may look
> > like "foo@@/main/1". Right now, my completion lists only the
> > filenames,
> > that is, only "foo" is listed. Is there a way to program completion so
> > that if a strng ends with "@@", I could run a custom function
> > which would
> > list all the versions available ? I have looked at the manual
> > pages and
> > examples, but I can't figure this out.
> 
> Try foo@@/, and press tab.  The overloaded readdir() in mvfs will
> sort it out, and give the list of versions.  Works in 4nt too.
> 
> /Basic
> 

--
_______________________________________________________________
Goran Koruga                            goran.koruga@hermes.si

HERMES Softlab
Litijska 51                             phone: +386 1 5865 524
1000 Ljubljana, Slovenia


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

* RE: Question about completion
  2001-09-18 12:32 Goran Koruga
@ 2001-09-18 12:46 ` Daniel Brahneborg
  2001-09-18 12:54   ` Goran Koruga
  0 siblings, 1 reply; 7+ messages in thread
From: Daniel Brahneborg @ 2001-09-18 12:46 UTC (permalink / raw)
  To: Goran Koruga, Zsh-Users Mailing List; +Cc: Daniel Brahneborg

Hi,

> My second question is more complicated. In ClearCase, one can access
> different version of file with syntax like this : filename@@version,
> where version is /main/1 for example. So full path for a file may look
> like "foo@@/main/1". Right now, my completion lists only the
> filenames,
> that is, only "foo" is listed. Is there a way to program completion so
> that if a strng ends with "@@", I could run a custom function
> which would
> list all the versions available ? I have looked at the manual
> pages and
> examples, but I can't figure this out.

Try foo@@/, and press tab.  The overloaded readdir() in mvfs will
sort it out, and give the list of versions.  Works in 4nt too.

/Basic


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

* Question about completion
@ 2001-09-18 12:32 Goran Koruga
  2001-09-18 12:46 ` Daniel Brahneborg
  0 siblings, 1 reply; 7+ messages in thread
From: Goran Koruga @ 2001-09-18 12:32 UTC (permalink / raw)
  To: zsh-users

Hi all,

I am working on a programmable completion for ClearCase (versioning
system ala CVS but commercial and more advanced). I have used _cvs file,
distributed with zsh 4.0.2, as an example. cleartool command is similar
to cvs command in a way. Unlike cvs, it accepts no switches, so I am not
sure if I can take the cvs example directly.

So far I have done the following :

---------------------------- cut ---------------------------
#compdef cleartool

# redefine _cleartool.
_cleartool () {
  _arguments -s \
    '*::clearcase command:_cc_command'
}

# define cleartool command dispatch function.

(( $+functions[_cc_command] )) ||
_cc_command () {
  if (( ! $+_cc_cmds )); then
    typeset -gA _cc_cmds
    _cc_cmds=()
    for a in annotate apropos catcs checkin checkout chevent describe diff \
             edcs find findmerge help hostinfo ln ls lscheckout lsdo       \
             lshistory lsprivate lsview lsvtree man merge mkbranch mkdir   \
             mkelem mklabel mklbtype mkview mount mv protect pwv rename    \
             rmbranch rmelem rmlabel rmver setcs setview umount uncheckout
    do
      _cc_cmds[$a]=" "
    done
    _cc_cmds[checkin]=" ci "
    _cc_cmds[checkout]=" co "
    _cc_cmds[lscheckout]=" lsco "
    _cc_cmds[uncheckout]=" unco "
  fi

  if (( CURRENT == 1 )); then
    _tags commands && { compadd "$@" -k _cc_cmds || compadd "$@" ${(kv)=_cc_cmds
} }
  else
    local curcontext="$curcontext"

    cmd="${${(k)_cc_cmds[(R)* $words[1] *]}:-${(k)_cc_cmds[(i)$words[1]]}}"
    if (( $#cmd )); then
      curcontext="${curcontext%:*:*}:cc-${cmd}:"
      _cc_$cmd
    else
      _message "unknown clearcase command: $words[1]"
    fi
  fi
}

# define completion functions for each cvs command

(( $+functions[_cc_annotate] )) ||
_cc_annotate () {
  _arguments -s \
    '-all[include all lines]' \
    '-rm[include removed lines]' \
    '-nco[use non checked-out version]' \
    '(-s)-short[use annotation format strings that yield an abbreviated report]'
 \
    '(-l)-long[use annotation format strings that yield a verbose report]' \
    '-fmt+[specify display format]:display format:' \
    '(-rmf)-rmfmt+[specify a format for deletion annotations]:deletion format:' 
\
    '(-f)-force[display even duplicated annotation lines]' \
    '(-nhe)-nheader[suppress the header section]' \
    '(-nda)-ndata[suppress the annotated text lines]' \
    '*:cc file:_cc_files'
}

(( $+functions[_cc_apropos] )) ||
_cc_apropos () {
  _arguments -s \
    '(-glo)-glossary+[show header lines that match entire string]'
}

(( $+functions[_cc_catcs] )) ||
_cc_catcs () {
  _arguments -s \
    '-tag+[show config specs for given view-tag]:cc view:_cc_views'
}

# define completion functions for files in clearcase

(( $+functions[_cc_views] )) ||
_cc_views () {
  _wanted ccviews expl 'cc view' compadd - ${(@)${(@)${(@f)"$(cleartool lsview)"}#[ *][ ]}/ *}
}

(( $+functions[_cc_files] )) ||
_cc_files () {
  _wanted ccfiles expl 'cc file' compadd - ${(@)${(@M)${(@f)"$(cleartool ls)"}:#* Rule:*-mkbranch *}/@@*}
}

(( $+functions[_cc_co_files] )) ||
_cc_co_files() {
  _wanted ccfilesco expl 'cc file (checked-out)' compadd - ${(@)${(@f)"$(cleartool lsprivate -co)"}/ *}
}
---------------------------- cut ---------------------------

This somehow works. However I get unexepected behaviour when I type the
following :

cleartool annotate -<ctrl-d>

This is where all options should be listed. They get listed, but my
problem is, that also _cc_files completion is attempted. Is there a way
to overcome this ? What I am looking for, is to complete options and only
options if string starts with '-'.

My second question is more complicated. In ClearCase, one can access
different version of file with syntax like this : filename@@version,
where version is /main/1 for example. So full path for a file may look
like "foo@@/main/1". Right now, my completion lists only the filenames,
that is, only "foo" is listed. Is there a way to program completion so
that if a strng ends with "@@", I could run a custom function which would
list all the versions available ? I have looked at the manual pages and
examples, but I can't figure this out.

Hopefully this is not too long and indescriptive.

Thank you in advance.

Regards,
Goran
--

Writing about music is like dancing about architecture.
    -- Frank Zappa 


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

end of thread, other threads:[~2001-10-12 11:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-10-12  6:55 Question about Completion Felix Rosencrantz
2001-10-12 11:35 ` Goran Koruga
  -- strict thread matches above, loose matches on Subject: below --
2001-09-21 14:32 Question about completion Felix Rosencrantz
2001-09-18 12:32 Goran Koruga
2001-09-18 12:46 ` Daniel Brahneborg
2001-09-18 12:54   ` Goran Koruga
2001-09-18 13:41     ` Goran Koruga

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