I am transitioning to Emacs with evil-mode after years of Vim. For work reasons I have to use a GUI statistics program (Stata) frequently. This program does not integrate well with external editors.
ess-mode doesn't support the GUI version of Stata but only a very limited terminal version. I prefer a simple solution that I can maintain myself.
To make it work with Vim, I wrote a shell script using
xdotool that takes as argument a filename, opens the GUI window, pastes "do filename" in the command window, sends return and then goes back to the original editor window. It's not a sophisticated solution but works well in practice.
.vimrc I had some code that would write the currently selected region or the current line to a temporary file in
/tmp/randomfoldername/consecutivenumber.do, then call the shell script with that file as the argument. Upon leaving vim, the folder would be deleted.
I am looking to replicate this functionality in Emacs, but don't know how or where to start. I essentially want to mimick what the
ess-eval-buffer are doing, simply by calling the shell script with the name of a temporary file or the name of the current buffer.
If it helps, this is the vimscript code:
" Run current buffer fun! RunIt() w !sh "~/dotfiles/rundo.sh" "%:p" endfun " Run selection fun! RunDoLines() let selectedLines = getbufline('%', line("'<"), line("'>")) if col("'>") < strlen(getline(line("'>"))) let selectedLines[-1] = strpart(selectedLines[-1], 0, col("'>")) endif if col("'<") != 1 let selectedLines = strpart(selectedLines, col("'<")-1) endif let temp = tempname() . ".do" call writefile(selectedLines, temp) exec "!sh ~/dotfiles/rundo.sh " . temp au VimLeave * silent exe '!del /Q "'.$TEMP.'\*.tmp.do"' endfun " Mappings au FileType stata noremap <F8> :<C-U>call RunIt()<CR><CR> au FileType stata noremap <F9> :<C-U>call RunDoLines()<CR><CR> au FileType stata noremap <C-Return> <S-v>:<C-U>call RunDoLines()<CR><CR>