From: Bart Schaefer <schaefer@brasslantern.com>
To: Domagoj Pintaric <domagoj.pintaric@gmail.com>
Cc: zsh-workers@zsh.org
Subject: Re: Custom auto complete
Date: Tue, 05 Aug 2014 20:45:33 -0700 [thread overview]
Message-ID: <140805204533.ZM28316@torch.brasslantern.com> (raw)
In-Reply-To: <CALGc2Bpr1Hv4KNbUiN8F==pE-pS7d8QU4oinju-4_wOH-KW8dA@mail.gmail.com>
On Aug 6, 12:37am, Domagoj Pintaric wrote:
}
} The solution you posted sort of dose what I want. With this code I have to
} type ?<some char(s)> in order for it to work. If I just type ? and hit tab
} it dose not work.
Hm. I did test it. Could you post the actual function?
} I get that's because of ( \?* ) and I tried (\?) but it dose not work.
} Interesting, if I use for example ( \! ) that works as expected. Is the '?'
} special for some reason?
Depends on the order of your completer style. I only tried with _query
as the first one. If e.g. you have _expand in there ahead of _query,
_expand will try to use the "?" on the command line as a glob pattern.
You haven't really told us enough details to make a diagnosis. On the
other hand you seem to prefer the custom key binding, so maybe it does
not matter.
} zle -C custom-complete menu-expand-or-complete _parse_sb_file
Why did you chose menu-expand-or-complete here, rather than just
menu-complete? When would you be using this binding for expansion?
See also below ...
} _parse_sb_file () {
} WORDS=(${(f)"$(<$SB_FILE_PATH)"})
} ARRAY=()
} integer POS=1
} for ITEM in ${WORDS}
} do
} ARRAY[${POS}]=${POS}") "${WORDS[${POS}]}
} (( POS++ ))
} done
} compadd -l -d ARRAY -a -S '' -- WORDS
} }
}
} bindkey ${CTRLTAB_KEY} custom-complete
}
} This works but I have some issues with this to:
}
} 1) if I press ctrl-tab I can not select the options with arrow keys I can
} just switch them with ctrl-tab, unless I first run for example "cp <TAB>"
This is very likely because you haven't yet loaded the zsh/complist module
the first time you try this, or you've loaded it but not set $MENUSELECT.
When you invoke the completion system with <TAB> it loads the module and
sets the variable for you, and thereafter menu completion notices that
$MENUSELECT has become set and enters the selection list.
If you load the module yourself, you can bind to the menu-select widget
and force entry into the selection list every time:
zmodload zsh/complist
zle -C custom-complete menu-select _parse_sb_file
} 2) if I have this string, for example, in a file "cp file1 file2" it is
} inserted like this "cp\ file1\ file2". The white spaces are escaped, how
} can I disable this, and tell zsh to insert a string as it is.
You need the -Q option when calling "compadd". However, note that when
deciding to re-enter completion, the command line is going to be split
on spaces, even if those spaces were inserted by a previous completion.
prev parent reply other threads:[~2014-08-06 3:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-03 16:17 Domagoj Pintaric
2014-08-04 20:39 ` Bart Schaefer
2014-08-04 20:57 ` Bart Schaefer
2014-08-05 22:37 ` Domagoj Pintaric
2014-08-06 3:45 ` Bart Schaefer [this message]
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=140805204533.ZM28316@torch.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=domagoj.pintaric@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).