17 comments

[ 3.3 ms ] story [ 52.1 ms ] thread
I could be mistaken, but isn't this a GNU Readline feature?

Neat regardless.

I think this is different because I'm full on opening an instance of vim. (I didn't know about GNU Readline though and it looks awesome - I'll definitely try and work it into a project at some point).
Either Readline let's you do the same, or that is just a bash specific feature I am miss remembering. I can check later when I'm not on my phone.
I'm only using GNU readline for my bash prompt, but if I press v it spawns a full-on $EDITOR instance to edit the commandline.
This is awesome (I still have a lot to learn about bash) and effectively what my module does.

Just so others know, you have to put bash in vi mode and press Esc before v (otherwise it's ctrl+x ctrl+e).

set -o vi

Aye, looks like I was wrong. This is a feature that bash has, not Readline. (in bash 4.2: bashline.c:858)
Cool.

Haven't looked at the code yet, but I wrote:

https://github.com/Julian/dotfiles/blob/master/.config/pytho...

which does something similar (and is interpreter agnostic as it looks like this is).

Mine's not interpreter agnostic because I had to mess with the stack frames to insert variables into the global context.

But yours is able to do that because your importing a top-level edit function while I was pretty set on dynamically creating a vim() method and not having to import a function (just a module).

I love how yours lists the globals though! I might just have to bite that feature :).

Oh, yeah, well, importing stuff on interpreter startup is pretty much exactly what $PYTHONSTARTUP is for :).
And this is why I post code online - to find out the right way to do things. PYTHONSTARTUP is exactly 100% what I was looking for, but didn't know existed.
oh my god this is awesome
Nice. Reminds me of a feature I have in Glass Table[0]:

Define a procedure, macro, or record type called foo:

    (define (foo x) ...)
Now say:

    ,(edit foo)
Your definition appears in the editor of your choice. (Try running GT within Emacs and setting your EDITOR to "emacsclient".) Make changes; provided no errors occurred (like missing parens) the changes take effect when you save and quit.

It's a nice little workflow; if you squint, it almost feels like a CADR...

[0] https://github.com/bitwize/glasstable