Greetings all,<br><br>This note is in reply to an old message (<a href="http://osdir.com/ml/gis.grass.user/2003-01/msg00039.html">http://osdir.com/ml/gis.grass.user/2003-01/msg00039.html</a>) seeking advice on using GRASS within EMACS. While not perfect (it would be nice to have a proper grass mode for emacs) I have a solution that works fairly well and is easy to implement. <br>
<br>I use R and GRASS together and frequently switch back and forth to accomplish tasks (this is the main reason I've stopped using Arc products - it's difficult to interface with a powerful statistics program), so I wanted to find a way to use GRASS easily within the EMACS - ESS environment (where I do my R work). I found that this is as simple as starting an R process (see <a href="http://ess.r-project.org/index.php?Section=home">http://ess.r-project.org/index.php?Section=home</a>), then switching to GRASS with a system() command and specifying the mapset. The send line function still works the same as in R, so the functionality is very similar. <br>
<br>For example:<br><ol><li>Open emacs and start R as described in the ess documentation <a href="http://ess.r-project.org/index.php?Section=home">http://ess.r-project.org/index.php?Section=home</a></li><li>run: system("grass63 /media/Data/Work/grassdata/spearfish/PERMANENT") # or whatever grass version and location/mapset you want to open. This can be the first line of your script.</li>
<li>That's it, you now have an interactive GRASS session that you can send lines of code using the ess interface. <br></li><li>if you want to start a R process within GRASS, you can run "R" at the grass prompt and you start a new nested R process, where you can load library(spgrass6) and use all those powerful R functions</li>
</ol>This results in a R process running within a grass process running within the original R process, but I don't notice any performance loss or bad repercussions of this. Ctrl-L sends the current line to the grass prompt (emacs-ess still thinks it's running R). This makes it quite simple to have a single script that bounces back and forth between GRASS and R. You can even exit from GRASS (which puts you back at the original R process) and then start a new GRASS process in a new mapset with another system() call. I like to keep an instance of QGis open at the same time for viewing the data I'm playing with, just hit ctrl-R there to refresh the map so it reflects any recent changes you made in the emacs-grass terminal. This results in a much better workflow than I have experienced with any arc products. While GRASS is chugging away on some big job, I am free to explore the same data in QGis. Emacs-ESS even allows multiple process to be running at the same time, so you if have some big jobs that you'd like to run in the background (but keep all the commands together in one script), you can do that too (though you cannot easily open the same mapset twice). <br>
<br>A few things about the Emacs-ESS interface that don't work (the first two are probably easily fixable, but I don't know how to do it):<br><ol><li>Send-region (ctrl-r) sends the first line then freezes the interface. Hit ctrl-g to unfreeze it. You have to send GRASS commands one line at a time. A little annoying but not horrible.<br>
</li><li>When the cursor is at the shell in GRASS - alt-p does not bring back the previously executed command. You have to re-type or copy-paste from above.</li><li>And, according to the previous post, "a few programs (primarily v.digit and many of the imagery programs) can only be used through a curses-based interface,<br>
which won't work with shell-mode. term-mode should work, but that "eats" most of Emacs' common keystrokes, which substantially reduces its usefulness, IMHO. - Glenn"<br>
</li></ol>For someone that understands lisp and how to set up modes in Emacs-ESS, it would probably not be too hard to add a GRASS mode by just making a few small changes to the R mode. <br><br>I hope someone finds this helpful. Thanks to all who have contributed to GRASS, it's great!<br>
<br><br>Adam<br><br><br clear="all"> Adam Wilson<br> __o <a href="http://hydrodictyon.eeb.uconn.edu/people/wilson/">http://hydrodictyon.eeb.uconn.edu/people/wilson/</a><br> _`\<,_ Department of Ecology and Evolutionary Biology<br>
(*)/ (*) BioPharm 223<br> University of Connecticut<br> Tel: 860.486.4157<br>