zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.dk
Subject: Re: expand style `suffix' option
Date: Fri, 5 Oct 2001 13:17:07 +0200	[thread overview]
Message-ID: <15293.38579.803273.864907@gargle.gargle.HOWL> (raw)
In-Reply-To: <22093.1002202403@csr.com>


Peter Stephenson wrote:

> ...
> 
> OK, I suppose the manual is saying it works if menu completion is started
> afterwards, but not if it's already in effect.
> 
> Since the `suffix' behaviour is selectable completely separately from
> anything else, I can't think of a good reason why the setting shouldn't
> simply be respected.  If you don't want it with menu completion you can
> simply not turn it on.

Right.  The patch below tries to make this style work again and it
also removes the dependency on not using menu completion (that part of 
the code is pretty hairy, so there might be things which now work
differently with menu-completion -- I'd like to hear about them so
that we can fix them).

> Tying settings together is really another problem entirely.  If we want
> some more general way of grouping --- set a whole load of styles all
> together - we can probably write a function suite that does it, e.g.
>   % zselect -v my_menu_styles
>   Turning on option `menuselect'
>   Changing style `expand' from `prefix suffix' to `prefix'
> However, it's not that trivial when you take contexts into account
> (compinstall has basically side-stepped this issue and while it handles
> contexts, you have to select them by hand).

Yes, I've been thinking about things like this, too, and haven't come
to a conclusion either.


The patch also tries to make the docs clearer on how the style has to
be set, because I haven't changed the code to look for sub-strings.


Bye
  Sven

Index: Completion/Unix/Type/_path_files
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_path_files,v
retrieving revision 1.11
diff -u -r1.11 _path_files
--- Completion/Unix/Type/_path_files	2001/08/17 09:25:22	1.11
+++ Completion/Unix/Type/_path_files	2001/10/05 11:11:15
@@ -332,6 +332,8 @@
 
     # Get the matching files by globbing.
 
+    tmp2=( "$tmp1[@]" )
+
     if [[ "$tpre$tsuf" = */* ]]; then
       compfiles -P$cfopt tmp1 accex "$skipped" "$_matcher" "$sdirs" fake
     elif [[ "$sopt" = *[/f]* ]]; then
@@ -344,7 +346,9 @@
     if [[ -n "$PREFIX$SUFFIX" ]]; then
       # See which of them match what's on the line.
 
-      if [[ "$tmp1[1]" = */* ]]; then
+      if (( ! $#tmp1 )); then
+        tmp2=( ${^tmp2}/$PREFIX$SUFFIX )
+      elif [[ "$tmp1[1]" = */* ]]; then
         if [[ -n "$_comp_correct" ]]; then
           tmp2=( "$tmp1[@]" )
           builtin compadd -D tmp1 -F _comp_ignore "$matcher[@]" - "${(@)tmp1:t}"
@@ -504,13 +508,16 @@
         PREFIX="$opre"
         SUFFIX="$osuf"
       fi
+
+      # This once tested `-n $menu ||' but our menu-completion expert says
+      # that's not what we want.
 
-      if [[ -n $menu || -z "$compstate[insert]" ]] ||
-         ! zstyle -t ":completion:${curcontext}:paths" expand suffix ||
+      if [[ -z "$compstate[insert]" ]] ||
+         { ! zstyle -t ":completion:${curcontext}:paths" expand suffix &&
            [[ -z "$listsfx" &&
               ( -n "$_comp_correct" ||
                 -z "$compstate[pattern_match]" || "$SUFFIX" != */* ||
-                "${SUFFIX#*/}" = (|*[^\\])[][*?#~^\|\<\>]* ) ]]; then
+                "${SUFFIX#*/}" = (|*[^\\])[][*?#~^\|\<\>]* ) ]] }; then
         (( tmp4 )) && zstyle -t ":completion:${curcontext}:paths" ambiguous &&
             compstate[to_end]=
         if [[ "$tmp3" = */* ]]; then
Index: Doc/Zsh/compsys.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compsys.yo,v
retrieving revision 1.134
diff -u -r1.134 compsys.yo
--- Doc/Zsh/compsys.yo	2001/08/15 13:50:03	1.134
+++ Doc/Zsh/compsys.yo	2001/10/05 11:11:16
@@ -1070,15 +1070,15 @@
 kindex(expand, completion style)
 item(tt(expand))(
 This style is used when completing strings consisting of multiple
-parts, such as path names.  If its
-value contains the string `tt(prefix)', the partially typed word from
+parts, such as path names.  If one of its values is
+the string `tt(prefix)', the partially typed word from
 the line will be expanded as far as possible even if trailing parts
-cannot be completed.  If it contains the string `tt(suffix)'
-and normal (non-menu-) completion is used, matching names for
+cannot be completed.  If one of its values is the string `tt(suffix)',
+matching names for
 components after the first ambiguous one will also be added.  This
 means that the resulting string is the longest unambiguous string
 possible, but if menu completion is started on the list of matches
-generated this way (e.g. due to the option tt(AUTO_MENU) being set),
+generated this way,
 this will also cycle through the names of the files in pathname
 components after the first ambiguous one.
 )

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


  reply	other threads:[~2001-10-05 11:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-02 11:41 Peter Stephenson
2001-10-02 14:52 ` Bart Schaefer
2001-10-04 13:10 ` Sven Wischnowsky
2001-10-04 13:33   ` Peter Stephenson
2001-10-05 11:17     ` Sven Wischnowsky [this message]
2001-10-05 16:10       ` PATCH: " Peter Stephenson
2001-10-08 12:33         ` Sven Wischnowsky
2001-10-09  9:48         ` Sven Wischnowsky
2001-10-09 10:35           ` Peter Stephenson

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=15293.38579.803273.864907@gargle.gargle.HOWL \
    --to=wischnow@informatik.hu-berlin.de \
    --cc=zsh-workers@sunsite.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).