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

Re: completer that first expands global aliases (Re: dsf)



On Jan 8,  6:01pm, Daniel wrote:
}
} If I add the _expand_alias like below, hitting ^Xm gives the expansion with a
} trailing space. And nothing more happens. The hash is the cursor position:
} 
}   zstyle ':completion:most-recent-*::::' completer _expand_alias _menu _complete _match
} 
}   $ cat ~/dl/ #    

The problem here is that the completer style tries each function in the
list until it finds one that succeeds (returns 0) at which point it
stops.  So you need _expand_alias to "fail" (return nonzero).

You can hack this by using a little wrapper function:

    _expand_alias_hack() {
      _expand_alias "$@"
      return 1
    }
    zstyle ':completion:most-recent-*::::' completer \
    	_expand_alias_hack _menu _complete _match

However, a cleaner way to do it would be to use the compprefuncs array.
This documentation for this is rather minimal; it's mostly used by the
_next_tags widget to force completion to walk through the tags array.
However, you can use it for oether completers as well.

In this case, you can either create a new widget for the most-recent-*
completion and assign to compprefuncs in the widget, or you can embed it
in the completer style definition by using the -e option:

    zstyle -e ':completion:most-recent-*::::' completer \
	'compprefuncs=(_expand_alias) reply=(_menu _complete _match)'

Note the quoting, it's important.

-- 
Barton E. Schaefer



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