zsh-workers
 help / color / mirror / code / Atom feed
* compadd -qS' ' should escape the space
@ 2007-05-03 16:11 Nikolai Weibull
  2007-05-07  5:44 ` Bart Schaefer
  2007-05-09 20:09 ` Nikolai Weibull
  0 siblings, 2 replies; 4+ messages in thread
From: Nikolai Weibull @ 2007-05-03 16:11 UTC (permalink / raw)
  To: Zsh hackers list

The following code will only do the right thing if I have started the
current word with a ":

  declare -a colors

  colors=(black red green yellow blue magenta cyan white)

  _describe -t color 'color' colors -qS' '

I'd expect the space used as a suffix to be escaped.

Thanks.

  nikolai


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: compadd -qS' ' should escape the space
  2007-05-03 16:11 compadd -qS' ' should escape the space Nikolai Weibull
@ 2007-05-07  5:44 ` Bart Schaefer
  2007-05-07  7:50   ` Nikolai Weibull
  2007-05-09 20:09 ` Nikolai Weibull
  1 sibling, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2007-05-07  5:44 UTC (permalink / raw)
  To: Zsh hackers list

I'm sort of surprised no one responded to this.  (Or did they and gmail
has spam-filtered it for me again?)

On May 3,  6:11pm, Nikolai Weibull wrote:
} Subject: compadd -qS' ' should escape the space
}
}   _describe -t color 'color' colors -qS' '
} 
} I'd expect the space used as a suffix to be escaped.

Er, no.  The suffix is supposed to be a separator between words; e.g.,
in file completion, you want the space between the file names to be
treated as IFS by the shell, so that you get one file name per word
as the command arguments.

You didn't provide enough context to know what you're really trying
to do and why you think the space should be escaped, so I have no
suggestions for what you should be doing instead.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: compadd -qS' ' should escape the space
  2007-05-07  5:44 ` Bart Schaefer
@ 2007-05-07  7:50   ` Nikolai Weibull
  0 siblings, 0 replies; 4+ messages in thread
From: Nikolai Weibull @ 2007-05-07  7:50 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Zsh hackers list

On 5/7/07, Bart Schaefer <schaefer@brasslantern.com> wrote:
> I'm sort of surprised no one responded to this.  (Or did they and gmail
> has spam-filtered it for me again?)

Nah, it's probably the fact that my question/suggestion wasn't very
well-formulated.

> On May 3,  6:11pm, Nikolai Weibull wrote:
> } Subject: compadd -qS' ' should escape the space
> }
> }   _describe -t color 'color' colors -qS' '
> }
> } I'd expect the space used as a suffix to be escaped.
>
> Er, no.  The suffix is supposed to be a separator between words; e.g.,
> in file completion, you want the space between the file names to be
> treated as IFS by the shell, so that you get one file name per word
> as the command arguments.
>
> You didn't provide enough context to know what you're really trying
> to do and why you think the space should be escaped, so I have no
> suggestions for what you should be doing instead.

I'm trying to complete a set of three colors and attributes:

      compset -P '* '

      case ($words[CURRENT]) in
        (?*' '?*' '*)
          if [[ $words[CURRENT] == *(bold|dim|ul|blink|reverse)* ]]; then
            __git_colors
          else
            __git_color_attributes
          fi
          ;;
        (*)
          if [[ $words[CURRENT] == *(bold|dim|ul|blink|reverse)* ]]; then
            __git_colors -qS' '
          else
            _alternative \
              'colors:color:__git_colors -qS" "' \
              'attributes:attribute:__git_color_attributes -qS" "'
          fi
          ;;

The idea is that when completing in the following context:

% git config color.branch.local |

(where '|' is the cursor) you'll be able to enter three space-separated values:

% git config color.branch.local red\ |

and now we'll still be able to complete the two other components.  If
I manually prefix the word before completing with a double quote it
all works, but I was hoping that this could also work automatically.

Feel free to ask for more context ;-).

  nikolai


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: compadd -qS' ' should escape the space
  2007-05-03 16:11 compadd -qS' ' should escape the space Nikolai Weibull
  2007-05-07  5:44 ` Bart Schaefer
@ 2007-05-09 20:09 ` Nikolai Weibull
  1 sibling, 0 replies; 4+ messages in thread
From: Nikolai Weibull @ 2007-05-09 20:09 UTC (permalink / raw)
  To: Zsh hackers list

On 5/3/07, Nikolai Weibull <now@bitwi.se> wrote:
> The following code will only do the right thing if I have started the
> current word with a ":
>
>   declare -a colors
>
>   colors=(black red green yellow blue magenta cyan white)
>
>   _describe -t color 'color' colors -qS' '
>
> I'd expect the space used as a suffix to be escaped.

I'm stupid.  I can simply escape the space myself.

  nikolai


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-05-09 20:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-03 16:11 compadd -qS' ' should escape the space Nikolai Weibull
2007-05-07  5:44 ` Bart Schaefer
2007-05-07  7:50   ` Nikolai Weibull
2007-05-09 20:09 ` Nikolai Weibull

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).