Add switch buffer command
A new command has been added to switch buffers interactively. The minibuffer prompts for the buffer to switch to, defaulting the previous buffer if a name is not provided. It has been bound to "alt-x" for eXchange buffer.
Internally, a new variable has been added to ship/editor.lua:
last_edit_buffer
. ship.change_buffer
has been modified to track the
previous buffer in last_edit_buffer
. A new function,
ship.last_buffer
, has been added to allow getting the previous buffer
from the sandbox. ship.open
has been slightly modified to save the
current buffer to last_edit_buffer
before switching.
Exactly as it says on the tin. As far as I can tell, there are a few behaviors that may not be optimal:
-
Switching to a buffer that is closed will switch back to flight mode
-
Likewise, switching to a buffer that does not exist will also switch back to flight mode
I wasn't sure if we wanted Emacs-style 'create if non-existant' buffer behavior, so I opted to just leave that alone. This is easily added if we want it.
We may want to look into added multi-layer bindings and/or providing an
'extended command' mechanism ala Emacs' execute-extended-command
(M-x
) in
the near future. We're starting to run out of room in the single combo keyspace;
"alt-x" was my 3rd choice for binding, and I'm not particularly happy with that
binding - I'd have prefered one with a 'b' in it somewhere. Something to think
about.
If you would like anything else to go with this patch, let me know.