zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: update-alternatives completion
@ 2001-05-28 19:05 Clint Adams
  2001-05-29  7:25 ` Sven Wischnowsky
  0 siblings, 1 reply; 8+ messages in thread
From: Clint Adams @ 2001-05-28 19:05 UTC (permalink / raw)
  To: zsh-workers

The problem I alluded to in 14512 is present here.  If one
tries to complete update-alternatives --remove,
it tries to complete an "alt" argument in between
--remove and the 1st argument.  Since the state is specified
rather than possible completions for that argument, it
doesn't seem very useful.

Also, the slave substate doesn't work, but I haven't
bothered to look into it yet.

Index: Completion/Debian/Command/.distfiles
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Debian/Command/.distfiles,v
retrieving revision 1.1
diff -u -r1.1 .distfiles
--- Completion/Debian/Command/.distfiles	2001/04/02 12:43:00	1.1
+++ Completion/Debian/Command/.distfiles	2001/05/28 18:59:57
@@ -1,4 +1,5 @@
 DISTFILES_SRC='
 .distfiles
 _apt          _bug          _dpkg         _dpkg_source  _dupload
+_update_alternatives
 '
Index: Completion/Debian/Command/_update-alternatives
===================================================================
RCS file: _update-alternatives
diff -N _update-alternatives
--- /dev/null	Thu May 24 22:33:05 2001
+++ _update-alternatives	Mon May 28 11:59:57 2001
@@ -0,0 +1,41 @@
+#compdef update-alternatives
+
+local curcontext="$curcontext" context state line expl ret
+typeset -A opt_args
+
+_arguments -C '--verbose' \
+           '--quiet' \
+           '--test' \
+           '--help' \
+           '--version' \
+           '--altdir:altdir:_files -/' \
+           '--admindir:admindir:_files -/' \
+    '--install:*::alt:->install' \
+    '--remove:*::alt:->remove' \
+    '--auto:altname:_files -W /var/lib/dpkg/alternatives' \
+    '--display:altname:_files -W /var/lib/dpkg/alternatives' \
+    '--config:altname:_files -W /var/lib/dpkg/alternatives' && return 0
+
+_call_function ret _update_alternatives_$state && return ret
+case "$state" in
+	islave)
+	_arguments -C '1:link:_files' \
+                   '2:name:_files -W /var/lib/dpkg/alternatives' \
+                   '3:path:_files' \
+                   '--slave:*::slave:->islave'
+	;;
+	install)
+	_arguments -C '1:link:_files' \
+                   '2:name:_files -W /var/lib/dpkg/alternatives' \
+                   '3:path:_files' \
+                   '4:priority:' \
+                   '--slave:*::slave:->islave' \
+	;;
+
+	remove)
+	_arguments \
+                   '1:altname:_files -W /var/lib/dpkg/alternatives' \
+                   '2:path:_files'
+	;;
+
+esac


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

* Re: PATCH: update-alternatives completion
  2001-05-28 19:05 PATCH: update-alternatives completion Clint Adams
@ 2001-05-29  7:25 ` Sven Wischnowsky
  2001-05-29  7:31   ` Andrej Borsenkow
  2001-05-29 12:32   ` PATCH: " Clint Adams
  0 siblings, 2 replies; 8+ messages in thread
From: Sven Wischnowsky @ 2001-05-29  7:25 UTC (permalink / raw)
  To: zsh-workers

Clint Adams wrote:

> The problem I alluded to in 14512 is present here.  If one
> tries to complete update-alternatives --remove,
> it tries to complete an "alt" argument in between
> --remove and the 1st argument.  Since the state is specified
> rather than possible completions for that argument, it
> doesn't seem very useful.

Here's the code:

> +    '--install:*::alt:->install' \
> +    '--remove:*::alt:->remove' \

The `:*::' removes everything up to the first argument after --remove
and --install.  Everything.  In particular: there's no `command word'
anymore and quite some time ago we decided that _arguments has to be
careful to complete only real arguments -- hence you don't get
completion for the first argument after these options.  Once there is an
argument, the calls to _arguments in the state-handling code are happy
to serve you because now they think that that first argument to the
option is the command word.

To solve this, we invented the `= ' prefix for _argument actions, i.e.:
just change the above to `...:= ->install' and so on.

> 
> Also, the slave substate doesn't work, but I haven't
> bothered to look into it yet.

By this description I don't know what you mean -- and without anything
debianish here I can't really try.  But anyway, you'd need some kind of
loop around the `case...esac' to enable these:

> +                   '--slave:*::slave:->islave' \

But of course you know that...

> ...
> 
> +                   '1:altname:_files -W /var/lib/dpkg/alternatives' \

Isn't there a better description than `altname'?  Or is this some well
known, recognised word in the debian world?


Bye
  Sven

P.S.: Too late now, but do you really like these mixed underscore/hyphen
      names?
P.P.S.: A command name with 19 characters?  What are we coming to... ;-)

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


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

* RE: PATCH: update-alternatives completion
  2001-05-29  7:25 ` Sven Wischnowsky
@ 2001-05-29  7:31   ` Andrej Borsenkow
  2001-05-29 12:34     ` Clint Adams
  2001-05-29 12:32   ` PATCH: " Clint Adams
  1 sibling, 1 reply; 8+ messages in thread
From: Andrej Borsenkow @ 2001-05-29  7:31 UTC (permalink / raw)
  To: zsh-workers



> P.P.S.: A command name with 19 characters?  What are we coming to... ;-)

You mean update-alternatives? It is not intended to be run by users but as a
tool for packagers (run during package installation).

-andrej


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

* PATCH: Re: PATCH: update-alternatives completion
  2001-05-29  7:25 ` Sven Wischnowsky
  2001-05-29  7:31   ` Andrej Borsenkow
@ 2001-05-29 12:32   ` Clint Adams
  2001-05-29 13:08     ` Sven Wischnowsky
  1 sibling, 1 reply; 8+ messages in thread
From: Clint Adams @ 2001-05-29 12:32 UTC (permalink / raw)
  To: Sven Wischnowsky; +Cc: zsh-workers

> To solve this, we invented the `= ' prefix for _argument actions, i.e.:
> just change the above to `...:= ->install' and so on.

That did the trick.

> By this description I don't know what you mean -- and without anything
> debianish here I can't really try.  But anyway, you'd need some kind of
> loop around the `case...esac' to enable these:
> 
> > +                   '--slave:*::slave:->islave' \
> 
> But of course you know that...

Here's an example of a valid command:

update-alternatives --quiet --install /usr/bin/awk awk /usr/bin/gawk 10 \
  --slave /usr/share/man/man1/awk.1.gz awk.1.gz /usr/share/man/man1/gawk.1.gz \
  --slave /usr/bin/nawk nawk /usr/bin/gawk \
  --slave /usr/share/man/man1/nawk.1.gz nawk.1.gz /usr/share/man/man1/gawk.1.gz

For each --slave, you repeat the <path> <name> <path>.

> Isn't there a better description than `altname'?  Or is this some well
> known, recognised word in the debian world?

No, it's not.  I've changed it to `name' for now, though `alternative name'
would be correct as well, I suppose.

> P.S.: Too late now, but do you really like these mixed underscore/hyphen
>       names?

No, I actually typed _update_alternatives in .distfiles, but of course
that didn't work out well seeing as how the file is named something
else.

> P.P.S.: A command name with 19 characters?  What are we coming to... ;-)

I guess you haven't seen /usr/sbin/upgrade-windowmaker-defaults

Index: Completion/Debian/Command/_dpkg
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Debian/Command/_dpkg,v
retrieving revision 1.2
diff -u -r1.2 _dpkg
--- Completion/Debian/Command/_dpkg	2001/05/28 18:59:03	1.2
+++ Completion/Debian/Command/_dpkg	2001/05/29 12:15:40
@@ -58,7 +58,7 @@
            '--print-architecture[print target architecture]' \
            '--print-gnu-build-architecture[print GNU version of target architecture]' \
            '--print-installation-architecture[print host architecture]' \
-           '--compare-versions[compare version numbers]:*:expression:->compare_versions')
+           '--compare-versions[compare version numbers]:*::expression:= ->compare_versions')
 
 _dpkg_options=('--abort-after[abort after errors]:number of errors:' \
            '--admindir=[data directory]:directory:_files -/' \
Index: Completion/Debian/Command/_update-alternatives
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Debian/Command/_update-alternatives,v
retrieving revision 1.1
diff -u -r1.1 _update-alternatives
--- Completion/Debian/Command/_update-alternatives	2001/05/28 19:06:51	1.1
+++ Completion/Debian/Command/_update-alternatives	2001/05/29 12:15:40
@@ -10,11 +10,11 @@
            '--version' \
            '--altdir:altdir:_files -/' \
            '--admindir:admindir:_files -/' \
-    '--install:*::alt:->install' \
-    '--remove:*::alt:->remove' \
-    '--auto:altname:_files -W /var/lib/dpkg/alternatives' \
-    '--display:altname:_files -W /var/lib/dpkg/alternatives' \
-    '--config:altname:_files -W /var/lib/dpkg/alternatives' && return 0
+    '--install:*::alt:= ->install' \
+    '--remove:*::alt:= ->remove' \
+    '--auto:name:_files -W /var/lib/dpkg/alternatives' \
+    '--display:name:_files -W /var/lib/dpkg/alternatives' \
+    '--config:name:_files -W /var/lib/dpkg/alternatives' && return 0
 
 _call_function ret _update_alternatives_$state && return ret
 case "$state" in
@@ -34,7 +34,7 @@
 
 	remove)
 	_arguments \
-                   '1:altname:_files -W /var/lib/dpkg/alternatives' \
+                   '1:name:_files -W /var/lib/dpkg/alternatives' \
                    '2:path:_files'
 	;;
 


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

* Re: PATCH: update-alternatives completion
  2001-05-29  7:31   ` Andrej Borsenkow
@ 2001-05-29 12:34     ` Clint Adams
  2001-05-29 14:28       ` Andrej Borsenkow
  0 siblings, 1 reply; 8+ messages in thread
From: Clint Adams @ 2001-05-29 12:34 UTC (permalink / raw)
  To: Andrej Borsenkow; +Cc: zsh-workers

> You mean update-alternatives? It is not intended to be run by users but as a
> tool for packagers (run during package installation).

That's not true.  --install and --remove are generally the province
of installation and removal scripts, but --auto, --display and --config
are certainly meant for interactive use by the system administrator.


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

* Re: PATCH: Re: PATCH: update-alternatives completion
  2001-05-29 12:32   ` PATCH: " Clint Adams
@ 2001-05-29 13:08     ` Sven Wischnowsky
  2001-05-29 14:19       ` Clint Adams
  0 siblings, 1 reply; 8+ messages in thread
From: Sven Wischnowsky @ 2001-05-29 13:08 UTC (permalink / raw)
  To: zsh-workers

Clint Adams wrote:

> ...
> 
> update-alternatives --quiet --install /usr/bin/awk awk /usr/bin/gawk 10 \
>   --slave /usr/share/man/man1/awk.1.gz awk.1.gz /usr/share/man/man1/gawk.1.gz \
>   --slave /usr/bin/nawk nawk /usr/bin/gawk \
>   --slave /usr/share/man/man1/nawk.1.gz nawk.1.gz /usr/share/man/man1/gawk.1.gz
> 
> For each --slave, you repeat the <path> <name> <path>.

Two possibilities, then (at least).  The large one (simplified):

  while true; do
  
    case "$state" in
  
    islave)
      state=
      _arguments '1:path:(spath)' \
                 '2:name:(sname)' \
                 '3:path:(spath2)' \
                 '--slave:*::more:= ->islave' && return 0
      [[ -z $state ]] && return 1
      ;;
  
    install)
      _arguments '1:link:(link)' \
                 '2:name:(name)' \
                 '3:path:(path)' \
                 '--slave:*::more:= ->islave' && return 0
      [[ -z $state ]] && return 1
      ;;

    other states)
      ...
      ;;
  
    esac
  done

Or just (simplified, too):

  case "$state" in
  other states)
    ...
    ;;

  install)
    _arguments '1:link:(link)' \
               '2:name:(name)' \
               '3:path:(path)' \
               '*--slave:path:(spath):name:(sname):path:(spath2)'
  esac

Without a `islave' state.  It would allow mixing the arguments of
--install with the --slave options which probably isn't allowed.


Bye
  Sven

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


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

* Re: PATCH: Re: PATCH: update-alternatives completion
  2001-05-29 13:08     ` Sven Wischnowsky
@ 2001-05-29 14:19       ` Clint Adams
  0 siblings, 0 replies; 8+ messages in thread
From: Clint Adams @ 2001-05-29 14:19 UTC (permalink / raw)
  To: Sven Wischnowsky; +Cc: zsh-workers

> Two possibilities, then (at least).  The large one (simplified):

Here goes.

Index: Completion/Debian/Command/_update-alternatives
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Debian/Command/_update-alternatives,v
retrieving revision 1.2
diff -u -r1.2 _update-alternatives
--- Completion/Debian/Command/_update-alternatives	2001/05/29 12:39:31	1.2
+++ Completion/Debian/Command/_update-alternatives	2001/05/29 14:17:16
@@ -16,26 +16,39 @@
     '--display:name:_files -W /var/lib/dpkg/alternatives' \
     '--config:name:_files -W /var/lib/dpkg/alternatives' && return 0
 
-_call_function ret _update_alternatives_$state && return ret
+while true; do
 case "$state" in
 	islave)
+        _call_function ret _update_alternatives_$state && return ret
+	state=
 	_arguments -C '1:link:_files' \
                    '2:name:_files -W /var/lib/dpkg/alternatives' \
                    '3:path:_files' \
-                   '--slave:*::slave:->islave'
+                   '--slave:*::more:= ->islave' && return 0
+        [[ -z $state ]] && return 1
 	;;
+
 	install)
+        _call_function ret _update_alternatives_$state && return ret
 	_arguments -C '1:link:_files' \
                    '2:name:_files -W /var/lib/dpkg/alternatives' \
                    '3:path:_files' \
                    '4:priority:' \
-                   '--slave:*::slave:->islave' \
+                   '--slave:*::slave:= ->islave' && return 0
+        [[ -z $state ]] && return 1
 	;;
 
 	remove)
+        _call_function ret _update_alternatives_$state && return ret
 	_arguments \
                    '1:name:_files -W /var/lib/dpkg/alternatives' \
-                   '2:path:_files'
+                   '2:path:_files' && return 0
+        return 1
+	;;
+
+	*)
+	return 1
 	;;
 
 esac
+done


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

* RE: PATCH: update-alternatives completion
  2001-05-29 12:34     ` Clint Adams
@ 2001-05-29 14:28       ` Andrej Borsenkow
  0 siblings, 0 replies; 8+ messages in thread
From: Andrej Borsenkow @ 2001-05-29 14:28 UTC (permalink / raw)
  To: zsh-workers


> 
> > You mean update-alternatives? It is not intended to be run by 
> users but as a
> > tool for packagers (run during package installation).
> 
> That's not true.  --install and --remove are generally the province
> of installation and removal scripts, but --auto, --display and --config
> are certainly meant for interactive use by the system administrator.
> 

For me a-aTAB is O.K. :-) It is just 4 characters.


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

end of thread, other threads:[~2001-05-29 14:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-28 19:05 PATCH: update-alternatives completion Clint Adams
2001-05-29  7:25 ` Sven Wischnowsky
2001-05-29  7:31   ` Andrej Borsenkow
2001-05-29 12:34     ` Clint Adams
2001-05-29 14:28       ` Andrej Borsenkow
2001-05-29 12:32   ` PATCH: " Clint Adams
2001-05-29 13:08     ` Sven Wischnowsky
2001-05-29 14:19       ` Clint Adams

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