Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: tab inserts literal tab instead of completing at beginning of line
- X-seq: zsh-workers 29332
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: tab inserts literal tab instead of completing at beginning of line
- Date: Fri, 20 May 2011 23:55:29 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=IwBaYNoPDfBmP1uEkEYZO8HCgWwpCLTAYqsPgUnHAFE=; b=CTurq5VAHgLG9gJH2LD86rFHStcqoCRmDgErbnxaeyCTOuCAJpbvN7prcdsx9u7iDf 7TQ7xbsO+LMsu1/rKFpx3lA8lt7UzWzA5SkJ9DOfa/uf8Ns2HrRuvJwpEW4rIaC5tw1Y 3lavPGJAExmYhKyNprJkGtXoU5SY+6tp3mT2g=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=v5/VTLTA62x93pot8DTntm+sNVebpwvF8BzHaeQ95GxL4jRsTxC/OxMwN/5JsJTXXH FXQ6/0B74pjtL+y05JKqi1s3b28+o9XFfHP26ZhsYGw7r5f3znrHEV2ngGGyKbErXCHw VmW45r41NNVMVTt4avtW7HPYr0mByDHhV3flM=
- In-reply-to: <BANLkTi=DiNg5NwhXXqnvvkBCiaSnLySetg@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <BANLkTimMcVWMzXnyJbFfuY2iDcOW2gJtug@mail.gmail.com> <BANLkTin2p-bfoubfa1Cc_Ak-7T+0sPtx4Q@mail.gmail.com> <BANLkTinqgZQqYbJ-=cjtYzhyYGbix+gyDQ@mail.gmail.com> <BANLkTinVGkTPvSPUJLbtNEyWgmmZv+73+w@mail.gmail.com> <BANLkTi=DiNg5NwhXXqnvvkBCiaSnLySetg@mail.gmail.com>
On 19 May 2011 18:00, Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> On 19 May 2011 17:19, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>> On Thu, May 19, 2011 at 2:36 AM, Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
>>>
>>> Well, in my case there's no more input, just me pressing tab. How's
>>> this? (it works)
>>
>> Sorry, I'm not sure what this does. Add an "empty" value to the
>> insert-tab style? If so then that's OK, I think.
>
> Ah, I was in my own little world there, I see more context is needed
> :). What it does is what I described last in my first message: insert
> a tab if the line is empty, or contains only tabs (presumably you want
> to paste more than one sometimes), otherwise completion as usual.
tl;dr nm this whole thing
Hmmm, so I'm confused again. It turns out my patch didn't work as well
as I hoped. When I press ctrl-n or alt-m, it just inserts those
literally as well. I tried comparing _complete_debug output for
insert-tab=false and =true, but they were the same. I could do this,
but...
( "$KEYS" = $'\t' && "$tmp" = empty && ${#${BUFFER##$'\t'#}} -eq 0 )
So I just erased a big paragraph here explaining how I'm confused
since _complete_debug output is identical with insert-tab set to true
and false. It took a few minutes for me to realize this meant this is
handled in the C code. I got to this line, and decided to give up this
project for now.
uselist = (useline ? ((isset(AUTOLIST) && !isset(BASHAUTOLIST)) ?
(isset(LISTAMBIGUOUS) ? 3 : 2) : 0) : 1);
useline is set by this earlier line
useline = (wouldinstab ? -1 : (lst != COMP_LIST_COMPLETE));
and wouldinstab is decided by this function, some time way before this
static int
usetab(void)
{
ZLE_STRING_T s = zleline + zlecs - 1;
if (keybuf[0] != '\t' || keybuf[1])
return 0;
for (; s >= zleline && *s != ZWC('\n'); s--)
if (*s != ZWC('\t') && *s != ZWC(' '))
return 0;
if (compfunc) {
wouldinstab = 1;
return 0;
}
return 1;
}
So I would have to somehow modify all the steps leading from
wouldinstab to useline/list/something to pass yet another value and
then compare this to my 'empty' value which I tracked down is called
'compinsert' in the C code. Since the code is already a mess of state
tracked by un-named magic integer values, I decided not to make
matters worse. Also to retain my sanity.
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author