Fix warnings: Fix outdated doc: Connecting to nvim through python REPL.

After neovim/python-client@b8b48bbe8fe9ee41ad73c9bd5a45e808504399e2,
docs were no longer relevant.
Merge pull request #1373 from elmart/fix-outofdate-doc

Fix outdated doc: Connecting to nvim through python REPL.
runtime: Refer to plugins running outside Nvim as "remote plugins"

- Rename autoload/rpc to autoload/remote
- External plugins are now remote plugins
- External plugins directory is "rplugin"
Merge PR #1515 'Refer to plugins running outside Nvim as "remote plugins"'
Add helper script for porting vim patches.
input: Refactor to ensure user input has higher priority
test: Refactor functional helpers to use vim_input

The vim_input function accepts raw terminal input and so is better to emulate
real user, especially because it is not deferred as vim_feedkeys.

Using this function required a number of changes:

- expect() was refactored to use curbuf_contents()
- The vim_eval function in request() was moved to curbuf_contents(). For most
  cases this is enough(we only care for synchronizing api calls with user input
  when verifying buffer contents).
- <C-@>(NUL) is preprocessed before being passed to replace_termcodes.
- Legacy test 4 had a bug that only became visible when using vim_input, it is
  fixed now.
- An extra blank line deletion was required for test 101

The last two items show that vim_feedkeys because it is not 100% equivalent to
receiving terminal input.
test: Fix problems in job_spec.lua

Nvim wasn't exiting cleanly in some job tests due to errors.

This can't be noticed until the next commit, which will perform a refactoring to
selectively process K_EVENT, so the `qa!` command executed at the end of each
test blocks forever if there are errors which require the user to press ENTER(in
that state Nvim no longer will process events).
event: No longer process K_EVENT automatically

Two new functions, `event_enable_deferred()`/`event_disable_deferred()` have to
be called by code that is capable of handling asynchronicity. User-dialog states
like "press ENTER to continue" or the swap file confirmation no longer will
generate K_EVENT.
Merge PR #1518 'Improve functional tests and perform explicit K_EVENT handling'
Fix functional-test-105 failure in OSX.

See https://github.com/neovim/neovim/issues/1519 for failure report.

Cause    : In OSX, /tmp is a symbolic link to /private/tmp, which causes
           expected and got results different because of implicit
           resolution.
Solution : Resolve path before setting expected value.
Merge pull request #1513 from fwalch/vimpatch-script

Add helper script for porting vim patches.
Fix Makefile for running valgrind with old tests.
Merge pull request #1521 from three-comrades/valgrind

Fix Makefile for running valgrind with old tests.
Merge pull request #1520 from elmart/fix-func-tests

Fix functional tests failing on OSX.
test: Add gdbserver support on helpers.lua

The $GDB env var can be set to run tests under gdbserver. If $VALGRIND is also
set, it will add the --vgdb=yes command-line option to valgrind instead of
starting gdbserver.
Merge PR #1527 'Add gdbserver support on helpers.lua'
clipboard: check for X on every invocation

xsel and xcopy may be available even if a valid X display is not. Also,
the availability of X may change at any time, so check on each
invocation.

Closes #1509.
Merge pull request #1525 from justinmk/clipboardX

clipboard: check for X on every invocation
Fix substitute newline: Memory functions: Improve style.

`try_malloc` was changed in 8bb2c2c0742c57150655e18cf8418a758cebdce8 to
avoid a warning when size is 0. Then, this improves some things on that:

- Use local vars instead of changing parameters.
- Homogenize style for other related functions.