zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <opk@u.genie.co.uk>
To: Zsh workers <zsh-workers@sunsite.auc.dk>
Subject: Re: help with _match, globcomplete etc. (with a PATCH)
Date: Tue, 15 Feb 2000 19:53:50 +0000	[thread overview]
Message-ID: <38A9AECE.5B213E7@u.genie.co.uk> (raw)
In-Reply-To: <200002151608.RAA14415@beta.informatik.hu-berlin.de>

Sven Wischnowsky wrote:

> I couldn't reproduce your `[' problem, unless that was a typo and you
> meant a quoted `{'. In this case it's the same as for the quoted
> globbing characters.

It wasn't a typo. It only occurs when the referenced associative array is set. I can reproduce it as follows:
zsh -f
bindkey -me
unsetopt glob
typeset -A code
code[ai]=foo
echo $code[ai]/{a,<tab>

and, in a separate message: 
> You can bind expand-word to ^X$. Expansion of parameter substitutions
> is a problem, because the completion (shell) code doesn't get the
> whole string. We only get the stuff after the $, so we can't really
> change such things.

I don't quite understand what you mean here. _expand seems to get the whole thing including the '$'. The main limiting factor on my configuration is that I can't do parameter expansion, command substitution and arithmetic expansion independantly. Maybe the e parameter expansion flag could allow options to select them. Also, I can't see a way of doing globbing, while preserving variable references.

In general, I don't like the substitution in _expand but the trouble with not having it enabled is that glob expansion will not work on lines with parameters. My solution is the following patch to _expand which adds the style subst-globs-only which if used with substitute and glob, only does expansion if globbing was able to do something meaningful. If you (Sven) are happy with this addition, I'll do a doc patch aswell.

and elsewhere:
> > Another thing which I would like to configure with expansion is when
> > there is only one match, I'd prefer if the space suffix was not added -
> > this is one of the things that makes the variable expansion annoying.
> > Ideally, the suffix would be as if normal completion was used so
> > directories would get a '/'.
> When speaking about variables: see above. When speaking about other
> expansions: _match does that and _expand could be made to do it
> (adding a loop that appends slashes to directory names).

It is only really when the globbing results in only one match that I am concerned about the suffix because my cursor is at the end of that match and I'm likely to go on adding more to it and doing more completion. I'll add a patch for this. Should I make it depend on a zstyle thing? Will it be needed for both of the compadds in _expand?

Out of interest, why does the check in _expand need to check against "$word"(|\(N\)) as opposed to just "$word": under what circumstances can the (N) find its way into $exp?

Thanks for your help

Oliver

--- Completion/Core/_expand.bak Tue Feb 15 19:25:20 2000
+++ Completion/Core/_expand     Tue Feb 15 19:26:24 2000
@@ -7,7 +7,7 @@
 # the expansions done produce no result or do not change the original
 # word from the line.
 
-local exp word="$PREFIX$SUFFIX" sort expr expl
+local exp word="$PREFIX$SUFFIX" sort expr expl subd
 local curcontext="${curcontext/:[^:]#:/:expand:}"
 
 # First, see if we should insert all *completions*.
@@ -34,17 +34,25 @@
 
 [[ -z "$exp" ]] && exp=("$word")
 
+subd="$exp"
+
 # Now try globbing.
 
 zstyle -s ":completion:${curcontext}:" glob expr &&
     [[ "${(e):-\$[$expr]}" -eq 1 ]] &&
     exp=( ${~exp}(N) )
-
+ 
 # If we don't have any expansions or only one and that is the same
 # as the original string, we let other completers run.
 
 [[ $#exp -eq 0 ||
    ( $#exp -eq 1 && "$exp[1]" = "$word"(|\(N\)) ) ]] && return 1
+
+# With subst-globs-only we bail out if there were no glob expansions,
+# regardless of any substitutions
+zstyle -s ":completion:${curcontext}:" subst-globs-only expr &&
+    [[ "${(e):-\$[$expr]}" -eq 1 ]] &&
+    [[ "$subd" = "$exp"(|\(N\)) ]] && return 1
 
 # Now add as matches whatever the user requested.


  reply	other threads:[~2000-02-15 19:53 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-02-15 16:08 help with _match, globcomplete etc Sven Wischnowsky
2000-02-15 19:53 ` Oliver Kiddle [this message]
2000-02-16  6:47   ` help with _match, globcomplete etc. (with a PATCH) Bart Schaefer
2000-02-16 10:38     ` Oliver Kiddle
2000-02-16 11:52       ` Bart Schaefer
2000-02-16 10:11 Sven Wischnowsky
2000-02-16 10:57 ` Bart Schaefer
2000-02-16 11:18 ` Oliver Kiddle
2000-02-16 15:39 Sven Wischnowsky
2000-02-17 14:43 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=38A9AECE.5B213E7@u.genie.co.uk \
    --to=opk@u.genie.co.uk \
    --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).