[GRASS-user] d.mon vs gui windows

Ken Mankoff mankoff at gmail.com
Thu Nov 30 01:05:25 PST 2017


On 2017-11-29 at 22:12, Tyler Smith <tyler at plantarum.ca> wrote:
> How are you running the code blocks? I didn't think there was babel
> support for GRASS. I've been using org-mode more frequently lately,
> and was thinking about extending grass-mode to provide babel support.
> But maybe someone's already done this?

I don't actually use the Emacs grass mode, just Org and Babel and Shells and GRASS. The code below this text works for me, both with and without Babel sessions. There are probably more elegant ways to do this. It would be nice if GRASS could have a "--quiet" option at launch to save the ASCII splash screen. I'm not sure why Org Babel w/ session's doesn't source my ~/.bash_profile. I usually run with ":results verbatim" but sometimes generate Org Tables from GRASS commands, and then use and manipulate them outside of GRASS in other babel blocks in other languages, and then bring results back into GRASS.

Also, many things in GRASS take time to run, and Org Babel doesn't officially support asynchronous execution. There are hacks for this, but I often find that I code in Org Babel but execute using an Emacs interface to my shell. This can be the same shell :session accessed by Org Babel. I have various keybindings to send lines and regions to the shell buffer (including appending an audio & visual notification when the commands complete) and then Emacs does not hang, I can continue using it while the GRASS commands run, and I'm alerted when the command finishes and I can send the next chunk to the shell.

When development is done, I can tangle everything to a single script and re-run all commands to re-produce the analysis and results using only GRASS and no Emacs, if I so choose (but not if I'm manipulating results in Org but outside of GRASS, as described above).

I hope this helps,

  -k.


*** GRASS shell no session
**** Create Region
#+BEGIN_SRC sh :results verbatim
trash ~/Desktop/Gtmp
grass72 --text -c EPSG:3413 ~/Desktop/Gtmp
g.region -p
#+END_SRC

**** Run more commands (re-launch GRASS each time)
#+BEGIN_SRC sh :results verbatim
grass72 ~/Desktop/Gtmp/PERMANENT
g.region -p
#+END_SRC


*** GRASS shell w/ session
**** Initialize Session and GRASS
#+BEGIN_SRC sh :results verbatim :session Gfoo
source ~/.bash_profile  # not sure why I need to do this
trash ~/Desktop/Gtmp
grass72 --text -c EPSG:3413 ~/Desktop/Gtmp
g.region -p
#+END_SRC

**** Run more commands 
#+BEGIN_SRC sh :results verbatim :session Gfoo
g.region -p
#+END_SRC


More information about the grass-user mailing list