Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vim-like :commands and :!exec #23

Open
linuxcaffe opened this issue Mar 16, 2017 · 2 comments
Open

vim-like :commands and :!exec #23

linuxcaffe opened this issue Mar 16, 2017 · 2 comments

Comments

@linuxcaffe
Copy link

linuxcaffe commented Mar 16, 2017

this is a crazy proposal for discussion.
iadd's keybindings work just great, but there comes a point where more exotic or unusual things maybe be shouldn't be jammed in there. This suggestion is for a key-binding on a leading ":", like when using vim, to preface vim-commands, or when using a leading ":!" to execute arbitrary shell commands.

:command
might have some iadd core navigation/ commands, and might also be configured to run any other hledger command, like reg or bal or..

:!exec
might be used to launch aliases, scripts or macros or just to issue a shell command (see #20 and #21)

in either case, on clean exit, iadd would resume entry of the transaction, and if the command exits with error, the error-message (if any) should be displayed and the iadd "Cancel Transaction? Y/n" should be triggered.

for your consideration.

@hpdeifel
Copy link
Owner

While I like vim-like ex-commands in many curses applications, I think it would probably be overkill for hledger-iadd. We currently have 13 different key bindings of which two are aliases for other keys (C-d and F1).

We also could not use the colon as prefix, because it's something the user might want to enter in the text area (e.g for account names).

:command
might have some iadd core navigation/ commands, and might also be configured to run any other hledger command, like reg or bal or..

Like I said above, I'm not sure this is necessary right now. Maybe if iadd gains a lot new features, but currently there are only a handful of core functions (navigation, accept, comment, undo, quit) with a few variations. Ex-commands have the advantage over key bindings of being mnemonic but as long as the key bindings fit on a small in-app help screen, I don't think that's very important. This advantage would also be mitigated by implementing @simonmichael's proposal of a permanent help bar at the top or bottom.

I can't think of a good reason to have hledger commands like bal or reg available from within iadd as opposed of just running them in another terminal. Do you have any use-case in mind?

:!exec
might be used to launch aliases, scripts or macros or just to issue a shell command (see #20 and #21)

This would be very useful! As outlined above, we'd need to bind it to something other than :!. A prompt for an arbitrary shell command to pipe the current transaction to would indeed solve #20 and #21; add a nice persistent command history and we don't even need a config option for that any more.

@linuxcaffe
Copy link
Author

linuxcaffe commented Mar 22, 2017

I agree!

  • :commands are not necessary, and would mostly duplicate existing functions
  • :!exec keybinding would be super-versatile, offloading a ton of personal usecases
  • non-conflicting key(s) must be picked, instead of the ones used for the above example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants