zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: completion for a couple more builtins
@ 2001-04-11 20:10 Oliver Kiddle
  2001-04-11 21:30 ` Slash after directory number in cd completion? Andrej Borsenkow
  2001-04-11 22:15 ` PATCH: completion for a couple more builtins Bart Schaefer
  0 siblings, 2 replies; 7+ messages in thread
From: Oliver Kiddle @ 2001-04-11 20:10 UTC (permalink / raw)
  To: zsh-workers

This patch adds _arguments based completion for alias and jobs.
Unfortunately, _jobs already exists for completing jobs so I've had to
use the name _jobs_builtin. I'm happy to rename this if anyone can think
of a better name. These were the only builtins I identified as using an
existing completion but needing a proper one using _arguments.

To summarise, remaining builtins lacking a proper completion are:

pushln, getln, limit, unlimit, unset - possibly should be done
exit, bye, logout, return - should we use the _message completion
suggested?
echoti - if we sort out ${(k)terminfo} this would be easy
[, test - should we use the _message suggestion directing users to
[[..]]?
echo, pwd - easy if we ignore the possibility that it is echo/pwd from
/bin
dirs, suspend, zprof, unalias - only take one option which makes it a
bit pointless
break, continue, comp*, zformat, zparseopts, zregexparse - not useful
interactively
umask - would just be _message so a bit pointless
_typeset should possibly handle autoload and functions
there is also the cap and clone modules but I never use them so am not
sure what they should be.

Oliver

Index: Completion/Zsh/Command/_alias
===================================================================
RCS file: _alias
diff -N _alias
--- /dev/null	Mon Dec 11 17:26:27 2000
+++ _alias	Wed Apr 11 14:06:46 2001
@@ -0,0 +1,8 @@
+#compdef alias
+
+_arguments -C -s -A "-*" -S \
+  '-+g[list or define global aliases]' \
+  '-+r[list or define regular aliases]' \
+  '-+m[print aliases matching specified pattern]' \
+  '-L[print each alias in the form of calls to alias]' \
+  '*::alias definition:_aliases -S ='
Index: Completion/Zsh/Command/_fc
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Zsh/Command/_fc,v
retrieving revision 1.1
diff -u -r1.1 _fc
--- Completion/Zsh/Command/_fc	2001/04/02 11:28:31	1.1
+++ Completion/Zsh/Command/_fc	2001/04/11 21:06:46
@@ -1,13 +1,13 @@
 #compdef fc history r
 
-local expl fc_common fc_hist fc_r
+local fc_common fc_hist fc_r
 
 fc_common=(
   '(-A -R -W -I)-r[reverse order of the commands]'
   '(-A -R -W -I -e)-n[suppress line numbers]'
   '(-A -R -W -I)*::commands:_command_names -e' )
 
-fc_hist=( \
+fc_hist=(
   '(-A -R -W -I)-m[treat first argument as a pattern]'
   '(-A -R -W -I -e -f -E -i)-d[print time-stamps]'
   '(-A -R -W -I -e -d -E -i)-f[mm/dd/yyyy format time-stamps]'
@@ -19,13 +19,13 @@
 
 case $service in
   history)
-    _arguments -C -s -S "$fc_common[@]" "$fc_hist[@]" && return 0
+    _arguments -s -S "$fc_common[@]" "$fc_hist[@]" && return 0
   ;;
   r)
-    _arguments -C -s -S "$fc_common[@]" "$fc_r" && return 0
+    _arguments -s -S "$fc_common[@]" "$fc_r" && return 0
   ;;
   *)
-  _arguments -C -s -S \
+  _arguments -s -S \
     '(-A -R -W -I -l -n -d -f -E -i -D)-e[specify editor to
invoke]:editor to invoke:_command_names -e' \
     '(-l -m -e -r -n -d -f -E -i -D -A -W *)-R[read history from
file]:history file:_files' \
     '(-l -m -e -r -n -d -f -E -i -D -R -W *)-A[append history to
file]:history file:_files' \
Index: Completion/Zsh/Command/_jobs_builtin
===================================================================
RCS file: _jobs_builtin
diff -N _jobs_builtin
--- /dev/null	Mon Dec 11 17:26:27 2000
+++ _jobs_builtin	Wed Apr 11 14:06:46 2001
@@ -0,0 +1,10 @@
+#compdef jobs
+
+_arguments -C -s \
+  "(-d -l -p -r -s *)-Z[specify string to replace shell's argument and
environment with]:string" \
+  '(-Z)-d[show directory from which to job was started]' \
+  '(-Z)-l[list process IDs]' \
+  '(-Z)-p[list process groups]' \
+  '(-Z -s)-r[list only running jobs]' \
+  '(-Z -r)-s[list only stopped jobs]' \
+  '(-Z)*::job:_jobs'
Index: Completion/Zsh/Type/_aliases
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Zsh/Type/_aliases,v
retrieving revision 1.1
diff -u -r1.1 _aliases
--- Completion/Zsh/Type/_aliases	2001/04/02 11:18:06	1.1
+++ Completion/Zsh/Type/_aliases	2001/04/11 21:06:47
@@ -1,4 +1,4 @@
-#compdef alias unalias
+#compdef unalias
 
 local expl sel args opts
 
Index: Completion/Zsh/Type/_jobs_fg
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Zsh/Type/_jobs_fg,v
retrieving revision 1.1
diff -u -r1.1 _jobs_fg
--- Completion/Zsh/Type/_jobs_fg	2001/04/02 11:21:11	1.1
+++ Completion/Zsh/Type/_jobs_fg	2001/04/11 21:06:47
@@ -1,3 +1,3 @@
-#compdef disown fg jobs
+#compdef disown fg
 
 _jobs


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

* Slash after directory number in cd completion?
  2001-04-11 20:10 PATCH: completion for a couple more builtins Oliver Kiddle
@ 2001-04-11 21:30 ` Andrej Borsenkow
  2001-04-11 22:06   ` Bart Schaefer
  2001-04-11 22:15 ` PATCH: completion for a couple more builtins Bart Schaefer
  1 sibling, 1 reply; 7+ messages in thread
From: Andrej Borsenkow @ 2001-04-11 21:30 UTC (permalink / raw)
  To: zsh-workers

On Wed, 11 Apr 2001, Oliver Kiddle wrote:

> dirs

It is not directly related, just reminded me:

bor@itsrm2:/u3/Linux%> cd -TAB
bor@itsrm2:/u3/Linux%> cd -1/

Where this slash comes from? It was not there before (it is something
near-4.0.1-pre-3 state, but not exactly).

-andrej


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

* Re: Slash after directory number in cd completion?
  2001-04-11 21:30 ` Slash after directory number in cd completion? Andrej Borsenkow
@ 2001-04-11 22:06   ` Bart Schaefer
  2001-04-12 11:34     ` Oliver Kiddle
  0 siblings, 1 reply; 7+ messages in thread
From: Bart Schaefer @ 2001-04-11 22:06 UTC (permalink / raw)
  To: Andrej Borsenkow, zsh-workers

On Apr 12,  1:30am, Andrej Borsenkow wrote:
} Subject: Slash after directory number in cd completion?
}
} bor@itsrm2:/u3/Linux%> cd -TAB
} bor@itsrm2:/u3/Linux%> cd -1/
} 
} Where this slash comes from?

It's _directory_stack calling `compadd -qS/ ...' via _wanted at line 50.
This is new as of Sven's patch in 13789 (before _popd was renamed).

I think the line

[[ $PREFIX = [-+]* ]] || return 1

needs to be something/somewhere else.  Perhaps like this?  This seems to
work as I expect, but Sven should confirm it when he's back next week.

Index: Completion/Zsh/Type/_directory_stack
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Zsh/Type/_directory_stack,v
retrieving revision 1.1
diff -u -r1.1 _directory_stack
--- Completion/Zsh/Type/_directory_stack	2001/04/02 11:20:31	1.1
+++ Completion/Zsh/Type/_directory_stack	2001/04/11 22:04:39
@@ -13,14 +13,15 @@
   ISUFFIX="/${SUFFIX#*/}$ISUFFIX"
   SUFFIX="${SUFFIX%%/*}"
   suf=(-S '')
-else
+elif [[ $PREFIX != [-+]* ]]; then
   suf=(-qS/)
+else
+  suf=()
 fi
 
 ### we decided against this, for now...
 #! zstyle -T ":completion:${curcontext}:directory-stack" prefix-needed ||
-
-[[ $PREFIX = [-+]* ]] || return 1
+#	[[ $PREFIX = [-+]* ]] || return 1
 
 if zstyle -T ":completion:${curcontext}:directory-stack" verbose; then
   # get the list of directories with their canonical number

-- 
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] 7+ messages in thread

* Re: PATCH: completion for a couple more builtins
  2001-04-11 20:10 PATCH: completion for a couple more builtins Oliver Kiddle
  2001-04-11 21:30 ` Slash after directory number in cd completion? Andrej Borsenkow
@ 2001-04-11 22:15 ` Bart Schaefer
  1 sibling, 0 replies; 7+ messages in thread
From: Bart Schaefer @ 2001-04-11 22:15 UTC (permalink / raw)
  To: zsh-workers

On Apr 11,  9:10pm, Oliver Kiddle wrote:
}
} echoti - if we sort out ${(k)terminfo} this would be easy

Hmm.  _echotc just lists a bunch of capabilities directly ... in fact, it
has some of them in the list twice.

-- 
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] 7+ messages in thread

* Re: Slash after directory number in cd completion?
  2001-04-11 22:06   ` Bart Schaefer
@ 2001-04-12 11:34     ` Oliver Kiddle
  2001-04-12 18:08       ` Bart Schaefer
  2001-04-17  8:52       ` Sven Wischnowsky
  0 siblings, 2 replies; 7+ messages in thread
From: Oliver Kiddle @ 2001-04-12 11:34 UTC (permalink / raw)
  To: zsh-workers

--- Bart Schaefer <schaefer@candle.brasslantern.com> wrote:

> It's _directory_stack calling `compadd -qS/ ...' via _wanted at line
right.

> I think the line
> 
> [[ $PREFIX = [-+]* ]] || return 1

That is needed so that the directory stack is only completed after a -
or + because the matches are added as 0, 1, 2, etc instead of -0, -1,
-2, etc.

> needs to be something/somewhere else.  Perhaps like this?  This seems
> to
> work as I expect, but Sven should confirm it when he's back next
> week.

It doesn't work as I'd expect - it adds the directory stack as
completions without the - and +.

_tilde now supplies the -qS/ option to _directory_stack and this is the
only time it is needed so I believe the following patch is correct
(this is instead of Bart's as opposed to on top of it).

I actually think the correct patch would be to remove the whole if,
then else because it is done in _tilde and isn't otherwise needed. I've
left it for the time being though.

Oliver

Index: Completion/Zsh/Type/_directory_stack
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Zsh/Type/_directory_stack,v
retrieving revision 1.1
diff -u -r1.1 _directory_stack
--- Completion/Zsh/Type/_directory_stack        2001/04/02 11:20:31    
1.1
+++ Completion/Zsh/Type/_directory_stack        2001/04/12 11:32:35
@@ -14,7 +14,7 @@
   SUFFIX="${SUFFIX%%/*}"
   suf=(-S '')
 else
-  suf=(-qS/)
+  suf=()
 fi

 ### we decided against this, for now...


____________________________________________________________
Do You Yahoo!?
Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk
or your free @yahoo.ie address at http://mail.yahoo.ie


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

* Re: Slash after directory number in cd completion?
  2001-04-12 11:34     ` Oliver Kiddle
@ 2001-04-12 18:08       ` Bart Schaefer
  2001-04-17  8:52       ` Sven Wischnowsky
  1 sibling, 0 replies; 7+ messages in thread
From: Bart Schaefer @ 2001-04-12 18:08 UTC (permalink / raw)
  To: zsh-workers

On Apr 12, 12:34pm, Oliver Kiddle wrote:
} Subject: Re: Slash after directory number in cd completion?
}
} _tilde now supplies the -qS/ option to _directory_stack and this is the
} only time it is needed so I believe the following patch is correct

Yes, that does seem better.

On a related note, ~- and ~+ are legitimate with or without a number after
them, but _tilde doesn't know that.

-- 
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] 7+ messages in thread

* Re: Slash after directory number in cd completion?
  2001-04-12 11:34     ` Oliver Kiddle
  2001-04-12 18:08       ` Bart Schaefer
@ 2001-04-17  8:52       ` Sven Wischnowsky
  1 sibling, 0 replies; 7+ messages in thread
From: Sven Wischnowsky @ 2001-04-17  8:52 UTC (permalink / raw)
  To: zsh-workers

[ Hello, everyone.  I'm back. ]

Oliver Kiddle wrote:

> ...
> 
> I actually think the correct patch would be to remove the whole if,
> then else because it is done in _tilde and isn't otherwise needed. I've
> left it for the time being though.

I agree.

Bye
  Sven

Index: Completion/Zsh/Type/_directory_stack
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Zsh/Type/_directory_stack,v
retrieving revision 1.3
diff -u -r1.3 _directory_stack
--- Completion/Zsh/Type/_directory_stack	2001/04/12 11:42:02	1.3
+++ Completion/Zsh/Type/_directory_stack	2001/04/17 08:51:53
@@ -7,16 +7,8 @@
 
 setopt localoptions nonomatch
 
-local expl list lines revlines disp suf
+local expl list lines revlines disp
 
-if [[ "$SUFFIX" = */* ]]; then
-  ISUFFIX="/${SUFFIX#*/}$ISUFFIX"
-  SUFFIX="${SUFFIX%%/*}"
-  suf=(-S '')
-else
-  suf=()
-fi
-
 ### we decided against this, for now...
 #! zstyle -T ":completion:${curcontext}:directory-stack" prefix-needed ||
 
@@ -48,4 +40,4 @@
 fi
 
 _wanted -V directory-stack expl 'directory stack' \
-    compadd "$@" "$suf[@]" "$disp[@]" -Q -a list
+    compadd "$@" "$disp[@]" -Q -a list

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


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

end of thread, other threads:[~2001-04-17  8:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-11 20:10 PATCH: completion for a couple more builtins Oliver Kiddle
2001-04-11 21:30 ` Slash after directory number in cd completion? Andrej Borsenkow
2001-04-11 22:06   ` Bart Schaefer
2001-04-12 11:34     ` Oliver Kiddle
2001-04-12 18:08       ` Bart Schaefer
2001-04-17  8:52       ` Sven Wischnowsky
2001-04-11 22:15 ` PATCH: completion for a couple more builtins 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).