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

Re: tag-order with git refs



[> workers]

On Oct 8, 10:39am, Peter Stephenson wrote:
} Subject: Re: tag-order with git refs
}
} Sounds like there are at least some possibilities for improving this,
} but I wonder if we can make ^xh a bit more helpful about what you
} actually need to do in a particular case?  That would save a lot of
} documentation for a lot of completions.

Squinted at this for a bit ...

} It's sort of mentioning the
} right words but doesn't give any help about how you need to combine
} them.  If we could make it build up a "story so far" string and output
} it at the end, or something like that...?

This would have to be a change to the _help_sort_tags function in
_complete_help.

It does accumulate the call stack down to the point at which the tag
becomes active, e.g. (re-wrapping lines for clarity):

heads-local   (__git_heads_local
               __git_heads
               _alternative
               __git_commits
               __git_tree_ishs
               _alternative
               _git-checkout
               _call_function
               _git)

(looks as if it should be filtering out _alternative and _call_function
along with the list of other things it already does filter).

So I guess you're supposed to intuit that when you see a stack that deep,
you should look at the other parenthesized stacks to find the tags in
__git_heads, and then the tags in _git_commits, and then _git_tree_ishs,
and so on, and build up your tag-order from that.

It's doing this by looking at $funcstack.  To get the tags instead of
the function names, I think _help_sort_tags would have to maintain its
own stack.

This patch doesn't attempt that, it just cleans up the funcstack stuff.


diff --git a/Completion/Base/Widget/_complete_help b/Completion/Base/Widget/_complete_help
index 0563c61..09637ec 100644
--- a/Completion/Base/Widget/_complete_help
+++ b/Completion/Base/Widget/_complete_help
@@ -6,12 +6,15 @@ _complete_help() {
   local _sort_tags=_help_sort_tags text i j k tmp
   typeset -A help_funcs help_tags help_sfuncs help_styles
 
+  local -H _help_scan_funcstack="main_complete|complete|approximate|normal"
+  local -H _help_filter_funcstack="alternative|call_function|describe|dispatch|wanted|requested|all_labels|next_label"
+
   {
     compadd() { return 1 }
     zstyle() {
-      local _f="${${(@)${(@)funcstack[2,(i)_(main_complete|complete|approximate|normal)]}:#_(dispatch|wanted|requested|all_labels|next_label)}% *}"
+      local _f="${${(@)${(@)funcstack[2,(i)_($~_help_scan_funcstack)]}:#(_($~_help_filter_funcstack)|\((eval|anon)\))}% *}"
   
-      [[ -z "$_f" ]] && _f="${${(@)funcstack[2,(i)_(main_complete|complete|approximate|normal)]}:#_(dispatch|wanted|requested|all_labels|next_label)}"
+      [[ -z "$_f" ]] && _f="${${(@)funcstack[2,(i)_($~_help_scan_funcstack)]}:#(_($~_help_filter_funcstack)|\((eval|anon)\))}"
   
       if [[ "$help_sfuncs[$2]" != *${_f}* ||
             "$help_styles[${2}${_f}]" != *${3}* ]]; then
@@ -73,7 +76,7 @@ _complete_help() {
 }
 
 _help_sort_tags() {
-  local f="${${(@)${(@)funcstack[3,(i)_(main_complete|complete|approximate|normal)]}:#(_(dispatch|wanted|requested|all_labels|next_label)|\(eval\))}% *}"
+  local f="${${(@)${(@)funcstack[3,(i)_($~_help_scan_funcstack)]}:#(_($~_help_filter_funcstack)|\((eval|anon)\))}% *}"
 
   if [[ "$help_funcs[$curcontext]" != *${f}* ||
         "$help_tags[${curcontext}${f}]" != *(${(j:|:)~argv})* ]]; then



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