martanne / vis

A vi-like editor based on Plan 9's structural regular expressions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature Request]: exit with status code

mralusw opened this issue · comments

What feature would you like to see?

Is there something like vim's :cquit (exit editor with status code), so that at least I might use vis as $GIT_EDITOR or $GIT_SEQUENCE_EDITOR? Exiting with a status code aborts the commit / rebase / whatever operation caused the editor to be invoked.

Not built in but its easy to add via lua:

vis:command_register("cq", function() vis:exit(1) end)

Ah. I found qall[!] [code]. I even managed to map it: map mode lhs rhs doesn't seem to accept a space within rhs, but qall!1 without a space works.

Before that, I tried vis:command_register("cq!", function() vis:exit(1) end) but it doesn't seem to work with a bang.

I suggest you look at the Lua documentation if you want to require the exclamation mark. ! can not be part of a command name, it specifies the force parameter

OK. For reference, to map <backslash>Q (like <Leader>Q in vi), add

  vis:command( "map normal \\Q :qall!\\ 1<Enter>" )

in the vis.events.subscribe(vis.events.INIT ... ) part of of visrc.lua. The \\ is, as I discovered above, optional, but this is how to add a <space> in a mapping "rhs". Also, all doubling of backslashes is due to inclusion in a lua string.

I wonder if there's a way to include a visrc.vis from Lua with normal commands (separate issue I guess).