Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Using 'ns instead of 'in-ns to change namespace

Fix Issue 484:	creating a new namespace and sending an defn expression from it to REPL results in CompilerException
  • Loading branch information...
commit 7121cc9b48008302f931c3232b06fd0e9f214a6c 1 parent b50c4e9
@laurentpetit authored
View
4 ccw.branding/html/reference/preferences/editor.html
@@ -68,12 +68,12 @@
</tr>
<tr>
<td valign="top">
- On file launch, switch the REPL to the file namespace (calling 'in-ns)
+ On file launch, switch the REPL to the file namespace (calling 'ns)
</td>
<td valign="top">
<p>
When a Clojure file is loaded into the REPL, this option will automatically
- call the <strong>in-ns</strong> function to allow direct calling of functions
+ call the <strong>ns</strong> macro to allow direct calling of functions
from the file just loaded, without the need to prefix the functions with the
namespace prefix.
</p>
View
2  ccw.core/src/java/ccw/editors/clojure/EvaluateTopLevelSExpressionAction.java
@@ -44,7 +44,7 @@ public void run() {
String editorNamespace = editor.findDeclaringNamespace();
String replNamespace = repl.getCurrentNamespace();
if (editorNamespace != null && !editorNamespace.equals(replNamespace)) {
- textToEvaluate = "(in-ns '" + editorNamespace + ")\n" + textToEvaluate + "\n(in-ns '" + replNamespace + ")";
+ textToEvaluate = "(clojure.core/ns " + editorNamespace + ")\n" + textToEvaluate + "\n(clojure.core/ns " + replNamespace + ")";
}
EvaluateTextUtil.evaluateText(repl, textToEvaluate, isReplExplicitLoggingMode());
View
3  ccw.core/src/java/ccw/editors/clojure/SwitchNamespaceAction.java
@@ -6,7 +6,6 @@
import org.eclipse.jface.action.Action;
import ccw.CCWPlugin;
-import ccw.preferences.PreferenceConstants;
import ccw.repl.Actions;
import ccw.repl.REPLView;
@@ -40,7 +39,7 @@ public static void run(REPLView repl, ClojureEditor editor, boolean activateREPL
CCWPlugin.logError("Could not switch ns to: " + ns);
} else {
EvaluateTextUtil.evaluateText(repl, String.format(";; Switching to %s namespace", ns), isReplExplicitLoggingMode());
- EvaluateTextUtil.evaluateText(repl, String.format("(in-ns '%s)", ns), false);
+ EvaluateTextUtil.evaluateText(repl, String.format("(clojure.core/ns %s)", ns), false);
Actions.ShowActiveREPL.execute(activateREPL);
}
}
View
2  ccw.core/src/java/ccw/preferences/messages.properties
@@ -4,7 +4,7 @@ ClojureREPLPreferencePage_Description=REPL settings for Clojure development:
ClojurePreferencePage_description=Expand the tree to edit preferences for a specific feature.
ClojurePreferencePage_displayed_tab_width=Displayed tab width:
ClojurePreferencePage_highlight_matching_brackets=Highlight &matching brackets
-ClojurePreferencePage_switch_to_ns_on_repl_startup=On file launch, switch the Repl to the file namespace (calling 'in-ns)
+ClojurePreferencePage_switch_to_ns_on_repl_startup=On file launch, switch the Repl to the file namespace (calling 'ns)
ClojurePreferencePage_use_strict_structural_editing_mode_by_default=Start editors in strict/paredit Edit mode
ClojurePreferencePage_show_rainbow_parens_by_default=Start editors with rainbow parens
ClojurePreferencePage_use_tab_for_reindenting_line=[Tab] reindents the current line
View
7 ccw.core/src/java/ccw/repl/REPLView.java
@@ -151,6 +151,7 @@ private static void releaseSecondaryId (String id) {
}
private static final Keyword inputExprLogType = Keyword.intern("in-expr");
+ private static final Keyword errLogType = Keyword.intern("err");
private static final Pattern boostIndent = Pattern.compile("^", Pattern.MULTILINE);
// TODO would like to eliminate separate log view, but:
@@ -251,7 +252,11 @@ public void evalExpression (String s, boolean userInput, boolean logExpression)
try {
if (s.trim().length() > 0) {
if (logExpression) log.invoke(this, logPanel, s, inputExprLogType);
- evalExpression.invoke(s, userInput);
+ if (evalExpression == null) {
+ log.invoke(this, logPanel, "Invalid REPL", errLogType);
+ } else {
+ evalExpression.invoke(s, userInput);
+ }
}
} catch (Exception e) {
CCWPlugin.logError(e);
Please sign in to comment.
Something went wrong with that request. Please try again.