zsh-workers
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: tab inserts literal tab instead of completing at beginning of line
Date: Fri, 20 May 2011 23:55:29 +0200	[thread overview]
Message-ID: <BANLkTimisOjcUKASf_uM3FTQ5supXGm7kg@mail.gmail.com> (raw)
In-Reply-To: <BANLkTi=DiNg5NwhXXqnvvkBCiaSnLySetg@mail.gmail.com>

On 19 May 2011 18:00, Mikael Magnusson <mikachu@gmail.com> wrote:
> On 19 May 2011 17:19, Bart Schaefer <schaefer@brasslantern.com> wrote:
>> On Thu, May 19, 2011 at 2:36 AM, Mikael Magnusson <mikachu@gmail.com> 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


  reply	other threads:[~2011-05-20 21:55 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-18 22:37 Mikael Magnusson
2011-05-19  5:47 ` Bart Schaefer
2011-05-19  9:36   ` Mikael Magnusson
2011-05-19 15:19     ` Bart Schaefer
2011-05-19 16:00       ` Mikael Magnusson
2011-05-20 21:55         ` Mikael Magnusson [this message]
2011-05-23  2:27           ` Bart Schaefer
2011-05-23  2:55             ` Mikael Magnusson
2011-05-23 16:57               ` Bart Schaefer
2011-05-23 17:11                 ` Mikael Magnusson
2011-05-24  2:55                   ` Bart Schaefer

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=BANLkTimisOjcUKASf_uM3FTQ5supXGm7kg@mail.gmail.com \
    --to=mikachu@gmail.com \
    --cc=zsh-workers@zsh.org \
    /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).