Very hacky support for ctrl+r history search

Type something, then hit ctrl+r to cycle through history items
which contain the value. ctrl+g to cancel.

Misfeatures:

* Search is case-sensitive

* Search does not update properly

* Code is a mess

* Not compatible with multiline mode
Merge branches 'add-history-completions', 'use-tab-constant' and 'search-history'