Fork me on GitHub
Martynas Maciulevičius14:04:39

Hey. I found that there is a shortcut to evaluate an expression in cider. SPC m e e evaluates an expresssion that is before the cursor. Is there a way to evaluate an expression that is one symbol further? i.e. an expression that ends one symbol after the cursor? Otherwise it could work the same. Example:

'(1 2 3 [4] 5)
The [] signifies where block cursor is located. It highlights whole character 4. In this example SPC m e e would evaluate 3 but I want to evaluate 4. And this is a more complicated example where I want to evaluate a longer function name: (map [i]nc '(1 2 3)) => map So the cursor is located on i letter but it would evaluate function map instead of inc. I would like to make it so that it would evaluate inc. But if I go one symbol further SPC m e e evaluates inc: (map i[n]c '(1 2 3)) => inc I use block cursor all the time and evaluation of last expression doesn't make sense. Because then I end up with this behavior: 1 2 3 4 [5]$ Dollar sign means that it's end of the line and I can't move my cursor to this symbol. But evaluation via SPC m e e gives me 4. While this cursor placement gives me the first item: 1 [2] 3 4 5$ => 1

Martynas Maciulevičius14:04:36

Found it. It was SPC m e v.

👍 1
Martynas Maciulevičius14:04:35

Hey. I found that CIDER has a handy binding to evaluate a full paren form. But sometimes I want to also evaluate a vector or a map. Would it be possible to add these to the bindings? For instance SPC m e [ and SPC m e { . Also the VIM mode has a binding vaB that selects curly braces as in va{ and it also has vab that acts as if you'd press va(. It's more convenient because then you don't need to reach for the two-button shift+9 . And instead you can click one button b to select it. It's probably not a good idea because , e b already evaluates the whole buffer. But it's an idea to think about because , s b does something very similar. Also I'm used to use C-p C-p a lot after I select whole form in VIM's visual mode. And it puts the result in a result buffer. But as I found the functions , e ( and others they only show the result inline. This is completely fine but sometimes it's nice to view larger results. And this is where the result buffer comes in. But keystroke , e p ( doesn't exist.

Martynas Maciulevičius14:04:59

it could also work seamlessly with vim mode such that it would accept a region and then vim mode would take care about the selection and so on.

Martynas Maciulevičius14:04:26

Yes, it's probably because I'm used to be using vim's keybinds to delete a paragraph and so on: dap -> deletes whole paragraph (`d` is for deletion, a p => all paragraph; dip would keep the surrounding newlines). I wanted something like this that could send a text selection directly into evaluation. Not sure if it's possible.

Martynas Maciulevičius15:04:16

Figured it out. I now have two keystrokes that allow to execute a text object from the EVIL mode. ,eda( or ,eDa( . The part a( is evil motion and selects a region of text. And it also works with already preselected text.