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

Re: _complete_help troubles



On Apr 11, 11:57pm, Adam Spiers wrote:
} Subject: _complete_help troubles
}
} > > $ ls <TAB>
} > > _complete_help:39: bad pattern: \n    all-files  (_files _default)

BTW, you do mean <C-x h> there, and not <TAB>, right?  If _complete_help
is running when you hit TAB, either you have rather surprising bindkeys,
or something very bad is happening.

} The relevant bit of trouble-making code is:
} 
}   for i in "${(@ok)help_funcs}"; do
}     text="${text}
} tags in context :completion:${i}:"
}     tmp=()
}     for j in "${(@s.:.)help_funcs[$i][2,-1]}"; do
}       tmp=( "$tmp[@]" "${(@s.,.)help_tags[${i}${j}][2,-1]}" )
}     done
}     zformat -a tmp '  (' "$tmp[@]"
}     tmp=( '
}     '${^tmp}')' )             <<<<<< this line gives the error
}     text="${text}${tmp}"
}   done
} 
} tmp has the value `all-files  (_files _default' when the error occurs,
} which doesn't look right.

No, that is in fact right.  The output should look something like

zagzig[99] ls <C-x h>
tags in context :completion::complete:ls::
    all-files  (_files _default)

and you'll note the ')' on the failing line.

However, look at this:

zagzig[99] setopt shwordsplit
zagzig[100] ls <C-x h>
tags in context :completion::complete:ls::
    all-files) 
    (_files) 
    _default)

I'm entirely certain that's NOT supposed to happen.  And then:

zagzig[109] setopt globsubst
zagzig[110] ls <C-x h>
_complete_help:39: bad pattern: \n    (_files)

So the problem is that _complete_help is expecting the standard options
from _main_complete, but of course it doesn't get them because it's not
called through the regular completion system.

Maybe we should put these (without localoptions, obviously) in another
function that can be called to install the standard completion options?

Except that rcexpandparam worries me just a tad ...

Index: Completion/Commands/_complete_help
===================================================================
@@ -1,6 +1,9 @@
 #compdef -k complete-word \C-xh
 
 _complete_help() {
+  setopt localoptions nullglob rcexpandparam extendedglob
+  unsetopt markdirs globsubst shwordsplit nounset ksharrays
+
   local _sort_tags=_help_sort_tags text i j k
   typeset -A help_funcs help_tags help_sfuncs help_styles
 

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com



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