Somewhere in the second half of last year I switched my primary text editor from Vim to Emacs. Calm down! I use Evil. So, one of my primary languages is R and I was in love with this plugin in Vim. A snippet of my vim config that I used to rely heavily on in Vim was:
1 2 3 4 5 6 7 8 9 |
|
These commands were invented by me after looking at a similar usage pattern in the plugin’s manuals. Being able to inspect objects at point without switching from my editor to the R prompt made me much more productive than when I could not do this. After I switched to Emacs and the mighty ESS for programming in R, replicating this was an explicit TODO in my ESS configuration. Ladies & gentlemen, today I bring you the solution. Drumroll!
The primary idea — ess-command
wrapped with popup-tip
— came from this blog post of yore and was wielded to magnificent effect by yours truly. (Yes, I’m a megalomaniac, thank you very much.)
Lemme show you teh codez.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
|
The function asb-ess-R-object-popup
allows us to yank the word at point and execute an arbitrary function on it (without arguments) and display the output as a popup-tip. This function is wrapped into asb-ess-R-object-popup-str
mapped to <leader>ei
(evil-ess-inspect) to inspect the str
of the object interactively because this is what I use the most. Another function called asb-ess-R-object-popup-interactive
mapped to <leader>eI
(evil-ess-interactive-inspect) asks the user what R function to inspect the object with. Common suspects will be head
, tail
, names
, etc. You know the drill. Have a look at the video and pay attention to the minibuffer.
PS: Actually, don’t bother watching the video; I don’t know why youtube insists on downgrading the video quality.