From 24bb738d87a1636b9b86850e14c59b608fe61fb9 Mon Sep 17 00:00:00 2001
From: Christophe Rhodes <csr21@cantab.net>
Date: Mon, 23 Apr 2012 11:33:44 +0100
Subject: [PATCH] fix bug #21

%in% needs a `vector' first argument, so make it so, listifying
anything that isn't already a vector.  (Note: there seem to be plenty
of non-vector first arguments that work, such as
as.Date("2012-01-01"), which returns FALSE to is.vector() -- but the new
code seems to get that right anyway, based on very limited testing.
---
 BUGS.org | 2 +-
 swank.R  | 9 ++++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/BUGS.org b/BUGS.org
index 7132a71..3976058 100644
--- a/BUGS.org
+++ b/BUGS.org
@@ -74,7 +74,7 @@
   I'm not sure what else that does.
 * RESOLVED #20 closing the connection causes infinite R errors    :IMPORTANT:
   reported by "Philipp Marek" <philipp@marek.priv.at> by private mail.
-* OPEN #21 inspecting an environment causes error in match()          :MINOR:
+* RESOLVED #21 inspecting an environment causes error in match()      :MINOR:
   reported by "Philipp Marek" <philipp@marek.priv.at> by private mail.
 
   To reproduce, C-c I globalenv() RET, or hit RET on environment
diff --git a/swank.R b/swank.R
index 2031184..d91c35f 100644
--- a/swank.R
+++ b/swank.R
@@ -601,12 +601,19 @@ resetInspector <- function(slimeConnection) {
 }
 
 inspectObject <- function(slimeConnection, object) {
+  vectorify <- function(x) {
+    if(is.vector(x)) {
+      x
+    } else {
+      list(x)
+    }
+  }
   previous <- slimeConnection$istate
   slimeConnection$istate <- new.env()
   slimeConnection$istate$object <- object
   slimeConnection$istate$previous <- previous
   slimeConnection$istate$content <- emacsInspect(object)
-  if(!(object %in% slimeConnection$inspectorHistory)) {
+  if(!(vectorify(object) %in% slimeConnection$inspectorHistory)) {
     slimeConnection$inspectorHistory <- c(slimeConnection$inspectorHistory, object)
   }
   if(!is.null(slimeConnection$istate$previous)) {
-- 
2.39.5