Emacs project management for Scala - scala

I would like to ask if any of you have any experience {and,or} could point me to a project management extension for Emacs that works well with {Scala,Ensime,SBT}. It would also be amazing if it didn't require too much hacking. I did some scheme in the past but I have little experience with the Emacs platform.
Basically, by project management I mean mainly the ability to 'tie files into project' and then search among them (and only among them).
Thanks for taking the time to read this and answer!

I really hate that you can't setup projects out of the box, though.
Just set up the project with sbt or maven and import it with ensime.
Essentially, what i would want is to be able to flex-find files in the project
"flex-find" is not English, so I don't really know what you mean. But what is wrong with find (the command line tool)?

With ensime you can load your project and then search for a type or method by name. The key sequence is C-c C-v v. This allows you to, for example, jump directly to a class definition.

The package projectile has a bunch of generic project-level features, such as running commands in the project root folder, grepping, creating TAGS files etc.
I'm a relatively new user of it, so I can't say exactly how big a difference it makes, but it seems like a worthwhile addition to your tool belt.

Related

Sharing common helper scripts among projects in VSCode

I have a few utility functions, snippets and scratches that I want to be able to use in every project.
Currently I have the following setup for Clojure projects and Intellij IDEA/Cursive:
I have a user profile defined in .lein, where I have source-paths pointing to
when I sync and run REPL for project in IDEA/Cursive, I check that :user profile is selected (it is the default)
Cursive shows both project files and common files (i.e. scratches folder) in project pane
I can edit and eval in REPL real project files and my local helers/scratchpads seamlessly.
Is there a way to achieve this behaviour in VSCode?
Notes:
My clojure setup in Cursive is for illustration purposes only. I would like to find a way to get similar feature in other scripting languages (i.e. python, groovy). So ideally I don't want to use leiningen for that, but rather find a generic way to add common source folder to VS code Explorer pane.
I know that with multi-root workspaces I can achieve what I want, but it must be done manually per project. It would be much better if my folder with common utils was added to every workspace automatically. Something like a default workspace template would solve this, but I couldn't find anything similar. Am I missing something?

Eclipse Workspaces: What for and why?

I have seen, read and thought of different ways of using Workspaces (per project, per application (multi-asseted or not), per program language, per target (web-development, plugins,..), and so on) and I am still doubting what the best approach is.
Can anyone give a detailed, but not a page long insight into this?
This involves a lot of sub-questions, so to speak, and I don't know all the specific sub-questions I should ask, as I am sure I don't know all aspects of Eclipse (and Workspaces), but I'll try to give an example of what I am looking for:
What for?
What did the Eclipse development team expect it to be used for?
What do other/most people think?
What do you think?
... ?
Why?
Are there configuration conflicts vs. sharing merits?
Any filespace reasons?
Performance?
... ?
I am speaking of the minimum use-case for a developer that uses different languages and protocols, not necessarily all of them in one project (E.g. Php, Javascript and XML for some projects, C# for others, Java and SQL for still others, etc..)
Edit 2012-11-27: Don't get me wrong. I don't doubt the use of
Workspaces, I just want to use it as it is meant to be or otherwise if
anyone would think it better. So "what for?" means: What's the best use? And
"why?" actually targets on the "what for?", in other words: tell me the reasons
for your answer.
I'll provide you with my vision of somebody who feels very uncomfortable in the Java world, which I assume is also your case.
What it is
A workspace is a concept of grouping together:
a set of (somehow) related projects
some configuration pertaining to all these projects
some settings for Eclipse itself
This happens by creating a directory and putting inside it (you don't have to do it, it's done for you) files that manage to tell Eclipse these information. All you have to do explicitly is to select the folder where these files will be placed. And this folder doesn't need to be the same where you put your source code - preferentially it won't be.
Exploring each item above:
a set of (somehow) related projects
Eclipse seems to always be opened in association with a particular workspace, i.e., if you are in a workspace A and decide to switch to workspace B (File > Switch Workspaces), Eclipse will close itself and reopen. All projects that were associated with workspace A (and were appearing in the Project Explorer) won't appear anymore and projects associated with workspace B will now appear. So it seems that a project, to be open in Eclipse, MUST be associated to a workspace.
Notice that this doesn't mean that the project source code must be inside the workspace. The workspace will, somehow, have a relation to the physical path of your projects in your disk (anybody knows how? I've looked inside the workspace searching for some file pointing to the projects paths, without success).
This way, a project can be inside more than 1 workspace at a time. So it seems good to keep your workspace and your source code separated.
some configuration pertaining to all these projects
I heard that something, like the Java compiler version (like 1.7, e.g - I don't know if 'version' is the word here), is a workspace-level configuration. If you have several projects inside your workspace, and compile them inside of Eclipse, all of them will be compiled with the same Java compiler.
some settings for Eclipse itself
Some things like your key bindings are stored at a workspace-level, also. So, if you define that ctrl+tab will switch tabs in a smart way (not stacking them), this will only be bound to your current workspace. If you want to use the same key binding in another workspace (and I think you want!), it seems that you have to export/import them between workspaces (if that's true, this IDE was built over some really strange premises). Here is a link on this.
It also seems that workspaces are not necessarily compatible between different Eclipse versions. This article suggests that you name your workspaces containing the name of the Eclipse version.
And, more important, once you pick a folder to be your workspace, don't touch any file inside there or you are in for some trouble.
How I think is a good way to use it
(actually, as I'm writing this, I don't know how to use this in a good way, that's why I was looking for an answer – that I'm trying to assemble here)
Create a folder for your projects:
/projects
Create a folder for each project and group the projects' sub-projects inside of it:
/projects/proj1/subproj1_1
/projects/proj1/subproj1_2
/projects/proj2/subproj2_1
Create a separate folder for your workspaces:
/eclipse-workspaces
Create workspaces for your projects:
/eclipse-workspaces/proj1
/eclipse-workspaces/proj2
The whole point of a workspace is to group a set of related projects together that usually make up an application. The workspace framework comes down to the eclipse.core.resources plugin and it naturally by design makes sense.
Projects have natures, builders are attached to specific projects and as you change resources in one project you can see in real time compile or other issues in projects that are in the same workspace. So the strategy I suggest is have different workspaces for different projects you work on but without a workspace in eclipse there would be no concept of a collection of projects and configurations and after all it's an IDE tool.
If that does not make sense ask how Net Beans or Visual Studio addresses this? It's the same theme. Maven is a good example, checking out a group of related maven projects into a workspace lets you develop and see errors in real time. If not a workspace what else would you suggest? An RCP application can be a different beast depending on what its used for but in the true IDE sense I don't know what would be a better solution than a workspace or context of projects. Just my thoughts. - Duncan
Basically the scope of workspace(s) is divided in two points.
First point (and primary) is the eclipse it self and is related with the settings and metadata configurations (plugin ctr). Each time you create a project, eclipse collects all the configurations and stores them on that workspace and if somehow in the same workspace a conflicting project is present you might loose some functionality or even stability of eclipse it self.
And second (secondary) the point of development strategy one can adopt.
Once the primary scope is met (and mastered) and there's need for further adjustments regarding project relations (as libraries, perspectives ctr) then initiate separate workspace(s) could be appropriate based on development habits or possible language/frameworks "behaviors".
DLTK for examples is a beast that should be contained in a separate cage.
Lots of complains at forums for it stopped working (properly or not at all) and suggested solution was to clean the settings of the equivalent plugin from the current workspace.
Personally, I found myself lean more to language distinction when it comes to separate workspaces which is relevant to known issues that comes with the current state of the plugins are used. Preferably I keep them in the minimum numbers as this is leads to less frustration when the projects are become... plenty and version control is not the only version you keep your projects.
Finally, loading speed and performance is an issue that might come up if lots of (unnecessary) plugins are loaded due to presents of irrelevant projects.
Bottom line; there is no one solution to every one, no master blue print that solves the issue. It's something that grows with experience,
Less is more though!
Although I've used Eclipse for years, this "answer" is only conjecture (which I'm going to try tonight). If it gets down-voted out of existence, then obviously I'm wrong.
Oracle relies on CMake to generate a Visual Studio "Solution" for their MySQL Connector C source code. Within the Solution are "Projects" that can be compiled individually or collectively (by the Solution). Each Project has its own makefile, compiling its portion of the Solution with settings that are different than the other Projects.
Similarly, I'm hoping an Eclipse Workspace can hold my related makefile Projects (Eclipse), with a master Project whose dependencies compile the various unique-makefile Projects as pre-requesites to building its "Solution". (My folder structure would be as #Rafael describes).
So I'm hoping a good way to use Workspaces is to emulate Visual Studio's ability to combine dissimilar Projects into a Solution.
It's just a feature for structuring projects.
Obviously Eclipse designers tried to avoid having global settings for Eclipse and decided to put them into workspace.
Each Eclipse app depends on each workspace settings.
Is it a good decision? I think it's not so.
It lacks flexibility. It was naive to expect that global settings can be avoided.
It doesn't allow you to have single projects (it can be a surprise for Eclipse designers but it happens quite often).
But it still works.
Many people use it. Sometimes they suffer but more frequently everything is ok.

Generating a list of include directories, and project files from a CMakeLists.txt

I'd like to use emacs to work on my project that is built using CMake, while this generally works fine, I'd like to implement better project management commands. Is there a simple way to generate some sort of file that acts as a listing of the project files.
It seems that the best way may just be some set of CMake macros that do a custom write to a file, is there perhaps any better solutions?
I have no direct experience with CMake. But there are a couple of approaches to solving this.
The canonical way is to generate a TAGS table as a part of your buid process. You will get symbol completion/navigation on top of easy access to file-list. And ctags is hyper fast. I'll leave you to google how to do that specifically, hint: wiki.
Alternatively, you can get a Emacs project management package like EDE, eproject, mk-project that defines the concept of a project. See wiki.
You can look onto CEDET mailing list - CMake support was discussed not so long time ago, and at least one person is actively working on CMake support in EDE (CEDET's project management)

Time to develop an option in Eclipse to modify a Java file source

I'm evaluating the possibility of developing an Eclipse plugin to modify the source code of some Java files.
The Eclipse plugin should:
add one menu option or context menu option to launch the modification process.
add a key binding
only alter the UI in that way when an editor has been open on a Java file.
the modification process would not open a dialog, or maybe, a very simple one.
the modification process would traverse the AST of the Java file and would modify it.
Considering that we have no experience with Eclipse plugins and we need spend time in reading docs, how much time do you estimate in developing that plugin?
Thanks in advance.
It's really not that difficult at all... I had students in my design patterns class doing it for an assignment (adding/removing javabean getters and setters)
See http://help.eclipse.org/ganymede/topic/org.eclipse.jdt.doc.isv/guide/jdt_api_manip.htm
[EDIT: added the following article reference]
And a great article on it at http://www.eclipse.org/articles/article.php?file=Article-JavaCodeManipulation_AST/index.html (from 2006 -- there may be a few API changes since)
Yes, writing plugins takes a little getting used to, but so does any API.
And you can modify the AST -- see the page I reference above.
(I should note that the above link is from the eclipse help, which can also be accessed via Help->Help Contents inside Eclipse -- there's a lot of good info in there, but it's just a starting point)
You'll probably spend quite some time cursing the complexity of the eclipse plugin system. There are some example plugin development projects that can be very helpful if they cover the area you're working in.
I'd say you're looking at 2-4 days of work, spent mainly getting familiar with the platform - someone with a lot of experience writing eclipse plugins would probably take no more than an hour.
However, your step 5 could be tricky. I don't know how easy it is to access and change the Java AST; my experience is based on developing an editor plugin for an exotic file format rather than Java code.
Well, the four first points are easy to achieve, even by monkey coders that look at the eclipse PDE documentation shipped with Eclipse. These can be achieve in 1 day of work, maybe 2.
The hardest point is really the fifth one and the kind of modification you expect to do. Acting directly on the editor content is simple, accessing the editor internal AST and modifying it is really a bigger challenge and I doubt that it could be achieve in less than a week by unexperimented people (it can take longer, depending of what kind of modification you want to apply).

Can Emacs support projects?

Can Emacs support the concept of projects? That would be where several configuration options varies depending on what project you are working on.
Yes, please look to the EDE package from CEDET library
Check out the project-local-variables plugin. I haven't used it personally, but I've seen it mentioned in the Rinari-mode documentation for scoping down a find-file-in-project function.
You generally wouldn't expect emacs to know about differences in build requirements---you let the build system (make or whatever) take care of that. To handle different coding standard define local yourproject.el files to set variables, load and unload local modes, etc... (use M-x load-file to run it).
To be pedantic, Emacs can support anything, being as it's a Lisp language runtime which so happens to have an editor on top of it.
To be specific, some addons for Emacs support Projects, such as the JDEE.
Well, as you can see there are several packages to do this.
You might like this approach:
http://blog.jrock.us/articles/eproject.pod
I just read it today.
Dude, as mentioned in another answer, EMACS can do anything. That said, let's expand a little on what a "project" means in this context. In most IDE's, like Eclipse, Netbeans, Visual Studio, or Xcode, "project" means two things: a file layout for the pieces that belong together, and instructions to the build system to build the thing composed of those pieces.
In EMACS, you have complete control of these things, but how they work together is dependent on both the target environment -- Lisp, Java, C/C++ and so on. Lisp is supported by SLIME, Java by the JDEE, C/C++ by the built in modes and a bunch of conventions; version control is also built in if you want to use it.
In most cases, the build details don't really affect the editor itself much, but you can specialize the behavior for specific files using either modelines, or local variables. JDEE has a specific "project" notion built in.
What languages and environments are you trying to work with?