I'm not sure if this is expected or a bug, but after running (clojure.tools.namespace.repl/refresh-all) the clojure.repl namespace is lost.
nREPL server started on port 61579 on host 127.0.0.1 nrepl://127.0.0.1:61579
REPL-y 0.3.5, nREPL 0.2.7
Clojure 1.6.0
testbed.core=> (doc map)
-------------------------
clojure.core/map
([f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls])
Returns a lazy...
nil
testbed.core=> (require 'clojure.tools.namespace.repl)
nil
testbed.core=> (clojure.tools.namespace.repl/refresh-all)
:reloading (testbed.core testbed.core-test)
:ok
testbed.core=> (doc map)
CompilerException java.lang.RuntimeException: Unable to resolve symbol: doc in this context, compiling:(/private/var/folders/xs/jbvb_r6j07q8xtclwlcbm21h0000gn/T/form-init6764593924445976503.clj:1:1)
testbed.core=>
My project.clj is very simple:
(defproject testbed "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.6.0"]]
:main ^:skip-aot testbed.core
:target-path "target/%s"
:profiles {:uberjar {:aot :all}
:dev {:dependencies [[org.clojure/tools.namespace "0.2.10"]]}})
Is there a simple way to avoid this? Particular while running Emacs/CIDER?
I remember having this issue. Although it's been a while, I recall getting around this by setting up my lein project to start the repl in namespace user and import the other namespaces - rather than starting out in the project namespace (defined by :main).
So I added :repl-options {:init-ns user} to my project.clj and also created a project user.clj - that ensures that clojure.repl functions I need are always available - as described in Stuart Sierra's post "My Clojure Workflow, Reloaded"
Session:
user=> (doc +)
-------------------------
clojure.core/+
([] [x] [x y] [x y & more])
Returns the sum of nums. (+) returns 0. Does not auto-promote
longs, will throw on overflow. See also: +'
nil
user=> (clojure.tools.namespace.repl/refresh-all)
(...namespaces...)
user=> (doc +)
-------------------------
clojure.core/+
([] [x] [x y] [x y & more])
Returns the sum of nums. (+) returns 0. Does not auto-promote
longs, will throw on overflow. See also: +'
nil
This is a work-around and not a real fix or explanation of the behavior. Another approach could be to ensure
clojure.tools.namespace.repl/refresh-all works by destroying the current in memory version of a namespace before loading the new one. Since the doc function is inserted by the REPL on startup and not defined in your source file, it is lost on reload.
You can use the functions disable-unload! and disable-reload! in clojure.tools.namespace.repl to prevent refresh from automatically un/reloading namespaces. nREPL inserts helper functions like doc in the initial namespace which is by default the main namespace of you application. You can make sure these functions are inserted elsewhere by setting an alternative initial namespace in your Leiningen profile.
I also recommend creating an actual source file for the namespace that contains helper functions for use at the REPL. You can find a description on how to do so in one of my other answers.
An example user profile setup can found on my Github.
Related
I am testing out SublimeText auto-complete using JEDI package and one problem I am having is unrequired parameters are auto-filling function/method calls:
For example in Flask:
I can just call the function as such:
app.run(),
but JEDI-Autocomplete is doing something like this:
app.run(host= , port=..., debug=..., load_dotenv=...)
I can't figure out how to clear the parameters as it's not needed in this case.
Same problem with:
app = Flask(__name__)
Instead autocomplete is automatically filling in unrequired parameters and seemingly forcing me to add value to each argument.
Searching the Sublime Text 3's SublimeJEDI repo (issue #290 - open() autocompletes all args when in required mode) seems to suggests that there's an option to control autocomplete aggressiveness:
"auto_complete_function_params": "all",
In your preference settings (either user preferences or syntax preferences).
From their README.md:
Function parameters completion has 3 different behaviors:
Insert all function arguments on autocomplete:
# complete result
func(a, b, c, d=True, e=1, f=None)
# sublime_jedi.sublime-settings
{
"auto_complete_function_params": "all"
}
Insert only required arguments that don't have default value (default behavior):
# complete result
func(a, b, c)
# sublime_jedi.sublime-settings
{
"auto_complete_function_params": "required"
}
Do not insert any arguments:
# complete result
func()
# sublime_jedi.sublime-settings
{
"auto_complete_function_params": ""
}
More info about auto_complete_function_params
You may experiment with those options to see what fits you better.
Turning auto_complete off and using SublimeJedi: ShowDocstring (defaults to Ctrl+Alt+D) when the cursor is after the function name fixes the issue for me.
You can also hover over the function name or use SublimeJedi: Show Signature.
I am a student who begin to study SHOP2 from China.
My teacher told me to run JSHOP2 in Eclipse.Now I can run original zenotravel problem and generate GUI and plans.Likewise, I want to put other domain and problems to SHOP2 and produce plans.
But the problem is that I don't know how to compile them and My teacher only asked me to run the the main function in Internaldomain but it can't succeed.Follow is the original code:
public static void main(String[] args) throws Exception
{
//compile();
// compile(args);
//-- run the planning algorithm
run(args);
}
This code can run zenotravel.Then I put domain and problems named pfile1 and
tdepots respectively into SHOP2 folder.Change the codes to:
{
compile(domaintdepots);
// compile(args);
//-- run the planning algorithm
run(args);
}
It warns "domainpdfiles cannot be resolved to a variable".
Or
//--compile();
compile(args);
//-- run the planning algorithm
//run(args);
It turns out:
"Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at JSHOP2.InternalDomain.compile(InternalDomain.java:748)
at JSHOP2.InternalDomain.main(InternalDomain.java:720)"
720 is main funcition above.And 748 is compile function:
public static void compile(String[] args) throws Exception
{
//-- The number of solution plans to be returned.
int planNo = -1;
//-- Handle the number of solution plans the user wants to be returned.
if (args.length == 2 || args[0].substring(0, 2).equals("-r")) {
if (args[0].equals("-r"))
planNo = 1;
else if (args[0].equals("-ra"))
planNo = Integer.MAX_VALUE;
else try {
planNo = Integer.parseInt(args[0].substring(2));
} catch (NumberFormatException e) {
}
}
Finally,according to the advice of the friend,I put the two pddls into src folder and use “java Jshop2.InternalDomain domaintdepots”in CMD commad but an error appeared:"the main class Interdomain can't be found or loaded".But I have set the class path accurately and the Zenotravel planning can run.So how
and where can I use the command ?
And what is written in the bracket"compile()" in Eclipse?
I am also not familiar with JAVA so it's better if there is concrete instruction.Thanks a lot.
Please describe what are you trying to build, what is it supposed to do, what is the expected end result.
If you do have a valid PDDL domain and problem file, you could try to load them into the online http://editor.planning.domains/ editor using the File > Load menu. Then press the Solve button and confirm which of the file is the domain and which is problem. If the PDDL model is valid (and the underlying solver can handle the requirements), you will get a plan back.
If you are trying to build a software solution that needs a PDDL-based planning engine as one of its component, perhaps you could use one of the available implementations: https://nergmada.github.io/pddl-reference/guide/whatisplanner.html#list-of-planners
If you are trying to build your own planning engine in Java using the Eclipse IDE, you probably need a Java-based PDDL parser. Here is a tutorial, how to use pddl4j for that purpose:
https://github.com/pellierd/pddl4j/wiki/A-tutorial-to-develop-your-own-planner
If you need to use Jshop2 in particular, it looks from their documentation (http://www.cs.umd.edu/projects/shop/description.html) that you need to indeed compile the domain and problem PDDL into Java code using following commands:
java JSHOP2.InternalDomain domainFileName
java JSHOP2.InternalDomain -r problemFileName
Edited on June 19th
Java package names (e.g. JSHOP2) and class names (InternalDomain) are case sensitive, so make sure you type them as per the documentation. That is probably why you are getting the "main class not found error".
It is difficult to say what the lines numbers 748 and 720 exactly correspond to, because in the GitHub repo https://github.com/mas-group/jshop2/blob/master/src/JSHOP2/InternalDomain.java the code is different from yours. Can you indicate in your questions which lines those are exactly?
The make file shows how to execute an out-of-the-box example in the distribution:
cd examples\blocks
java JSHOP2.InternalDomain blocks
java JSHOP2.InternalDomain -r problem300
Does that work for you?
There is a suitable method in the sbt.Exctracted to add the TaskKey to the current state. Assume I have inState: State:
val key1 = TaskKey[String]("key1")
Project.extract(inState).append(Seq(key1 := "key1 value"), inState)
I have faced with the strange behavior when I do it twice. I got the exception in the following example:
val key1 = TaskKey[String]("key1")
val key2 = TaskKey[String]("key2")
val st1: State = Project.extract(inState).append(Seq(key1 := "key1 value"), inState)
val st2: State = Project.extract(st1).append(Seq(key2 := "key2 value"), st1)
Project.extract(st2).runTask(key1, st2)
leads to:
java.lang.RuntimeException: */*:key1 is undefined.
The question is - why does it work like this? Is it possible to add several TaskKeys while executing the particular task by several calls to sbt.Extracted.append?
The example sbt project is sbt.Extracted append-example, to reproduce the issue just run sbt fooCmd
Josh Suereth posted the answer to sbt-dev mail list. Quote:
The append function is pretty dirty/low-level. This is probably a bug in its implementation (or the lack of documentation), but it blows away any other appended setting when used.
What you want to do, (I think) is append into the current "Session" so things will stick around and the user can remove what you've done via "sesison clear" command.
Additonally, the settings you're passing are in "raw" or "fully qualified" form. If you'd for the setting you write to work exactly the same as it would from a build.sbt file, you need to transform it first, so the Scopes match the current project, etc.
We provide a utility in sbt-server that makes it a bit easier to append settings into the current session:
https://github.com/sbt/sbt-remote-control/blob/master/server/src/main/scala/sbt/server/SettingUtil.scala#L11-L29
I have tested the proposed solution and that works like a charm.
Pretend I have an emacs window open and it is split horizontally into three buffers:
===== BUFFER1.cpp ======
#include "CommonTypeDefs.h"
namespace NS1 {
...
void someFunction( void ) {
MyClassHandle mh = getMyClassHandle(); // getMyClassHandle(): returns a MyClassHandle
mh-> // SEMANTIC does not parse
...
-
===== CommonTypeDefs.h ======
...
typedef class NS2::MyClass* MyClassHandle
...
-
===== BUFFER2.h ======
namespace NS2 {
...
class MyClass {
// things in here
...
-
I do not see why this extra layer (in this case a common header file full of typedefs) is not picking up the possible completions.
-
I have also noticed that when Semantic works I get shown the line of the class definition, eg:
-
===== BUFFER1.h ======
SomeDe[]finedClass* sdc = getSomeDefinedClassPtr();
-
If I have the cursor over the type that is sdc (see the square braces), the Emacs minibuffer will say something
like:
-
SomeDefinedClass.h: class SomeDefinedClass {}
-
This means that I know Semantic will be able to parse the symbos in SomeDefinedClass. Everything is good when this happens because there is no typedef involved. But, in the case where things don't work:
-
===== BUFFER1.h ======
SomeDe[]finedClassHandle sdch = getSomeDefinedClassHandle();
-
Again, I have the cursor where the square brackets are but this time the minibuffer says:
-
CommonTypeDefs.h: typedef* SomeDefinedClassHandle {}
-
I guess this makes sense, because firstly this type is a typedef, but it seems like Semantic stops there - rather than then saying, Okay: I am a typedef, but now I need to look at symbols for the typedef. Hence, I do not get completions.
-
I have confirmed that everything has been parsed because I have -decoration-mode on. Also, semantic is working for other things, it just doesn't seem to be able to handle these handles.
There is no problem with missing includes either as there are no compilation errors. In this project there are a number of subsystems, hence why I have included different directory to the system-c-dependency-include* path and these all work fine.
Why is this not working?
Emacs 24.3 / Windows / CEDET (around the 26th Sept 2014 bzr release)
Ipython 0.13.1 can print the source of an object from python library,
such as, os.path.abspath??
But I can't print the source code of any object I defined through %ed magic in ipython,
Is anything wrong I did?
such as, I define a class Name through %ed magic:
%ed
then
class Name(object):
"""docstring for Name"""
name = 'hong'
def __init__(self, arg):
super(Name, self).__init__()
self.arg = arg
def pri():
print 'class Name'
when back to ipython, I can't see the source code of class Name:
In [59]: Name??
Type: type
String Form:<class '__main__.Name'>
Docstring: docstring for Name
Constructor information:
Definition:Name(self, arg)
Is this the bug of IPython?
--Edits after OP mentioned this is seen in ipython iteself.
Is there any error message you get after typying %ed myfunc? Pasting that might help others find the issue.
---update:
I also get a short version of the source code when I try Name??, but Name.pri?? gives me the full source code of the pri() member function of the Name class. So ipython may have some convention to not give full source code of classes.
Here is my interaction:
In [2]: Name??
Type: type
String Form:<class '__main__.Name'>
Docstring: docstring for Name
Constructor information:
Definition:Name(self, arg)
In [3]: Name.pri??
Type: instancemethod
String Form:<unbound method Name.pri>
File: /tmp/ipython_edit_8YOfN9.py
Definition: Name.pri()
Source:
def pri():
print 'class Name'
In [4]:
Recent versions of IPython (not sure of the exact version number) actually do show the source:
IPython 0.13 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: %ed
IPython will make a temporary file named: /var/folders/88/zgy_z51x1fn2mp_7vmkj3phm0000gn/T/ipython_edit_g9xYY4.py
Editing... done. Executing edited code...
Out[1]: 'def f(a):\n\treturn a + 3\n'
In [2]: f(4)
Out[2]: 7
In [3]: f??
Type: function
String Form:<function f at 0x18ddb30>
File: /var/folders/88/zgy_z51x1fn2mp_7vmkj3phm0000gn/T/ipython_edit_g9xYY4.py
Definition: f(a)
Source:
def f(a):
return a + 3
There are two other ways to get the source. One is if you can go back to the line where you called %ed, the return value should be the source code (here, this is Out[1], so you could do print Out[1]). Another is to call %ed f — this is supposed to load up the current definition of f into the editor, and allow you to edit the definition.