yi-editor/yi — pull request #496 by benarmston (2014-01-16 21:19:49+00:00)
Title: Vim2 buffer ex command improvements

This PR removes some incompatibilities between Vim's `:buffer` command and the Vim2 keymap's `:buffer` command.

- Don't switch away from a modified file.
- Support a `!` to allow switching from a modified file.
- Support buffer numbers directly after the command name, e.g., `:b4`.
- Support `:buffer` as a noop. Previously at least one space was required after the command.

Also, the error message for an unrecognized ex command has been improved. It now includes the command that wasn't correctly parsed. This proved surprisingly useful for debugging errors with the ex command parsers.

The `:buffer` command parser makes use of a new `parseWithBang` function exported by `Yi.Keymaps.Vim2.Ex.Commands.Common`. It is part of a work-in-progress experiment I have to make writing compatible-with-vim ex commands much easier. The idea is that one would eventually be able to write something like:

```haskell
myExCommandParser =
Common.parse (AcceptsRange <> AcceptsBang <> AcceptsArguments)
(P.try (P.string "smine" *> return "s") <|> P.string "mine" *> return "")
(\range s bang -> do
args <- someParser
let split = s == "s"
doStuff range split bang
)
```

It doesn't have much relevance to this PR, but it does explain why the second argument to `parseWithBang` takes the result of running the name parser. And besides I just wanted to mention it ;-)