From c15f7575dad3773f1f56e37f5943d8d277f76ee8 Mon Sep 17 00:00:00 2001 From: Christophe Rhodes Date: Wed, 1 Sep 2010 11:11:52 +0100 Subject: [PATCH] implement swank:find-definitions-for-emacs A simple implementation, only looking for a single function definition (no methods, whether S3 or S4, or indeed anything else). Enough to support M-., though. --- swank.R | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/swank.R b/swank.R index 1316485..1dc95b4 100644 --- a/swank.R +++ b/swank.R @@ -418,3 +418,28 @@ computeRestartsForEmacs <- function (sldbState) { finally={sink(); output <- readLines(f); close(f)}) list(output, printToString(value)) } + +`swank:find-definitions-for-emacs` <- function(slimeConnection, sldbState, string) { + if(exists(string, envir = globalenv())) { + thing <- get(string, envir = globalenv()) + if(inherits(thing, "function")) { + body <- body(thing) + srcref <- attr(body, "srcref") + srcfile <- attr(body, "srcfile") + if(is.null(srcfile)) { + list() + } else { + filename <- get("filename", srcfile) + list(list(sprintf("function %s", string), + list(quote(`:location`), + list(quote(`:file`), sprintf("%s/%s", srcfile$wd, srcfile$filename)), + list(quote(`:line`), srcref[[2]][[1]], srcref[[2]][[2]]-1), + list()))) + } + } else { + list() + } + } else { + list() + } +} -- 2.30.2