Christophe Weblog Wiki Code Publications Music
more srcref frobbing
authorChristophe Rhodes <csr21@cantab.net>
Thu, 29 Nov 2012 14:50:08 +0000 (14:50 +0000)
committerChristophe Rhodes <csr21@cantab.net>
Thu, 29 Nov 2012 14:50:08 +0000 (14:50 +0000)
I do not pretend to understand whether this is new, but in 2.14
parsing an expression, in addition to adding srcref attributes to the
results of the parse, can result in actual srcref elements being in
the results.  Those srcrefs also need to be frobbed so that display of
functions at the repl works properly.  (I do think this worked in 2.12
without this extra frobbing, but I am totally prepared to admit that I
can't really remember).

Since we're on the case, also frob things that look like srcrefs but
aren't under "srcref" attributes, such as "wholeSrcref"s

swank.R

diff --git a/swank.R b/swank.R
index 757e2430752b00ce87724f82ccfbd0d6dfbb5dbe..8ba9060f6147a47956ba4e6e18a8d4a8ebd9be45 100644 (file)
--- a/swank.R
+++ b/swank.R
@@ -525,6 +525,12 @@ computeRestartsForEmacs <- function (sldbState) {
     if(mode(s) == "name") {
       return(s)
     }
     if(mode(s) == "name") {
       return(s)
     }
+    if(is(s, "srcref")) {
+      ## more monumental KLUDGE: parsing (in 2.14, at least) appears
+      ## to put srcrefs directly in `length 2' objects, which we need
+      ## to frob directly.
+      return(frob(list(s))[[1]])
+    }
     srcrefs <- attr(s, "srcref")
     attribs <- attributes(s)
     new <- 
     srcrefs <- attr(s, "srcref")
     attribs <- attributes(s)
     new <- 
@@ -536,6 +542,9 @@ computeRestartsForEmacs <- function (sldbState) {
     if(!is.null(attr(s, "srcref"))) {
       attr(new, "srcref") <- frob(srcrefs)
     }
     if(!is.null(attr(s, "srcref"))) {
       attr(new, "srcref") <- frob(srcrefs)
     }
+    if(!is.null(attr(s, "wholeSrcref"))) {
+      attr(new, "wholeSrcref") <- frob(list(attr(s, "wholeSrcref")))[[1]]
+    }
     new
   }
   withRestarts({
     new
   }
   withRestarts({