From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@math.gatech.edu
Subject: Re: experimental new style completion
Date: Thu, 21 Jan 1999 11:36:34 +0100 (MET) [thread overview]
Message-ID: <199901211036.LAA18556@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: "Bart Schaefer"'s message of Wed, 6 Jan 1999 23:36:32 -0800
Bart Schaefer wrote:
> May I suggest that there's no reason to abbreviate names of this sort.
>
> `command' (not `cmd') we are completing in command position
> `argument' (not `arg') we are completing in argument position
> `redirect' (not `redir') ... after a redirection operator
> `math' ... in a math environment
> `subscript' (not `subscr') ... in a subscript
> `value' ... in the value of an variable assignment
> `condition' ... inside `[[...]]'
>
The patch below does this.
> Also ... I may be mistaken, but isn't it possible to be in both the command
> position and after a redirection operator (e.g. readnullcmd) or in both a
> math context and inside a subscript? Is a single context identifier enough?
This is not changed by the patch. The intended usage is to call a
provided shell function or alias that generates the matches for
`included' context types (see the use of `compalso' in the example
file). Anyway after thinking more about this I see a real use for this
only with `math' and `subscript' and probaly using the `math' stuff in
some cases in conditions. `command' and `redirection' are mutually
exclusive as far as I can see.
Bye
Sven
*** Src/Zle/zle_tricky.c.old Thu Jan 21 10:47:03 1999
--- Src/Zle/zle_tricky.c Thu Jan 21 11:03:02 1999
***************
*** 3241,3249 ****
zsfree(compcommand);
compcommand = "";
if (lincmd)
! compcontext = (insubscr ? "subscr" : "cmd");
else if (linredir)
! compcontext = "redir";
else
switch (inwhat) {
case IN_ENV:
--- 3241,3249 ----
zsfree(compcommand);
compcommand = "";
if (lincmd)
! compcontext = (insubscr ? "subscript" : "command");
else if (linredir)
! compcontext = "redirect";
else
switch (inwhat) {
case IN_ENV:
***************
*** 3253,3270 ****
break;
case IN_MATH:
if (insubscr) {
! compcontext = "subscr";
compcommand = varname ? varname : "";
} else
compcontext = "math";
usea = 0;
break;
case IN_COND:
! compcontext = "cond";
break;
default:
if (cmdstr) {
! compcontext = "arg";
compcommand = cmdstr;
} else {
compcontext = "value";
--- 3253,3270 ----
break;
case IN_MATH:
if (insubscr) {
! compcontext = "subscript";
compcommand = varname ? varname : "";
} else
compcontext = "math";
usea = 0;
break;
case IN_COND:
! compcontext = "condition";
break;
default:
if (cmdstr) {
! compcontext = "argument";
compcommand = cmdstr;
} else {
compcontext = "value";
*** Src/example.old Thu Jan 21 10:47:18 1999
--- Src/example Thu Jan 21 11:25:50 1999
***************
*** 42,47 ****
--- 42,53 ----
alias compsub='do-complete "$@" || return 1'
+ # This searches $1 in the array for normal completions and calls the result.
+
+ compalso() {
+ 1="$comps[$1]"
+ [[ -z "$1" ]] || call-complete "$@"
+ }
# This generates matches. The first argument is something we got from one
# of the associative arrays above. This is expected to be either the name
***************
*** 81,87 ****
# For arguments we use the `do-complete' function below called via the
# convenience alias `compsub'.
! if [[ $CONTEXT == arg || $CONTEXT == cmd ]] then
compsub
else
# Let's see if we have a special completion definition for the other
--- 87,93 ----
# For arguments we use the `do-complete' function below called via the
# convenience alias `compsub'.
! if [[ $CONTEXT == argument || $CONTEXT == command ]] then
compsub
else
# Let's see if we have a special completion definition for the other
***************
*** 90,100 ****
comp=''
case $CONTEXT in
! redir) comp="$comps[--redir--]";;
math) comp="$comps[--math--]";;
! subscr) comp="$comps[--subscr--]";;
value) comp="$comps[--value--]";;
! cond) comp="$comps[--cond--]";;
esac
# If not, we use default completion, if any.
--- 96,106 ----
comp=''
case $CONTEXT in
! redirect) comp="$comps[--redir--]";;
math) comp="$comps[--math--]";;
! subscript) comp="$comps[--subscr--]";;
value) comp="$comps[--value--]";;
! condition) comp="$comps[--cond--]";;
esac
# If not, we use default completion, if any.
***************
*** 114,120 ****
# two strings we have search in the completion definition arrays (e.g.
# a path and the last path name component).
! if [[ $CONTEXT == cmd ]] then
comp="$comps[--command--]"
[[ -z "$comp" ]] || call-complete "$comp" "$@" || return 1
return 0
--- 120,126 ----
# two strings we have search in the completion definition arrays (e.g.
# a path and the last path name component).
! if [[ $CONTEXT == command ]] then
comp="$comps[--command--]"
[[ -z "$comp" ]] || call-complete "$comp" "$@" || return 1
return 0
***************
*** 162,170 ****
shift
(( CURRENT-- ))
if [[ CURRENT -eq 0 ]] then
! CONTEXT=cmd
else
! CONTEXT=arg
fi
compsub
}
--- 168,176 ----
shift
(( CURRENT-- ))
if [[ CURRENT -eq 0 ]] then
! CONTEXT=command
else
! CONTEXT=argument
fi
compsub
}
***************
*** 178,185 ****
__command=( -c )
defcomp --math-- __math
- defcomp --subscr-- __math
__math=( -v )
# A simple pattern completion, just as an example.
--- 184,196 ----
__command=( -c )
defcomp --math-- __math
__math=( -v )
+
+ defcomp --subscr-- __subscr
+ __subscr() {
+ compalso --math-- "$@"
+ # ...probably other stuff
+ }
# A simple pattern completion, just as an example.
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
next reply other threads:[~1999-01-21 10:45 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-01-21 10:36 Sven Wischnowsky [this message]
-- strict thread matches above, loose matches on Subject: below --
1999-01-22 16:30 Sven Wischnowsky
1999-01-22 14:50 Sven Wischnowsky
1999-01-22 16:18 ` Phil Pennock
1999-01-22 17:09 ` Bart Schaefer
1999-01-22 13:15 Sven Wischnowsky
1999-01-21 16:07 Sven Wischnowsky
1999-01-21 12:02 Sven Wischnowsky
1999-01-21 10:53 Sven Wischnowsky
1999-01-07 8:02 Sven Wischnowsky
1999-01-05 15:43 Sven Wischnowsky
1999-01-07 7:36 ` Bart Schaefer
1998-12-18 15:59 Sven Wischnowsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199901211036.LAA18556@beta.informatik.hu-berlin.de \
--to=wischnow@informatik.hu-berlin.de \
--cc=zsh-workers@math.gatech.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).