Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: tab inserts literal tab instead of completing at beginning of line



On 19 May 2011 07:47, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Wed, May 18, 2011 at 3:37 PM, Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
>>
>> Yes, this actually happened to me. If I were to find where this
>> special tab-insert-at-start-of-line handling is, could I disable it,
>> or do I need to add an option?
>
> See the doc for the insert-tab zstyle.
>
>> There's always ctrl-v tab, and why do
>> you want to write literal tabs at the start of the line anyway; to
>> paste random indented scriptlets?
>
> Generally speaking, yes.
>
>> If that's why, maybe I can make the
>> thing check if the line is empty instead of $cursor==0?
>
> Or try the "pending" setting of the style.  If testing for pending
> input were more reliable, we might make that the default instead of
> "true".

Well, in my case there's no more input, just me pressing tab. How's
this? (it works)

--- a/Completion/Base/Core/_main_complete
+++ b/Completion/Base/Core/_main_complete
@@ -44,7 +44,8 @@

 if [[ ( "$tmp" = *pending(|[[:blank:]]*) && PENDING -gt 0 ) ||
       ( "$tmp" = *pending=(#b)([0-9]##)(|[[:blank:]]*) &&
-        PENDING -ge $match[1] ) ]]; then
+        PENDING -ge $match[1] ) ||
+      ( "$tmp" = empty && ${#${BUFFER##$'\t'#}} -eq 0 ) ]]; then
   compstate[insert]=tab

   return 0


-- 
Mikael Magnusson



Messages sorted by: Reverse Date, Date, Thread, Author