zsh-workers
 help / color / mirror / code / Atom feed
* Re: PATCH: _diff (new), _prcs (upgrade)
@ 2000-01-28 10:25 Sven Wischnowsky
  2000-01-28 15:04 ` Alexandre Duret-Lutz
  0 siblings, 1 reply; 11+ messages in thread
From: Sven Wischnowsky @ 2000-01-28 10:25 UTC (permalink / raw)
  To: zsh-workers


Alexandre Duret-Lutz wrote:

> ...
> 
> I rethought about it this morning, and while I have not changed my idea, I
> can describe it differently.  My opinion is: we should write $(XXX) if
> we are in the completion function for XXX, and $(command XXX) otherwise.
> In the former case, we really need to see what the user is actually running,
> in order to not complete for the wrong command (that's the case in _diff,
> I think); in the later case we need to call a command directly in order
> to get unaltered result (case of the call to ps in _pids).

But then a hackishly written function may still break everything (if
you have a function for diff that actually does something if invoked
with zero or only one argument, for example).

>  Sven> Actually, I wasn't too sure about _pids either... the problem is that
>  Sven> some users may have functions for ps, diff, and so on that may give
>  Sven> completely different results when invoked in the way we invoke them.
> 
>  Sven> Hm. maybe we should try to solve this in a generic manner by writing a 
>  Sven> function that is called in such cases, like:
> 
>  Sven>   _call <name> [ <how> ]
> 
>  Sven> (i.e. we use `$(_diff ps)', `$(_call ps list)' and so on).
> 
> $(_call diff version)?

No, I wasn't clear enough. I meant that any arguments one normally
wants to give to the command would come after the <how>:

  $(_call diff -v </dev/null)

or

  $(_call diff -- -v </dev/null)

The <how> was meant for cases where we want to invoke the command more 
than once, for different purposes (e.g. we call ps to get the pids and to
get the lines to display).

So the style would only be used to get the command (including: how it
should be invoked, i.e. with `command' or not) and any options the
user wants to give to it. If the style is not set we use some standard 
way, so we don't have to set up default styles for this.

> ...
> 
> Another point about the $+functions[<name>] test: what if I am writting a
> completion function for a shell function? say I need to call it, how do I
> do?

Good point. Also testing $+commands and $+builtins might help here,
but could still be wrong. Hm, I just wanted to make this cleverer but
since the style would allow one to override it anyway, we should
probably just call it without any pre-command modifier in the default
case. Or let _call accept options like -c and -b to say that the
default should use `command' or `builtin'. Maybe the <how> should be
given with a option, too.

So we would have:

  _call -h pids -c ps             -> command ps
  _call -h list -c ps             -> command ps
  _call diff -- -v < /dev/null    -> diff -v      (the <... is in the caller)

and the user can set

  zstyle '...:ps-pids' command-line ps -e -o pid
  zstyle '...:ps-list  command-line ps -e -o pid,command
  zstyle '...:diff'    command-line command diff

(in the last case _call would stick the -v after the diff)

Does this sound sensible?

Bye
 Sven


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


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

* Re: PATCH: _diff (new), _prcs (upgrade)
  2000-01-28 10:25 PATCH: _diff (new), _prcs (upgrade) Sven Wischnowsky
@ 2000-01-28 15:04 ` Alexandre Duret-Lutz
  0 siblings, 0 replies; 11+ messages in thread
From: Alexandre Duret-Lutz @ 2000-01-28 15:04 UTC (permalink / raw)
  To: zsh-workers; +Cc: Sven Wischnowsky

>>> "Sven" == Sven Wischnowsky <wischnow@informatik.hu-berlin.de> writes:

 Sven> Alexandre Duret-Lutz wrote:

[...]

 >> My opinion is: we should write $(XXX) if we are in the completion
 >> function for XXX, and $(command XXX) otherwise.

[...]

 Sven> But then a hackishly written function may still break everything (if
 Sven> you have a function for diff that actually does something if invoked
 Sven> with zero or only one argument, for example).

Yes.  And since _call shall allow people to customize the completion system
for those cases, it's not a problem anyway.  

[...]

 Sven> So the style would only be used to get the command (including: how it
 Sven> should be invoked, i.e. with `command' or not) and any options the
 Sven> user wants to give to it. If the style is not set we use some standard 
 Sven> way, so we don't have to set up default styles for this.

This (your last sentence) assume that no option is used by default (like
the call to ps in _pids).  This seems restrictive (but I don't have an
example where options are needed by default, and where the user would want
to change them).

 >> ...
 >> 
 >> Another point about the $+functions[<name>] test: what if I am writting a
 >> completion function for a shell function? say I need to call it, how do I
 >> do?

 Sven> Good point. Also testing $+commands and $+builtins might help here,
 Sven> but could still be wrong. Hm, I just wanted to make this cleverer but
 Sven> since the style would allow one to override it anyway, we should
 Sven> probably just call it without any pre-command modifier in the default
 Sven> case. Or let _call accept options like -c and -b to say that the
 Sven> default should use `command' or `builtin'. 

Given I am writting a _call in a completion function, how do I decide
whether I must use -[bc] or not?  We ne a rule here, that should be used
consistently in the completion system (see the first paragraph for what I
suggest). 

And if a rule is chosen, _call can apply it, and therefore -[bc] parameters
may not be needed anymore.

[...]

-- 
Alexandre Duret-Lutz


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

* Re: PATCH: _diff (new), _prcs (upgrade)
@ 2000-01-31  9:09 Sven Wischnowsky
  0 siblings, 0 replies; 11+ messages in thread
From: Sven Wischnowsky @ 2000-01-31  9:09 UTC (permalink / raw)
  To: zsh-workers


Alexandre Duret-Lutz wrote:

> ...
> 
>  Sven> I suggested that to enable completion functions to make it as you
>  Sven> described in 9453: if we are completing for the command, call it
>  Sven> without a `command', otherwise with it. And that can't be decided in
>  Sven> _call.
> 
> I must be missing something.  Can't $curcontext be used? 
> I am thinking about something like this:
> 
>     # 
>     _call () {  
>       if [[ $curcontext == *:$1: ]]
>       then
>         $1                   #(A)
>       else
>         command $1           #(B)
>       fi
>     }
> 
>     _f() {
>       _call foo
>     } 
> 
>     compdef _f foo bar
> 
> 
> seems to run either (A) or (B) wheter I complete after foo or bar.

Hm, for forcing the test to use only command names, this would be
`::${1}:'. Maybe. I'm trying to think of a case where this would fail, 
but I can't find one just now...

Bye
 Sven


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


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

* Re: PATCH: _diff (new), _prcs (upgrade)
  2000-01-27 16:08 Sven Wischnowsky
  2000-01-27 17:21 ` Alexandre Duret-Lutz
@ 2000-01-29  8:49 ` Alexandre Duret-Lutz
  1 sibling, 0 replies; 11+ messages in thread
From: Alexandre Duret-Lutz @ 2000-01-29  8:49 UTC (permalink / raw)
  To: zsh-workers

Oops, forgot to add _diff and _diff_options.

Index: Completion/User/.distfiles
--- Completion/User/.distfiles Mon, 24 Jan 2000 13:13:23 +0100 Alexandre
+++ Completion/User/.distfiles Sat, 29 Jan 2000 09:45:31 +0100 Alexandre
@@ -1,12 +1,15 @@
 DISTFILES_SRC='
     .distfiles
-    _a2ps _archie _bison _bunzip2 _bzip2 _chown _compress _configure _cvs
-    _dd _dir_list _dirs _domains _dvi _find _finger _flex _gcc _gdb _gprof
-    _groups _gs _gunzip _gv _gzip _hosts _ispell _killall _lp _lynx
-    _mailboxes _make _man _mh _mount _mutt _my_accounts _netscape _nslookup
-    _other_accounts _pack _patch _pbm _pdf _perl_basepods _perl_builtin_funcs
-    _perl_modules _perldoc _ports _prcs _prompt _ps _pspdf _rcs _rlogin _sh
-    _socket _ssh _strip _stty _su _sudo _tar _tar_archive _telnet _tex _tiff
-    _uncompress _unpack _urls _use_lo _user_at_host _users _users_on
-    _webbrowser _wget _whereis _whois _xargs _yodl _yp _zdump
+    _a2ps _archie _bison _bunzip2 _bzip2 _chown _compress
+    _configure _cvs _dd _diff _diff_options _dir_list _dirs
+    _domains _dvi _find _finger _flex _gcc _gdb _gprof _groups
+    _gs _gunzip _gv _gzip _hosts _ispell _killall _lp _lynx
+    _mailboxes _make _man _mh _mount _mutt _my_accounts
+    _netscape _nslookup _other_accounts _pack _patch _pbm _pdf
+    _perl_basepods _perl_builtin_funcs _perl_modules _perldoc
+    _ports _prcs _prompt _ps _pspdf _rcs _rlogin _sh _socket
+    _ssh _strip _stty _su _sudo _tar _tar_archive _telnet _tex
+    _tiff _uncompress _unpack _urls _use_lo _user_at_host _users
+    _users_on _webbrowser _wget _whereis _whois _xargs _yodl _yp
+    _zdump
 '

-- 
Alexandre Duret-Lutz


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

* Re: PATCH: _diff (new), _prcs (upgrade)
  2000-01-28 15:11 Sven Wischnowsky
@ 2000-01-28 16:24 ` Alexandre Duret-Lutz
  0 siblings, 0 replies; 11+ messages in thread
From: Alexandre Duret-Lutz @ 2000-01-28 16:24 UTC (permalink / raw)
  To: zsh-workers; +Cc: Sven Wischnowsky

>>> "Sven" == Sven Wischnowsky <wischnow@informatik.hu-berlin.de> writes:

 Sven> Alexandre Duret-Lutz wrote:

[...]

 Sven> The only problem is that this means that such options will always be
 Sven> combined with the ones a user might define in a style. I.e. there are
 Sven> actually two types of options a completion function might give to a
 Sven> command: those that *have* to be there to make it work in the way the
 Sven> function needs it (like the -v for diff) and those the completion
 Sven> functions *suggests* to use -- which may be overridden by a user's
 Sven> style. Ideally, we should support both cases...

Yes, I was speaking of what you call *suggested* options.  As for now, to
set these options, we should set a default style in compinit or elsewhere.
But since these *suggested* options must be quite uncommon, this is not a
problem. ok.

[...]

 >> and if a rule is chosen, _call can apply it

[...]

 Sven> I suggested that to enable completion functions to make it as you
 Sven> described in 9453: if we are completing for the command, call it
 Sven> without a `command', otherwise with it. And that can't be decided in
 Sven> _call.

I must be missing something.  Can't $curcontext be used? 
I am thinking about something like this:

    # 
    _call () {  
      if [[ $curcontext == *:$1: ]]
      then
        $1                   #(A)
      else
        command $1           #(B)
      fi
    }

    _f() {
      _call foo
    } 

    compdef _f foo bar


seems to run either (A) or (B) wheter I complete after foo or bar.

-- 
Alexandre Duret-Lutz


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

* Re: PATCH: _diff (new), _prcs (upgrade)
@ 2000-01-28 15:11 Sven Wischnowsky
  2000-01-28 16:24 ` Alexandre Duret-Lutz
  0 siblings, 1 reply; 11+ messages in thread
From: Sven Wischnowsky @ 2000-01-28 15:11 UTC (permalink / raw)
  To: zsh-workers


Alexandre Duret-Lutz wrote:

> ...
>
>  Sven> So the style would only be used to get the command (including: how it
>  Sven> should be invoked, i.e. with `command' or not) and any options the
>  Sven> user wants to give to it. If the style is not set we use some standard 
>  Sven> way, so we don't have to set up default styles for this.
> 
> This (your last sentence) assume that no option is used by default (like
> the call to ps in _pids).  This seems restrictive (but I don't have an
> example where options are needed by default, and where the user would want
> to change them).

Err, either I misunderstand you here, or... options the completion
function wants to give would be give to _call, as in the example for
diff I had in my last answer (`_call diff -- -v').

The only problem is that this means that such options will always be
combined with the ones a user might define in a style. I.e. there are
actually two types of options a completion function might give to a
command: those that *have* to be there to make it work in the way the
function needs it (like the -v for diff) and those the completion
functions *suggests* to use -- which may be overridden by a user's
style. Ideally, we should support both cases...

>  >> ...
>  >> 
>  >> Another point about the $+functions[<name>] test: what if I am writting a
>  >> completion function for a shell function? say I need to call it, how do I
>  >> do?
> 
>  Sven> Good point. Also testing $+commands and $+builtins might help here,
>  Sven> but could still be wrong. Hm, I just wanted to make this cleverer but
>  Sven> since the style would allow one to override it anyway, we should
>  Sven> probably just call it without any pre-command modifier in the default
>  Sven> case. Or let _call accept options like -c and -b to say that the
>  Sven> default should use `command' or `builtin'. 
> 
> Given I am writting a _call in a completion function, how do I decide
> whether I must use -[bc] or not?  We ne a rule here, that should be used
> consistently in the completion system (see the first paragraph for what I
> suggest). 
> 
> And if a rule is chosen, _call can apply it, and therefore -[bc] parameters
> may not be needed anymore.

I suggested that to enable completion functions to make it as you
described in 9453: if we are completing for the command, call it
without a `command', otherwise with it. And that can't be decided in
_call.


Bye
 Sven


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


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

* Re: PATCH: _diff (new), _prcs (upgrade)
  2000-01-28  8:26 Sven Wischnowsky
@ 2000-01-28  9:49 ` Alexandre Duret-Lutz
  0 siblings, 0 replies; 11+ messages in thread
From: Alexandre Duret-Lutz @ 2000-01-28  9:49 UTC (permalink / raw)
  To: zsh-workers; +Cc: Sven Wischnowsky

>>> "Sven" == Sven Wischnowsky <wischnow@informatik.hu-berlin.de> writes:

 Sven> Alexandre Duret-Lutz wrote:

[...]

 Sven> Oh, and it makes _diff_options use `$(command diff ...)' -- I at least 
 Sven> have a small wrapper function for it which makes it fail otherwise.
 >> 
 >> I first wrote this, and then removed 'command' when I thought that on a
 >> system without GNU diff a user may have installed GNU diff and made diff be
 >> an alias to GNU diff.  But maybe it's quite uncommon especially with diff
 >> (which is used by several commands and is thus better put in the PATH).
 >> 
 >> Also, I should say: I understand why _pids is running $(command ps ...)
 >> but the difference in _diff_options is that we should be testing the
 >> command that the user is actually running.

I rethought about it this morning, and while I have not changed my idea, I
can describe it differently.  My opinion is: we should write $(XXX) if
we are in the completion function for XXX, and $(command XXX) otherwise.
In the former case, we really need to see what the user is actually running,
in order to not complete for the wrong command (that's the case in _diff,
I think); in the later case we need to call a command directly in order
to get unaltered result (case of the call to ps in _pids).

 Sven> Actually, I wasn't too sure about _pids either... the problem is that
 Sven> some users may have functions for ps, diff, and so on that may give
 Sven> completely different results when invoked in the way we invoke them.

 Sven> Hm. maybe we should try to solve this in a generic manner by writing a 
 Sven> function that is called in such cases, like:

 Sven>   _call <name> [ <how> ]

 Sven> (i.e. we use `$(_diff ps)', `$(_call ps list)' and so on).

$(_call diff version)?

 Sven> _call would then first see if there is a style `command-line' for the
 Sven> tag `<name>' or, if <how> is given, <name>-<how>. If there is such a
 Sven> style it is used as an array containing the whole command line to use
 Sven> (the styles for ps we have now would be removed). 

 Sven> If there is no such style, and $+functions[<name>] is 1, we use
 Sven> `command <name>', otherwise we use just `<name>'.

I'm not sure to understand this default behaviour, what would be
the default for a <name>-<how> call? (where will arguments come
from?).


  $(diff -v </dev/null)

would be replaced by

  $(_call diff version)

with something like

 zstyle '*:diff-version' command-line 'diff -v </dev/null'

where is this last line going to be?  will every completion function
have to pollute compinit to set such default?


Another point about the $+functions[<name>] test: what if I am writting a
completion function for a shell function? say I need to call it, how do I
do?

[...]

-- 
Alexandre Duret-Lutz


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

* Re: PATCH: _diff (new), _prcs (upgrade)
@ 2000-01-28  8:26 Sven Wischnowsky
  2000-01-28  9:49 ` Alexandre Duret-Lutz
  0 siblings, 1 reply; 11+ messages in thread
From: Sven Wischnowsky @ 2000-01-28  8:26 UTC (permalink / raw)
  To: zsh-workers


Alexandre Duret-Lutz wrote:

> >>> "Sven" == Sven Wischnowsky <wischnow@informatik.hu-berlin.de> writes:
> 
> [...]
> 
>  Sven> The rest of the patch just makes some of the descriptions more
>  Sven> verbose. I hope this is ok for Alexandre (?).
> 
> I don't see why it shouldn't be ok.
> 
>  Sven> Oh, and it makes _diff_options use `$(command diff ...)' -- I at least 
>  Sven> have a small wrapper function for it which makes it fail otherwise.
> 
> I first wrote this, and then removed 'command' when I thought that on a
> system without GNU diff a user may have installed GNU diff and made diff be
> an alias to GNU diff.  But maybe it's quite uncommon especially with diff
> (which is used by several commands and is thus better put in the PATH).
> 
> Also, I should say: I understand why _pids is running $(command ps ...)
> but the difference in _diff_options is that we should be testing the
> command that the user is actually running.

Actually, I wasn't too sure about _pids either... the problem is that
some users may have functions for ps, diff, and so on that may give
completely different results when invoked in the way we invoke them.

Hm. maybe we should try to solve this in a generic manner by writing a 
function that is called in such cases, like:

  _call <name> [ <how> ]

(i.e. we use `$(_diff ps)', `$(_call ps list)' and so on).

_call would then first see if there is a style `command-line' for the
tag `<name>' or, if <how> is given, <name>-<how>. If there is such a
style it is used as an array containing the whole command line to use
(the styles for ps we have now would be removed). If there is no such
style, and $+functions[<name>] is 1, we use `command <name>',
otherwise we use just `<name>'.

Does this sound reasonable?


Bye
 Sven


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


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

* Re: PATCH: _diff (new), _prcs (upgrade)
  2000-01-27 16:08 Sven Wischnowsky
@ 2000-01-27 17:21 ` Alexandre Duret-Lutz
  2000-01-29  8:49 ` Alexandre Duret-Lutz
  1 sibling, 0 replies; 11+ messages in thread
From: Alexandre Duret-Lutz @ 2000-01-27 17:21 UTC (permalink / raw)
  To: zsh-workers; +Cc: Sven Wischnowsky

>>> "Sven" == Sven Wischnowsky <wischnow@informatik.hu-berlin.de> writes:

[...]

 Sven> The rest of the patch just makes some of the descriptions more
 Sven> verbose. I hope this is ok for Alexandre (?).

I don't see why it shouldn't be ok.

 Sven> Oh, and it makes _diff_options use `$(command diff ...)' -- I at least 
 Sven> have a small wrapper function for it which makes it fail otherwise.

I first wrote this, and then removed 'command' when I thought that on a
system without GNU diff a user may have installed GNU diff and made diff be
an alias to GNU diff.  But maybe it's quite uncommon especially with diff
(which is used by several commands and is thus better put in the PATH).

Also, I should say: I understand why _pids is running $(command ps ...)
but the difference in _diff_options is that we should be testing the
command that the user is actually running.

[...]

-- 
Alexandre Duret-Lutz


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

* Re: PATCH: _diff (new), _prcs (upgrade)
@ 2000-01-27 16:08 Sven Wischnowsky
  2000-01-27 17:21 ` Alexandre Duret-Lutz
  2000-01-29  8:49 ` Alexandre Duret-Lutz
  0 siblings, 2 replies; 11+ messages in thread
From: Sven Wischnowsky @ 2000-01-27 16:08 UTC (permalink / raw)
  To: zsh-workers


Alexandre Duret-Lutz wrote:

> Here is a diff completion fonction. I have separated _diff_options
> (complete options) from _diff (also complete filenames), so that 
> completion functions like _prcs may use only _diff_options.

Testing this revealed a thinko in _files -- sometimes ignored-patterns 
was effectively ignored.

The rest of the patch just makes some of the descriptions more
verbose. I hope this is ok for Alexandre (?).

Oh, and it makes _diff_options use `$(command diff ...)' -- I at least 
have a small wrapper function for it which makes it fail otherwise.

Bye
 Sven

diff -ru ../z.old/Completion/Core/_files Completion/Core/_files
--- ../z.old/Completion/Core/_files	Thu Jan 27 16:48:00 2000
+++ Completion/Core/_files	Thu Jan 27 17:02:48 2000
@@ -1,6 +1,7 @@
 #autoload
 
 local opts opt type=file glob group gopts dopts aopts tmp _file_pat_checked=yes
+local hasign ign
 
 opts=()
 group=()
@@ -9,11 +10,12 @@
 aopts=(-f)
 while getopts "P:S:qr:R:W:F:J:V:X:f/g:M:12n" opt; do
   case "$opt" in
-  /)      type="${type}dir"                        ;;
-  g)      type="${type}glob"; gopts=(-g "$OPTARG") ;;
-  [qn12]) opts=("$opts[@]" "-$opt"          )      ;;
-  [JV])   group=(          "-$opt" "$OPTARG")      ;;
-  [^f])   opts=("$opts[@]" "-$opt" "$OPTARG")      ;;
+  /)      type="${type}dir"                               ;;
+  g)      type="${type}glob"; gopts=(-g "$OPTARG")        ;;
+  [qn12]) opts=("$opts[@]" "-$opt"          )             ;;
+  [JV])   group=(          "-$opt" "$OPTARG")             ;;
+  F)      opts=("$opts[@]" "-$opt" "$OPTARG"); hasign=yes ;;
+  [^f])   opts=("$opts[@]" "-$opt" "$OPTARG")             ;;
   esac
 done
 
@@ -60,32 +62,44 @@
     if (( $#group )); then
       group[2]=all-files
       _setup all-files
+      [[ -z "$hasign" ]] &&
+        zstyle -a ":completion${curcontext}:all-files" ignored-patterns _comp_ignore &&
+	  ign=(-F _comp_ignore)
     fi
-    _path_files "$opts[@]" "$aopts[@]"
+    _path_files "$opts[@]" "$ign[@]" "$aopts[@]"
     return
   elif _requested directories; then
     if _requested globbed-files; then
       if (( $#group )); then
         group[2]=globbed-files
 	_setup globbed-files
+        [[ -z "$hasign" ]] &&
+          zstyle -a ":completion${curcontext}:all-files" ignored-patterns _comp_ignore &&
+	    ign=(-F _comp_ignore)
       fi
-      _path_files "$opts[@]" "$dopts[@]" "$gopts[@]" && return 0
+      _path_files "$opts[@]" "$ign[@]" "$dopts[@]" "$gopts[@]" && return 0
     else
       if (( $#group )); then
         group[2]=directories
 	_setup directories
+        [[ -z "$hasign" ]] &&
+          zstyle -a ":completion${curcontext}:all-files" ignored-patterns _comp_ignore &&
+	    ign=(-F _comp_ignore)
       fi
-      _path_files "$opts[@]" "$dopts[@]" && return 0
+      _path_files "$opts[@]" "$ign[@]" "$dopts[@]" && return 0
     fi
   elif _requested globbed-files; then
     if (( $#group )); then
       group[2]=globbed-files
       _setup globbed-files
+      [[ -z "$hasign" ]] &&
+        zstyle -a ":completion${curcontext}:all-files" ignored-patterns _comp_ignore &&
+	  ign=(-F _comp_ignore)
     fi
     if [[ "$type" = (*dir*glob*|*glob*dir*) ]]; then
-      _path_files "$opts[@]" "$dopts[@]" "$gopts[@]" && return 0
+      _path_files "$opts[@]" "$ign[@]" "$dopts[@]" "$gopts[@]" && return 0
     else
-      _path_files "$opts[@]" "$gopts[@]" && return 0
+      _path_files "$opts[@]" "$ign[@]" "$gopts[@]" && return 0
     fi
   fi
 done
diff -ru ../z.old/Completion/User/_diff_options Completion/User/_diff_options
--- ../z.old/Completion/User/_diff_options	Thu Jan 27 16:48:13 2000
+++ Completion/User/_diff_options	Thu Jan 27 16:52:50 2000
@@ -4,7 +4,7 @@
 
 (( $+_diff_is_gnu )) || {
 	_diff_is_gnu=0;
-        [[ $(diff -v </dev/null) == *GNU* ]] && _diff_is_gnu=1
+        [[ $(command diff -v </dev/null) == *GNU* ]] && _diff_is_gnu=1
 }
 
 if (( _diff_is_gnu ))
@@ -50,15 +50,15 @@
     '(--ignore-space-change)-b[ignore changes in the amount of white space]' \
     '(-B)--ignore-blank-lines[ignore lines that are all blank]' \
     '(--ignore-blank-lines)-B[ignore lines that are all blank]' \
-    '(-I)--ignore-matching-lines=[ignore lines that match regex]:regex:' \
-    '(--ignore-matching-lines)-I[ignore lines that match regex]:regex:' \
+    '(-I)--ignore-matching-lines=[ignore lines that match regex]:line exclusion regex:' \
+    '(--ignore-matching-lines)-I[ignore lines that match regex]:line exclusion regex:' \
     '(-a)--text[treat all files as text]' \
     '(--text)-a[treat all files as text]' \
-    "($of $oss)--context=[context diff]::# lines of copied context:" \
-    "($of $oss)-C[output a context diff]:# lines of copied context:" \
+    "($of $oss)--context=[context diff]::number of lines of copied context:" \
+    "($of $oss)-C[output a context diff]:number of lines of copied context:" \
     "($of $oss)-c[output a context diff]" \
-    "($of $oss)--unified=[output a unified diff]::# lines of unified context:" \
-    "($of $oss)-U[output a unified diff]:# lines of unified context:" \
+    "($of $oss)--unified=[output a unified diff]::number of lines of unified context:" \
+    "($of $oss)-U[output a unified diff]:number of lines of unified context:" \
     "($of $oss)-u[output a unified diff]" \
     "($ofwuc $oss -L)--label[set label to use instead of file name]:label:" \
     "($ofwuc $oss --label)-L[set label to use instead of file name]:label:" \
@@ -75,18 +75,18 @@
     "($of $ouc $oss)-n[RCS format diff]" \
     "($of $ouc)--side-by-side[output in two columns]" \
     "($of $ouc)-y[output in two columns]" \
-    "($ofwy $ouc -W)--width[set size of line]:# characters per line:" \
-    "($ofwy $ouc --width)-W[set size of line]:# characters per line:" \
+    "($ofwy $ouc -W)--width[set size of line]:number of characters per line:" \
+    "($ofwy $ouc --width)-W[set size of line]:number of characters per line:" \
     "($ofwy $ouc)--left-column[output only left column of common lines]" \
     "($ofwy $ouc)--suppress-common-lines[do not ouput commun lines]" \
-    "($ofwg $ouc $oss)--old-group-format=[set old group format]:group format:" \
-    "($ofwg $ouc $oss)--new-group-format=[set new group format]:group format:" \
-    "($ofwg $ouc $oss)--changed-group-format=[set changed group format]:group format:" \
-    "($ofwg $ouc $oss)--unchanged-group-format=[set unchanged group format]:group format:" \
+    "($ofwg $ouc $oss)--old-group-format=[set old group format]:old group format:" \
+    "($ofwg $ouc $oss)--new-group-format=[set new group format]:new group format:" \
+    "($ofwg $ouc $oss)--changed-group-format=[set changed group format]:changed group format:" \
+    "($ofwg $ouc $oss)--unchanged-group-format=[set unchanged group format]:unchanged group format:" \
     "($ofwl $ouc $oss)--line-format=[set line format]:line format:" \
-    "($ofwl $ouc $oss)--old-line-format=[set old line format]:line format:" \
-    "($ofwl $ouc $oss)--new-line-format=[set new line format]:line format:" \
-    "($ofwl $ouc $oss)--changed-line-format=[set changed line format]:line format:" \
+    "($ofwl $ouc $oss)--old-line-format=[set old line format]:old line format:" \
+    "($ofwl $ouc $oss)--new-line-format=[set new line format]:new line format:" \
+    "($ofwl $ouc $oss)--changed-line-format=[set changed line format]:changed line format:" \
     '(-l)--paginate[output through pr]' \
     '(--paginate)-l[output through pr]' \
     '(-t)--expand-tabs[expand tabs to spaces]' \
@@ -101,13 +101,13 @@
     '(--unidirectional-new-file)-P[treat absent first files as empty]' \
     '(-s)--report-identical-files[report when two files are the same]' \
     '(--report-identical-files)-s[report when two files are the same]' \
-    '(-x)--exclude=[exclude files matching pattern]:pattern:' \
-    '(--exclude)-x[exclude files matching pattern]:pattern:' \
-    '(-X)--exclude-from=[exclude files matching pattern in file]:file:_files' \
-    '(--exclude-from)-X[exclude files matching pattern in file]:file:_files' \
-    '(-S)--starting-file=[set first file in comparison]:file:_files' \
-    '(--starting-file)-S=[set first file in comparison]:file:_files' \
-    '--horizon-lines=[set number of lines to keep in prefix and suffix]:number:' \
+    '(-x)--exclude=[exclude files matching pattern]:exclusion pattern:' \
+    '(--exclude)-x[exclude files matching pattern]:exclusion pattern:' \
+    '(-X)--exclude-from=[exclude files matching pattern in file]:exclude file:_files' \
+    '(--exclude-from)-X[exclude files matching pattern in file]:exclude file:_files' \
+    '(-S)--starting-file=[set first file in comparison]:start with file:_files' \
+    '(--starting-file)-S=[set first file in comparison]:start with file:_files' \
+    '--horizon-lines=[set number of lines to keep in prefix and suffix]:number of horizon lines:' \
     '(-d)--mininal[try to find a smaler set of changes]' \
     '(--mininal)-d[try to find a smaler set of changes]' \
     '(-H)--speed-large-files[assume large files and many small changes]' \

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


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

* PATCH: _diff (new), _prcs (upgrade)
@ 2000-01-27 14:52 Alexandre Duret-Lutz
  0 siblings, 0 replies; 11+ messages in thread
From: Alexandre Duret-Lutz @ 2000-01-27 14:52 UTC (permalink / raw)
  To: zsh-workers


Here is a diff completion fonction. I have separated _diff_options
(complete options) from _diff (also complete filenames), so that 
completion functions like _prcs may use only _diff_options.

Index: Completion/User/_prcs
--- Completion/User/_prcs Mon, 24 Jan 2000 13:13:23 +0100 Alexandre
+++ Completion/User/_prcs Thu, 27 Jan 2000 15:39:51 +0100 Alexandre
@@ -65,6 +65,7 @@
 	  compress\:"instruct PRCS to save disk space for project"
 	  init\:"create a repository entry"
 	  pdelete\:"delete a repository entry"
+	  pinfo\:"list all projects in the repository"
 	  prename\:"rename a repository entry"
 	  rebuild\:"reconstruct PRCS data files in the repository"
 	  uncompress\:"instruct PRCS to save time in processing project"))'
@@ -75,6 +76,9 @@
       access|compress|init|pdelete|prename|rebuild)
         _prcs_arguments ':project name:_prcs_projects'
         ;;
+      pinfo)
+	_prcs_arguments
+	;;
       uncompress)
         _prcs_arguments \
 	  '-i[expand the entire project immediately]' \
@@ -120,11 +124,6 @@
       '*:file or directory:_files'
     ;;
   diff)
-#
-# FIXME: when there will be a _diff completion function,
-#        we should complete with diff options after `--' :
-# prcs diff [OPTION ...] [PROJECT [FILE-OR-DIR ...]] [-- [DIFF-OPTION ...]]
-#
     _prcs_arguments \
       '*--revison=[version of the project]:revision:' \
       '*-r[version of the project]:revision:' \
@@ -134,6 +133,7 @@
       '(--new)-N[compare new files against empty files]' \
       "(-P)--exclude-project-file[don't diff the project file]" \
       "(--exclude-project-file)-P[don't diff the project file]" \
+      '--[introduce diff options]:*:diff options: _diff_options' \
       ':project name:_prcs_projects' \
       '*:file or directory:_files'
     ;;
Index: Completion/User/_diff_options
--- Completion/User/_diff_options Thu, 27 Jan 2000 15:51:05 +0100 Alexandre
+++ Completion/User/_diff_options Thu, 27 Jan 2000 15:38:01 +0100 Alexandre
@@ -0,0 +1,127 @@
+#autoload
+
+local of ofwuc ouc oss ofwy ofwg ofwl
+
+(( $+_diff_is_gnu )) || {
+	_diff_is_gnu=0;
+        [[ $(diff -v </dev/null) == *GNU* ]] && _diff_is_gnu=1
+}
+
+if (( _diff_is_gnu ))
+then
+  # output formats 
+  of="-y --side-by-side -n --rcs -e -f --ed -q --brief -c -C --context -u -U \
+  --unified --old-group-format --new-group-format --changed-group-format \
+  --unchanged-group-format --line-format --old-line-format --new-line-format \
+  --changed-line-format"
+
+  # output formats w/o unified and context
+  ofwuc="-y --side-by-side -n --rcs -e -f --ed -q --brief --old-group-format \
+  --new-group-format --changed-group-format --unchanged-group-format \
+  --line-format --old-line-format --new-line-format --changed-line-format"
+
+  # option specific to unified or context diff
+  ouc='-L --label -p --show-c-function -F --show-function-line'
+
+  # option specific to side by side
+  oss='-W --width --left-column --suppress-common-lines'
+
+  # output formats w/o side by side
+  ofwy="-n --rcs -e -f --ed -q --brief -c -C --context -u -U --unified \
+  --old-group-format --new-group-format --changed-group-format \
+  --unchanged-group-format --line-format --old-line-format \
+  --new-line-format --changed-line-format"
+
+  # output formats w/o group format
+  ofwg="-n --rcs -e -f --ed -q --brief -c -C --context -u -U --unified \
+  --line-format --old-line-format --new-line-format --changed-line-format"
+
+  # output formats w/o line format
+  ofwl="-n --rcs -e -f --ed -q --brief -c -C --context -u -U --unified \
+  --old-group-format --new-group-format --changed-group-format \
+  --unchanged-group-format"
+
+  _arguments -s \
+    '(-i)--ignore-case[case insensitive]' \
+    '(--ignore-case)-i[case insensitive]' \
+    '(-w)--ignore-all-space[ignore all white space]' \
+    '(--ignore-all-space)-w[ignore all white space]' \
+    '(-b)--ignore-space-change[ignore changes in the amount of white space]' \
+    '(--ignore-space-change)-b[ignore changes in the amount of white space]' \
+    '(-B)--ignore-blank-lines[ignore lines that are all blank]' \
+    '(--ignore-blank-lines)-B[ignore lines that are all blank]' \
+    '(-I)--ignore-matching-lines=[ignore lines that match regex]:regex:' \
+    '(--ignore-matching-lines)-I[ignore lines that match regex]:regex:' \
+    '(-a)--text[treat all files as text]' \
+    '(--text)-a[treat all files as text]' \
+    "($of $oss)--context=[context diff]::# lines of copied context:" \
+    "($of $oss)-C[output a context diff]:# lines of copied context:" \
+    "($of $oss)-c[output a context diff]" \
+    "($of $oss)--unified=[output a unified diff]::# lines of unified context:" \
+    "($of $oss)-U[output a unified diff]:# lines of unified context:" \
+    "($of $oss)-u[output a unified diff]" \
+    "($ofwuc $oss -L)--label[set label to use instead of file name]:label:" \
+    "($ofwuc $oss --label)-L[set label to use instead of file name]:label:" \
+    "($ofwuc $oss -p)--show-c-function[show C function of each change]" \
+    "($ofwuc $oss --show-c-function)-p[show C function of each change]" \
+    "($ofwuc $oss -F)--show-function-line=[show the most recent line matching regex]:regex:" \
+    "($ofwuc $oss --show-function-line)-F[show the most recent line matching regex]:regex:" \
+    "($of $ouc $oss)--brief[output only whether files differ]" \
+    "($of $ouc $oss)-q[output only whether files differ]" \
+    "($of $ouc $oss)--ed[output an ed script]" \
+    "($of $ouc $oss)-f[output a reversed ed script]" \
+    "($of $ouc $oss)-e[output an ed script]" \
+    "($of $ouc $oss)--rcs[RCS format diff]" \
+    "($of $ouc $oss)-n[RCS format diff]" \
+    "($of $ouc)--side-by-side[output in two columns]" \
+    "($of $ouc)-y[output in two columns]" \
+    "($ofwy $ouc -W)--width[set size of line]:# characters per line:" \
+    "($ofwy $ouc --width)-W[set size of line]:# characters per line:" \
+    "($ofwy $ouc)--left-column[output only left column of common lines]" \
+    "($ofwy $ouc)--suppress-common-lines[do not ouput commun lines]" \
+    "($ofwg $ouc $oss)--old-group-format=[set old group format]:group format:" \
+    "($ofwg $ouc $oss)--new-group-format=[set new group format]:group format:" \
+    "($ofwg $ouc $oss)--changed-group-format=[set changed group format]:group format:" \
+    "($ofwg $ouc $oss)--unchanged-group-format=[set unchanged group format]:group format:" \
+    "($ofwl $ouc $oss)--line-format=[set line format]:line format:" \
+    "($ofwl $ouc $oss)--old-line-format=[set old line format]:line format:" \
+    "($ofwl $ouc $oss)--new-line-format=[set new line format]:line format:" \
+    "($ofwl $ouc $oss)--changed-line-format=[set changed line format]:line format:" \
+    '(-l)--paginate[output through pr]' \
+    '(--paginate)-l[output through pr]' \
+    '(-t)--expand-tabs[expand tabs to spaces]' \
+    '(--expand-tabs)-t[expand tabs to spaces]' \
+    '(-T)--initial-tab[prepend a tab]' \
+    '(--initial-tab)-T[prepend a tab]' \
+    '(-r)--recursive[recursively compare subdirectories]' \
+    '(--recursive)-r[recursively compare subdirectories]' \
+    '(-N)--new-file[treat absent files as empty]' \
+    '(--new-file)-N[treat absent files as empty]' \
+    '(-P)--unidirectional-new-file[treat absent first files as empty]' \
+    '(--unidirectional-new-file)-P[treat absent first files as empty]' \
+    '(-s)--report-identical-files[report when two files are the same]' \
+    '(--report-identical-files)-s[report when two files are the same]' \
+    '(-x)--exclude=[exclude files matching pattern]:pattern:' \
+    '(--exclude)-x[exclude files matching pattern]:pattern:' \
+    '(-X)--exclude-from=[exclude files matching pattern in file]:file:_files' \
+    '(--exclude-from)-X[exclude files matching pattern in file]:file:_files' \
+    '(-S)--starting-file=[set first file in comparison]:file:_files' \
+    '(--starting-file)-S=[set first file in comparison]:file:_files' \
+    '--horizon-lines=[set number of lines to keep in prefix and suffix]:number:' \
+    '(-d)--mininal[try to find a smaler set of changes]' \
+    '(--mininal)-d[try to find a smaler set of changes]' \
+    '(-H)--speed-large-files[assume large files and many small changes]' \
+    '(--speed-large-files)-H[assume large files and many small changes]' \
+    '(--version)-v[output version info]' \
+    '(-v)--version[output version info]' \
+    '--help[help text]' \
+    $@
+else
+  _arguments \
+    "(-e -f)-c[output a context diff]" \
+    "(-c -f)-e[output an ed script]" \
+    "(-c -e)-f[output a reversed ed script]" \
+    '-b[skip trailing white spaces]' \
+    '-r[recursively compare subdirectories]' \
+    $@
+fi
Index: Completion/User/_diff
--- Completion/User/_diff Thu, 27 Jan 2000 15:51:05 +0100 Alexandre
+++ Completion/User/_diff Thu, 27 Jan 2000 15:08:15 +0100 Alexandre
@@ -0,0 +1,3 @@
+#compdef diff
+
+_diff_options ':original file:_files' ':new file:_files'


-- 
Alexandre Duret-Lutz


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

end of thread, other threads:[~2000-01-31  9:45 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-01-28 10:25 PATCH: _diff (new), _prcs (upgrade) Sven Wischnowsky
2000-01-28 15:04 ` Alexandre Duret-Lutz
  -- strict thread matches above, loose matches on Subject: below --
2000-01-31  9:09 Sven Wischnowsky
2000-01-28 15:11 Sven Wischnowsky
2000-01-28 16:24 ` Alexandre Duret-Lutz
2000-01-28  8:26 Sven Wischnowsky
2000-01-28  9:49 ` Alexandre Duret-Lutz
2000-01-27 16:08 Sven Wischnowsky
2000-01-27 17:21 ` Alexandre Duret-Lutz
2000-01-29  8:49 ` Alexandre Duret-Lutz
2000-01-27 14:52 Alexandre Duret-Lutz

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