[ESS] how to leverage ESS parsing to find current module in Julia buffer

Tamas Papp tkpapp at gmail.com
Wed Feb 25 10:37:03 CET 2015


I am still working on improving ESS/Julia, especially the evaluation
context. The problem I am facing is finding the relevant module for
evaluation --- I thought I can simply search backwards with a regexp,
but submodules complicate this.

For example, if a buffer contains

--8<---------------cut here---------------start------------->8---
module Parent

module Child1
f(x) = x+1

module Child2
g(x) = x+1                      # eval here

--8<---------------cut here---------------end--------------->8---

and the user presses C-c C-c on the line that contains

g(x) = x+1                      # eval here

then the relevant module for eval is Parent.Child2. If I naively search
backwards and collect all module lines that match a regexp, I get
Parent, Child1, and Child2.

So it seems I would have to parse the file somehow in Emacs. But I
notice that ESS already does some of that, since it indents everything
correctly. Can I somehow use that to extract a list of open (ie not
terminated with an "end") module expressions up to a given position?



More information about the ESS-help mailing list