WeeChat DevCenter

Tag - completion

Entries feed

Monday, March 22 2010

Custom completion for aliases

It is now possible to have custom completion for aliases, for example to complete with another command completion, or with your own completion.

Examples:

  • create alias /forcejoin with completion of /sajoin: /alias -completion %%sajoin forcejoin /quote forcejoin
  • create alias /mybuf with custom completion: /alias -completion #weechat|#weechat-fr mybuf /buffer

You can change completion if alias is already created:

/set alias.completion.forcejoin "%%sajoin"

You can use empty string to prevent any completion for command (default is to complete using target command):

/set alias.completion.forcejoin ""

And you can remove a completion:

/unset alias.completion.forcejoin

Completion is automatically removed when you remove an alias with /unalias.

Saturday, April 11 2009

Completion improved for command arguments

Completion has been improved for command arguments. Now many templates are allowed for one command, and WeeChat will automatically choose and use the better template according to arguments you give on command line.

Let's take an example: the /proxy command. Completion template is this string:

add %(proxies_names) http|socks4|socks5 || del %(proxies_names) || set %(proxies_names) %(proxies_options) || list

The single pipe is still used to add many possible items for one argument. Now a double pipe has been added to separate many templates. WeeChat will choose template according to arguments you give before completion location in command line.
Example 1: if you enter: "/proxy add [+tab]", then WeeChat will use first template ("add %(proxies_names) http|socks4|socks5").
Example 2: if you enter: "/proxy set [+tab]", WeeChat will used third template ("set %(proxies_names) %(proxies_options)").

Now, you'll ask: but how to complete first argument of command? WeeChat can't know which template to use!
Hey, good question! I was sure you would ask that ;)
The answer is very simple: for first argument, WeeChat will make a "or" between first argument of each template (so it will use a fictive template which is: "add|del|set").

It's recommended to use plain words for first argument of each template (when using many templates). If you use many words (separated by single pipe), or items (%(xxx)), then WeeChat will not know which template to use, and may not complete at all.

Another thing you should know, default completion items (defined by WeeChat core) have been renamed. Old name was something like "%x", new name is"%(xxx)". For example %n has been renamed to %(nicks). Some new completions have been added too. Please read doc for new names (and now that includes names of completion items defined by plugins).

If you are using old development version, nick completion will be broken, so you'll have to issue following command: /unset weechat.completion.default_template

Happy completion party!