zsh-workers
 help / color / mirror / code / Atom feed
* Re: PATCH: new _print and thoughts on _arguments mutexes
@ 2000-04-19 14:53 Sven Wischnowsky
  0 siblings, 0 replies; 6+ messages in thread
From: Sven Wischnowsky @ 2000-04-19 14:53 UTC (permalink / raw)
  To: zsh-workers


Oliver Kiddle wrote:

> This patch adds a new completion for _print and adds a couple more
> commands to _nothing. Does anyone know how I can determine if there is a
> currently active coprocess so the -p flag is only offered if it can be
> used.

I can't think of a way... if it turns out that it is impossible, maybe 
we (c|sh)ould fake `/dev/fd/coproc-{in,out}'?

> ...
> 
> Writing this completion, I came across a characteristic of _arguments
> which I think should be changed (if it can be fairly easily). The -R
> option is unusual in that it can be used after lots of the other options
> but only -n and -e can be used after it. This is easy to handle - the
> list of options which can't appear after -R are in the mutex list for -R
> but -R is not in the mutex list for all the other options. Unfortunately
> this doesn't work when you move the cursor before -R on the line:
> 
> cd -  -R<tab>
>     ^cursor here
> 
> will only complete the -n option. This is fine in that it does what the
> documentation says it does but we have a certain amount of redundancy in
> our _arguments syntax. If two arguments are mutually exclusive, we have
> to put each of them in each others mutex list so in effect we are
> duplicating the information that they are mutually exclusive. If we
> redefined the mutex lists to mean that they listed arguments which could
> not follow this argument then we could handle situations like print's
> -R.

That's easy to implement. No patch yet, I'll have a look at the other
_arguments stuff mentioned by you some time ago and the one mentioned
by Tanaka at the weekend.

> One final question: was _vars_eq intended to be a general function to be
> used from other completion functions? In other words, when I come to do
> _arguments style completion for typeset, should I modify _vars_eq or
> call it from a new _typeset?

No, _vars_eq was only intended for use with commands that get
variables or variable assignments. Use it. Weird name, though. My
fault, no doubt.

> How do I persuade cvs diff to give me something for new files? I've
> manually added a diff against /dev/null so you may have to separate it
> to apply the patch (or wait until I commit it).

I'd like to know that, too...

Bye
 Sven


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


^ permalink raw reply	[flat|nested] 6+ messages in thread
* PATCH: new _print and thoughts on _arguments mutexes
@ 2000-04-19 14:39 Oliver Kiddle
  2000-04-19 15:13 ` Zefram
  0 siblings, 1 reply; 6+ messages in thread
From: Oliver Kiddle @ 2000-04-19 14:39 UTC (permalink / raw)
  To: Zsh workers

This patch adds a new completion for _print and adds a couple more
commands to _nothing. Does anyone know how I can determine if there is a
currently active coprocess so the -p flag is only offered if it can be
used. I can find out which file-descriptors are currently active using
/dev/fd/n tests but I haven't bothered because it wouldn't be much use
unless I could create meaningful descriptions of the file/pipe that the
file-descriptor points to.

Writing this completion, I came across a characteristic of _arguments
which I think should be changed (if it can be fairly easily). The -R
option is unusual in that it can be used after lots of the other options
but only -n and -e can be used after it. This is easy to handle - the
list of options which can't appear after -R are in the mutex list for -R
but -R is not in the mutex list for all the other options. Unfortunately
this doesn't work when you move the cursor before -R on the line:

cd -  -R<tab>
    ^cursor here

will only complete the -n option. This is fine in that it does what the
documentation says it does but we have a certain amount of redundancy in
our _arguments syntax. If two arguments are mutually exclusive, we have
to put each of them in each others mutex list so in effect we are
duplicating the information that they are mutually exclusive. If we
redefined the mutex lists to mean that they listed arguments which could
not follow this argument then we could handle situations like print's
-R.

To implement it, the list of mutexes of all arguments to the left of the
cursor would be considered and for all arguments to the right of the
cursor, any arguments which have them in their mutex list should not be
offered for completion.

One final question: was _vars_eq intended to be a general function to be
used from other completion functions? In other words, when I come to do
_arguments style completion for typeset, should I modify _vars_eq or
call it from a new _typeset?

How do I persuade cvs diff to give me something for new files? I've
manually added a diff against /dev/null so you may have to separate it
to apply the patch (or wait until I commit it).

Oliver Kiddle

Index: .distfiles
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Builtins/.distfiles,v
retrieving revision 1.2
diff -r1.2 .distfiles
5,7c5,7
<     _hash _kill _limits _nothing _pids _popd _sched _set _setopt _source
<     _stat _trap _unhash _unsetopt _vars _vars_eq _wait _which _zcompile
<     _zftp _zle _zmodload _zpty _signals _zstyle
---
>     _hash _kill _limits _nothing _pids _popd _print _sched _set _setopt
>     _source _stat _trap _unhash _unsetopt _vars _vars_eq _wait _which
>     _zcompile _zftp _zle _zmodload _zpty _signals _zstyle
Index: _nothing
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Builtins/_nothing,v
retrieving revision 1.2
diff -r1.2 _nothing
1c1
< #compdef true false log times whoami
---
> #compdef true false log times clear logname whoami
--- /dev/null	Wed Mar  3 17:20:11 1999
+++ Completion/Builtins/_print	Wed Apr 19 15:27:23 2000
@@ -0,0 +1,26 @@
+#compdef print
+
+local state expl line eflag
+
+# -e flag available only after -R 
+eflag="${words[1,CURRENT-1][(r)-*R*]:+-e[enable escapes]}"
+
+_arguments -C -s \
+  '-r[ignore escape conventions of echo]' \
+  '(-r -b -m -s -l -N -o -O -i -c -u -p -z -D -P)-R[emulate BSD echo (no escapes, -n & -e flags only)]' \
+  '-b[recognise bindkey escape sequences]' \
+  '-m[remove arguments matching specified pattern]' \
+  '(-u -p -z)-s[place results in the history list]' \
+  '(-N -c)-n[do not add a newline to the result]' \
+  '(-N -c)-l[print arguments separated by newlines]' \
+  '(-n -l -c)-N[print arguments separated and terminated by nulls]' \
+  '(-O)-o[sort arguments in ascending order]' \
+  '(-o)-O[sort arguments in descending order]' \
+  '-i[case-insensitive sorting]' \
+  '(-n -l -N)-c[print arguments in columns]' \
+  '(-s -p -z)-u+[specify file-descriptor to print arguments to]:file-descritor' \
+  '(-s -u -z)-p[print arguments to input of coprocess]' \
+  '(-s -p -u)-z[push arguments onto editing buffer stack]' \
+  '-D[substitute any arguments which are named directories using ~ notation]' \
+  '-P[perform prompt expansion]' \
+  $eflag '*:default:_default'


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

end of thread, other threads:[~2000-04-19 16:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-04-19 14:53 PATCH: new _print and thoughts on _arguments mutexes Sven Wischnowsky
  -- strict thread matches above, loose matches on Subject: below --
2000-04-19 14:39 Oliver Kiddle
2000-04-19 15:13 ` Zefram
2000-04-19 15:50   ` Oliver Kiddle
2000-04-19 15:58     ` Zefram
2000-04-19 16:07       ` Trond Eivind Glomsrød

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