* more interactive menu completion
@ 2003-01-19 23:34 Le Wang
2003-01-20 12:17 ` Borzenkov Andrey
0 siblings, 1 reply; 10+ messages in thread
From: Le Wang @ 2003-01-19 23:34 UTC (permalink / raw)
To: Zsh users list
Hi,
I'm using menu completion now, and I absolutely love
it. However I was just thinking that all of my
keyboard keys are unmapped during menu completion, so
wouldn't it be nice if I could press 'abc', and have
the selection go to the first file starting with an
'abc'? This is very much like the way modern file
managers work (e.g. Explorer, Konqueror, etc), except
they only match the first letter.
It would be great if this kind of widget can be
refined to do substring matching as well. Does this
kind of completion scheme currently exist for Zsh?
--
Le
______________________________________________________________________
Post your free ad now! http://personals.yahoo.ca
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: more interactive menu completion
2003-01-19 23:34 more interactive menu completion Le Wang
@ 2003-01-20 12:17 ` Borzenkov Andrey
2003-01-20 14:23 ` Le Wang
2003-01-20 14:51 ` more interactive menu completion Sven Wischnowsky
0 siblings, 2 replies; 10+ messages in thread
From: Borzenkov Andrey @ 2003-01-20 12:17 UTC (permalink / raw)
To: 'Le Wang', 'Zsh users list'
>
> I'm using menu completion now, and I absolutely love
> it. However I was just thinking that all of my
> keyboard keys are unmapped during menu completion, so
> wouldn't it be nice if I could press 'abc', and have
> the selection go to the first file starting with an
> 'abc'? This is very much like the way modern file
> managers work (e.g. Explorer, Konqueror, etc), except
> they only match the first letter.
>
> It would be great if this kind of widget can be
> refined to do substring matching as well. Does this
> kind of completion scheme currently exist for Zsh?
>
There is incremental-complete-word widget that does what you want. I do not
know if it is widely used, so your comments would be welcome.
incremental-complete-word
This allows incremental completion of a word. After starting this
command, a list of completion choices can be shown after every
character you type, which you can delete with ^H or DEL. Pressing
return accepts the completion so far and returns you to normal
editing (that is, the command line is _not_ immediately executed).
You can hit TAB to do normal completion, ^G to abort back to the
state when you started, and ^D to list the matches.
This works only with the new function based completion system.
bindkey '^Xi' incremental-complete-word
You'll need
fpath=($fpath /path/to/zsh/functions/Zle)
autoload incremental-complete-word
(unless done already).
It did not work for me after quick test :(
-andrey
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: more interactive menu completion
2003-01-20 12:17 ` Borzenkov Andrey
@ 2003-01-20 14:23 ` Le Wang
2003-01-20 14:34 ` Peter Stephenson
2003-01-20 14:34 ` passing arrays Le Wang
2003-01-20 14:51 ` more interactive menu completion Sven Wischnowsky
1 sibling, 2 replies; 10+ messages in thread
From: Le Wang @ 2003-01-20 14:23 UTC (permalink / raw)
To: Zsh users list
--- Borzenkov Andrey <Andrey.Borzenkov@siemens.com>
wrote: >
> > Here is an extension of the problem. Say I have a
> > bunch of functions that operate on $PATH, how
> would I
> > generalize it so that it works with any $PATH like
> > variable?
> >
>
> Hmm ... have you noticed that every your question
> needs at least one reply
> that requests clarification what you really mean? No
> offence intended :)
None taken. I will strive to refine my problem
descriptions.
My problem is as follows:
I currently have:
addToPath () {...}
and I use it as:
addToPath ~/bin/scripts
I would like to have
addToPathVar () {...}
and use it as:
addToPathVar CLASSPATH ~/java/lib
--
Le
______________________________________________________________________
Post your free ad now! http://personals.yahoo.ca
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: more interactive menu completion
2003-01-20 14:23 ` Le Wang
@ 2003-01-20 14:34 ` Peter Stephenson
2003-01-20 14:34 ` passing arrays Le Wang
1 sibling, 0 replies; 10+ messages in thread
From: Peter Stephenson @ 2003-01-20 14:34 UTC (permalink / raw)
To: Zsh users list
Le Wang wrote:
> My problem is as follows:
>
> I currently have:
>
> addToPath () {...}
>
> and I use it as:
>
> addToPath ~/bin/scripts
>
> I would like to have
>
> addToPathVar () {...}
>
> and use it as:
>
> addToPathVar CLASSPATH ~/java/lib
Here's my current solution to this particular problem; it goes back a
few versions of zsh hence it doesn't use all the latest features.
--
Peter Stephenson <pws@csr.com> Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK Tel: +44 (0)1223 692070
## cut
# addpath() # -*-ksh-*-
# Replace or delete a value in a PATH-type variable.
# The first argument is the variable name (not its value, i.e. no $).
# The second is the component to add.
#
# Options: there are two sets of mutually exclusive options (i.e.
# the options inside the set are mutually exclusive, one from each
# set may be used):
# The first set applies if the component is currently in the path.
# -k Keep it where it is (default).
# -r Replace it as given by the -a/-p option.
# -d Delete it from the path.
# If it was not already in the path, or if -r was given, then:
# -a Append the value to the end of the variable (default).
# -p Prepend the value to the beginning of the variable.
local var add before after varnam
local where=-a mode=-k
# We don't want substituted text from parameters to be used as patterns.
[[ -n $ZSH_VERSION ]] && setopt localoptions
unsetopt globsubst
Usage() {
echo 'Usage: addpath [-k|r|d] [-a|p] variable value'
echo '-k|r|d: keep (default), replace or delete'
echo '-a|p: append (default) or prepend'
}
Doadd() {
# Uses $varnam, $var and $add from main function
local result
case "$where" in
-a)
result="${var}:${add}"
;;
*)
result="${add}:${var}"
;;
esac
eval "$varnam=\"$result\""
}
while [[ $1 = -* && $1 != '-' ]]
do
case "$1" in
-[ap])
where=$1
shift
;;
-[krd])
mode=$1
shift
;;
*)
Usage
return 1
;;
esac
done
[[ $1 = '-' ]] && shift
(( $# != 2)) && Usage && return 1
eval var=\"\$$1\"
varnam=$1
shift
add=$1
shift
case "$var" in
*:$add:*|*:$add|$add:*|$add)
case "$mode" in
-k) # do nothing
;;
*)
# Remove the old value.
local found=true
while [[ $found = true ]]; do
case "$var" in
*:$add:*) var="${var%%:$add:*}:${var#*:$add:}"
;;
*:$add) var="${var%%:$add}"
;;
$add:*) var="${var##$add:}"
;;
*) found=false
;;
esac
done
# and replace it if necessary
if [[ $mode = -d ]]; then
eval "$varnam=\"$var\""
else
Doadd
fi
;;
esac
;;
"")
if [[ $mode != -d ]]; then
eval "$varnam=\"$add\""
fi
;;
*)
if [[ $mode != -d ]]; then
Doadd
fi
;;
esac
unfunction Usage Doadd
##cut
**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential
and/or privileged material.
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by
persons or entities other than the intended recipient is
prohibited.
If you received this in error, please contact the sender and
delete the material from any computer.
**********************************************************************
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: passing arrays
2003-01-20 14:23 ` Le Wang
2003-01-20 14:34 ` Peter Stephenson
@ 2003-01-20 14:34 ` Le Wang
1 sibling, 0 replies; 10+ messages in thread
From: Le Wang @ 2003-01-20 14:34 UTC (permalink / raw)
To: Zsh users list
--- Borzenkov Andrey <Andrey.Borzenkov@siemens.com>
wrote: >
> > Here is an extension of the problem. Say I have a
> > bunch of functions that operate on $PATH, how
> would I
> > generalize it so that it works with any $PATH like
> > variable?
> >
>
> Hmm ... have you noticed that every your question
> needs at least one reply
> that requests clarification what you really mean? No
> offence intended :)
None taken. I will strive to refine my problem
descriptions.
My problem is as follows:
I currently have:
addToPath () {...}
and I use it as:
addToPath ~/bin/scripts
I would like to have
addToPathVar () {...}
and use it as:
addToPathVar CLASSPATH ~/java/lib
--
Le
______________________________________________________________________
Post your free ad now! http://personals.yahoo.ca
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: more interactive menu completion
2003-01-20 12:17 ` Borzenkov Andrey
2003-01-20 14:23 ` Le Wang
@ 2003-01-20 14:51 ` Sven Wischnowsky
2003-01-20 15:13 ` Borzenkov Andrey
2003-01-21 1:58 ` Le Wang
1 sibling, 2 replies; 10+ messages in thread
From: Sven Wischnowsky @ 2003-01-20 14:51 UTC (permalink / raw)
To: zsh-users
Borzenkov Andrey wrote:
> >
> > I'm using menu completion now, and I absolutely love
> > it. However I was just thinking that all of my
> > keyboard keys are unmapped during menu completion, so
> > wouldn't it be nice if I could press 'abc', and have
> > the selection go to the first file starting with an
> > 'abc'? This is very much like the way modern file
> > managers work (e.g. Explorer, Konqueror, etc), except
> > they only match the first letter.
> >
> > It would be great if this kind of widget can be
> > refined to do substring matching as well. Does this
> > kind of completion scheme currently exist for Zsh?
> >
>
> There is incremental-complete-word widget that does what you want. I do not
> know if it is widely used, so your comments would be welcome.
In the development version, there is also incremental mode of menu
selection, see the docs for the `complist' module and for the new
completion system (under the `menu' style).
Bye
Sven
--
Sven Wischnowsky wischnow@berkom.de
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: more interactive menu completion
2003-01-20 14:51 ` more interactive menu completion Sven Wischnowsky
@ 2003-01-20 15:13 ` Borzenkov Andrey
2003-01-20 16:06 ` Peter Stephenson
2003-01-21 1:58 ` Le Wang
1 sibling, 1 reply; 10+ messages in thread
From: Borzenkov Andrey @ 2003-01-20 15:13 UTC (permalink / raw)
To: zsh-users
> In the development version, there is also incremental mode of menu
> selection, see the docs for the `complist' module and for the new
> completion system (under the `menu' style).
>
Wow! It really works! May wonders never cease ...
For others, it refers to (quoting complist documentation):
viinsert
this toggles between normal and interactive mode; in interactive
mode the keys bound to self-insert and self-insert-unmeta insert
into the command line as in normal editing mode but without leaving
menu selection; after each character completion is tried again and
the list changes to contain only the new matches; the completion
widgets make the longest unambiguous string be inserted in the
command line and undo and backward-delete-char go back to the
previous set of matches
-andrey
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: more interactive menu completion
2003-01-20 15:13 ` Borzenkov Andrey
@ 2003-01-20 16:06 ` Peter Stephenson
0 siblings, 0 replies; 10+ messages in thread
From: Peter Stephenson @ 2003-01-20 16:06 UTC (permalink / raw)
To: zsh-users
Borzenkov Andrey wrote:
> For others, it refers to (quoting complist documentation):
>
> viinsert
except it's actually `vi-insert'.
Index: Doc/Zsh/mod_complist.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/mod_complist.yo,v
retrieving revision 1.16
diff -u -r1.16 mod_complist.yo
--- Doc/Zsh/mod_complist.yo 26 Jun 2002 11:07:46 -0000 1.16
+++ Doc/Zsh/mod_complist.yo 20 Jan 2003 16:05:40 -0000
@@ -332,7 +332,7 @@
item(tt(reverse-menu-complete))(
moves the mark to the previous match
)
-item(tt(viinsert))(
+item(tt(vi-insert))(
this toggles between normal and interactive mode; in interactive mode
the keys bound to tt(self-insert) and tt(self-insert-unmeta) insert
into the command line as in normal editing mode but without leaving
--
Peter Stephenson <pws@csr.com> Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK Tel: +44 (0)1223 692070
**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential
and/or privileged material.
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by
persons or entities other than the intended recipient is
prohibited.
If you received this in error, please contact the sender and
delete the material from any computer.
**********************************************************************
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: more interactive menu completion
2003-01-20 14:51 ` more interactive menu completion Sven Wischnowsky
2003-01-20 15:13 ` Borzenkov Andrey
@ 2003-01-21 1:58 ` Le Wang
2003-01-21 6:17 ` Borzenkov Andrey
1 sibling, 1 reply; 10+ messages in thread
From: Le Wang @ 2003-01-21 1:58 UTC (permalink / raw)
To: Zsh users list
--- Sven Wischnowsky <wischnow@berkom.de> wrote:
>
> Borzenkov Andrey wrote:
>
> > >
> > > I'm using menu completion now, and I absolutely
> love
> > > it. However I was just thinking that all of my
> > > keyboard keys are unmapped during menu
> completion, so
> > > wouldn't it be nice if I could press 'abc', and
> have
> > > the selection go to the first file starting with
> an
> > > 'abc'? This is very much like the way modern
> file
> > > managers work (e.g. Explorer, Konqueror, etc),
> except
> > > they only match the first letter.
> > >
> > > It would be great if this kind of widget can be
> > > refined to do substring matching as well. Does
> this
> > > kind of completion scheme currently exist for
> Zsh?
> > >
> >
> > There is incremental-complete-word widget that
> does what you want. I do not
> > know if it is widely used, so your comments would
> be welcome.
>
> In the development version, there is also
> incremental mode of menu
> selection, see the docs for the `complist' module
> and for the new
> completion system (under the `menu' style).
That is very nice. The functionality is exactly what
I had in mind. Once again, I'm very impressed with
Zsh! :)
One note about the user interface of this
"interactive" menu completion mode: Why have a
'vi-insert' key binding at all? I don't see any
reason for it. IMHO "interactive" mode should be able
to be toggled on or off permanently (maybe throuth
styles).
cheers.
--
Le
______________________________________________________________________
Post your free ad now! http://personals.yahoo.ca
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: more interactive menu completion
2003-01-21 1:58 ` Le Wang
@ 2003-01-21 6:17 ` Borzenkov Andrey
0 siblings, 0 replies; 10+ messages in thread
From: Borzenkov Andrey @ 2003-01-21 6:17 UTC (permalink / raw)
To: 'Le Wang', 'Zsh users list'
> >
> > In the development version, there is also
> > incremental mode of menu
> > selection, see the docs for the `complist' module
> > and for the new
> > completion system (under the `menu' style).
^^^^^^^^^^^^^^^^^^^^^^
>
>
> That is very nice. The functionality is exactly what
> I had in mind. Once again, I'm very impressed with
> Zsh! :)
>
> One note about the user interface of this
> "interactive" menu completion mode: Why have a
> 'vi-insert' key binding at all? I don't see any
> reason for it. IMHO "interactive" mode should be able
> to be toggled on or off permanently (maybe throuth
> styles).
>
You have not read carefully enough :)
menu
.....
Finally, the two special modes of menu selection, namely
interactive mode and incremental search can be pre-selected with
this style. By including the word `interactive' in the value,
interactive mode will be entered immediately when menu selection
is started and the string `search' does the same for incremental
search. To select backward incremental search, include the string
`search-backward'.
It is not default because it is still experimental, it is slow (yes, it _is_
slow) and it is very different from usual way. I personally found that
hitting three times cursor key needs the same time as typing in three
characters of next match :))
-andrey
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2003-01-21 6:18 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-19 23:34 more interactive menu completion Le Wang
2003-01-20 12:17 ` Borzenkov Andrey
2003-01-20 14:23 ` Le Wang
2003-01-20 14:34 ` Peter Stephenson
2003-01-20 14:34 ` passing arrays Le Wang
2003-01-20 14:51 ` more interactive menu completion Sven Wischnowsky
2003-01-20 15:13 ` Borzenkov Andrey
2003-01-20 16:06 ` Peter Stephenson
2003-01-21 1:58 ` Le Wang
2003-01-21 6:17 ` Borzenkov Andrey
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).