emacs-ess / ESS

Emacs Speaks Statistics: ESS
https://ess.r-project.org/
GNU General Public License v3.0
622 stars 162 forks source link

Add an option to make stata-mode work like the Stata built-in editor to use the xstata/GUI version #451

Closed hliebert closed 8 months ago

hliebert commented 7 years ago

I am currently trying to migrate from Vim to Emacs/Spacemacs. I frequently have to use Stata for work with coauthors. However, running Stata in Emacs isn't quite as useful as using the GUI Version (e.g. for displaying graphs or looking at the data in the spreadsheet viewer). See also the discussion e.g. here.

The built-in Stata do file editor works by just using having commands to execute either the whole file or a selection by writing it to a temp file and then executing that. Would it be possible to add this functionality as on option to ESS? I believe this behaviour could be more useful than the current state.

I have emulated this in Vim by writing a tmp file and triggering a simple shell script to change to the current GUI window and then execute the file. I have been using it for some time, and it works fine. Unfortunately, I do not know any Emacs Lisp and have no idea how to implement this. I'd happily share my current solution. It's not really elegant, relying on a combination of xdotool, wmctrl, xte and uses the system clipboard, but it works.

vspinu commented 7 years ago

I am afraid no-one from the core developers are using STATA on a regular basis or maybe at all. So I am a bit pessimistic about the outcome on this. You will probably have to figure it out yourself, especially if it's such a hacky communication mechanism as focusing STATA GUI window and pasting there.

You can easily grab a region, save to a file, run your and old shell script on it within emacs. Look at buffer-substring-no-properties, with-temp-file and call-process-shell-command.

hliebert commented 7 years ago

Thanks, I suspected as much. Thank you for providing some pointers where to start, I'll have a look. Is there a way to easily disable ess/stata-mode for stata related files?

vspinu commented 7 years ago

I think there was a do-mode lying somewhere but I cannot seem to find it anymore. In any case you can always bind your custom commands in ess-mode-map.