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

Re: completion fails if dir referenced via variable.



On Feb 25, 11:41am, Ray Andrews wrote:
}
} But couldn't we have:
} 
}   zstyle ':completion:*' auto-multiple-completion
} 
} or something like that? In the above situation I'd want it to perform 
} any and all completions/expansions/corrections all at once, every time. 

The default tab-binding around which this is essentially designed is
the builtin widget "expand-or-complete".  Note "or": expand if possible,
else complete, not both.

If what you want is "expand-and-complete" you can construct that:

    expand-and-complete() {
      zle expand-word	# perhaps _expand_word for compsys support
      zle complete-word
    }
    zle -N expand-and-complete
    bindkey $'\t' expand-and-complete

If you go with _expand_word instead of expand-word you still need the
tag-order all-expansions style that Oliver described, but there are some
rare cases that _expand_word handles better than the builtin expand-word.

Here's a slightly more sophisticated version:

    expand-and-complete() {
      if [[ $LASTWIDGET != expand-and-complete ]]; then
        zle expand-word
	zle auto-remove-suffix
      fi
      zle complete-word
    }
    zle -N expand-and-complete
    bindkey $'\t' expand-and-complete

This allows multiple TABs to enter menu completion, otherwise the call
to expand-word breaks off the last completion and starts a new one.



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