From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: expansion
Date: Tue, 13 Jun 2000 13:24:33 +0200 (MET DST) [thread overview]
Message-ID: <200006131124.NAA31140@beta.informatik.hu-berlin.de> (raw)
[ sunsite.auc.dk seems to be down, at least I don't get my mails
back... I'll just keep on sending patches ;-]
We were discussing these... This adds the style `suffix' and makes
`accept-exact' be used by _expand:
- With `suffix', expansion is not done if there is anything after a
`~foo' or `$foo'. I.e. it will not expand `~foo/<TAB>', but it will
expand `~foo'.
- With `accept-exact' set it will expand `$MAIL', with it unset, it
will not expand it (if there are other parameters starting with
`MAIL').
We were using rexexact in the old expansion code, so I thought we
should just use `accept-exact' which is the style equivalent of
recexact.
Note that I've used the same default value in _expand as it has
elsewhere (`false'), which means that without further configuring,
this now behaves differently. Should we make it default to `true' in
_expand?
Ok. Is this good enough? Oliver?
Bye
Sven
Index: Completion/Core/_expand
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_expand,v
retrieving revision 1.15
diff -u -r1.15 _expand
--- Completion/Core/_expand 2000/06/08 08:39:51 1.15
+++ Completion/Core/_expand 2000/06/13 11:22:46
@@ -18,12 +18,6 @@
force="$force$opt"
done
-if [[ "$funcstack[2]" = _prefix ]]; then
- word="$IPREFIX$PREFIX$SUFFIX"
-else
- word="$IPREFIX$PREFIX$SUFFIX$ISUFFIX"
-fi
-
# First, see if we should insert all *completions*.
if [[ "$force" = *c* ]] ||
@@ -33,8 +27,25 @@
[[ "$curcontext" = expand-word:* ]] && _complete && return 0
return 1
fi
+
+if [[ "$funcstack[2]" = _prefix ]]; then
+ word="$IPREFIX$PREFIX$SUFFIX"
+else
+ word="$IPREFIX$PREFIX$SUFFIX$ISUFFIX"
+fi
+
+zstyle -t ":completion:${curcontext}:" suffix &&
+ [[ "$word" = (\~*/*|\$[a-zA-Z0-9_]##[^a-zA-Z0-9_]*|\$\{*\}?*) ]] &&
+ return 1
+
+zstyle -t ":completion:${curcontext}:" accept-exact ||
+ { [[ "$word" = \~(|[-+]) ||
+ ( "$word" = \~[-+][1-9]## && $word[3,-1] -le $#dirstack ) ||
+ ( "$word" = \~* && ${#userdirs[(I)${word[2,-1]}*]}+${#nameddirs[(I)${word[2,-1]}*]} -ne 1 ) ||
+ ( "$word" = \$[a-zA-Z0-9_]## &&
+ ${#parameters[(I)${word[2,-1]}*]} -ne 1 ) ]] && return 1 }
-# In exp we will collect the expansion.
+# In exp we will collect the expansions.
exp=("$word")
Index: Doc/Zsh/compsys.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compsys.yo,v
retrieving revision 1.60
diff -u -r1.60 compsys.yo
--- Doc/Zsh/compsys.yo 2000/06/08 08:39:51 1.60
+++ Doc/Zsh/compsys.yo 2000/06/13 11:22:48
@@ -779,6 +779,12 @@
matches. If it is set to `true' for at least one match which is the
same as the string on the line, this match will immediately be
accepted.
+
+Note that this is also used by the tt(_expand) completer to decide if
+words beginning with a tilde or parameter expansion should be
+expanded. This means that if, for example, there are parameters
+tt(foo) and tt(foobar), the string `tt($foo)' will only be expanded if
+tt(accept-exact) is set to `true'.
)
kindex(add-space, completion style)
item(tt(add-space))(
@@ -1785,6 +1791,14 @@
substitution will be performed only if given an explicit numeric
argument other than `tt(1)', as by typing `tt(ESC 2 TAB)'.
+)
+kindex(suffix, completion style)
+item(tt(suffix))(
+This is used by the tt(_expand) completer if the word starts with a
+tilde or parameter expansion. If it is set to `true', the word will
+only be expanded if it doesn't have a suffix, i.e. if it is something
+like `tt(~foo)' or `tt($foo)', but not if it is `tt(~foo/)' or
+`tt($foo/bar)'. The default for this style is `false'.
)
kindex(tag-order, completion style)
item(tt(tag-order))(
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
next reply other threads:[~2000-06-13 12:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-06-13 11:24 Sven Wischnowsky [this message]
2000-06-13 16:41 ` Bart Schaefer
-- strict thread matches above, loose matches on Subject: below --
2000-06-14 6:21 Sven Wischnowsky
2000-06-09 7:32 Sven Wischnowsky
2000-06-09 10:45 ` Oliver Kiddle
[not found] <0FVU001OT0DZC6@la-la.cambridgesiliconradio.com>
2000-06-08 16:50 ` Oliver Kiddle
2000-06-07 6:46 PATCH: expansion (was: Re: PATCH: Re: blah*[TAB] (difference between 3.1.6 and 3.1.9)) Sven Wischnowsky
2000-06-07 22:21 ` PATCH: expansion Wayne Davison
2000-06-08 10:03 ` Oliver Kiddle
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=200006131124.NAA31140@beta.informatik.hu-berlin.de \
--to=wischnow@informatik.hu-berlin.de \
--cc=zsh-workers@sunsite.auc.dk \
/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).