In the video the guy was able to insert functions and classes by pressing some buttons. How do I set up my Emacs to do that? Did he just use auto insert mode or something?
You can try yasnippet, skeletons or several other template mechanisms for Emacs.
As suvayu indicated, the guy in that video is mostly using various template mechanisms in Emacs (this is actually not that impressive). If you want your mind to really be blown, have a look at Marco Barringer's SLIME video. In it, he demos how to use the Common Lisp SLIME mode in Emacs. Along the way, he shows how an expert Emacs user effectively utilizes Emacs to write code. First, just watch the movie. Then, if you want to know more details about what he's doing, read Peter Christensen's transcript of the movie (I wrote a blog entry just after the movie came out with comments from a number of good lisp programmers who had seen the movie). Once you've seen the movie and can understand what is happening in it, attempt to adopt some of the techniques demonstrated in that video using your preferred programming language.
You can also look onto SRecode module in CEDET package - it allows to implement context-sensitive templates (for example, some are available only inside class, etc.), and there are some for elisp, c++, java, etc.
Related
While it is fun to customize, the Emacs has 100s of mode and there is lots of customization. I like to find popular choices, so it makes my life easier and I can spend time productively. It could be about hooks, registers, buffers, keybindings,bookmarks etc..
If such a thing does not exist, I am still happy to customize in my way.
Have a look at the Emacs Prelude.
A very popular compilation of popular default settings is the Emacs Starter Kit, originally developed by Phil Hagelberg, then by Eric Schulte and finally updated for emacs-24. It mentions:
The main advantage of this Emacs Starter Kit are
better default settings
inclusion of many useful libraries and configurations
"literate" customization embedded in Org-mode files
an organizational directory structure
git provides for version control, backup, and sharing
Then there are some specialized extensions of it:
the starter kit for social sciences
the emacs kicker
the emacs expert kick
For most popular "aha" settings, the Emacs NiftyTricks page from the emacs wiki has already been linked to in another question.
I don't know a single collection of settings, but Emacs nifty tricks can be a good starting place to pick up useful customizations and features you may not know.
It's not strictly customization, but this stackoverflow question list useful features of Emacs.
I personally advise:
Link - how to make Emacs settings compatible with modern conventions
Link - ergonomic keybinding scheme
There is also Emacs Prelude - a set of customization to make Emacs learning curve more gradual.
I also recommend going through Mastering Emacs - it has many of customizations, that may improve your productivity.
I tried the starter some time ago, but I found that I got better results by writing my own init.el so that I actually know what each line of cod e does. Emacs Fu is the best resource that I know, because it has blog posts about many different modes instead of just code: http://emacs-fu.blogspot.com/. And there is also sample .emacs based on the posts.
I think maintainer of Emacs rocks series ended up with a good .emacs settings and a useful start-up-kit for newbies to help them morph their finger habits quickly into Emacs'.
https://github.com/magnars/.emacs.d. The better-defaults package lives up to its title.
I have come accross vi-style keybindings for Emacs, but my past experience in mixing Lisp based config in .emacs file for enabling various modes etc., hasn't been very pleasant so far.
Read several articles on Emacs + Erlang, but is there something that might be slightly easier for folks familiar mostly with vi (and who are unfamiliar with Lisp)?
The entire set of possibilities (keybindings) is quite overwhelming. Is there a condensed key-map/shortcuts reference specially relevant for Erlang development?
Just use vi and a command line. There are numerous people doing that and it seems to work just fine for them. Even though I use Emacs, it is not the Emacs-erlang interaction I use. Rather I usually just have a separate Erlang shell and then I load modules in that shell with the l() command for interaction.
Answering your questions one by one:
Debugging in Erlang is funny. Firstly, if your program is kept functional you will find that you need much less debugging to figure out what the program does incorrectly because you can simply write small tests for each of the numerous functions to test its correctness. And you can add those into unit-test frameworks.
As soon as you add multiple processes to the mix you will find that traditional debugging doesn't work anymore anyway. The trick is then to trace and assert, and you will need to learn a way to read programs without running them and see where they go with a debugger.
That said, try to execute debugger:start() in an Erlang shell :) There are also the tracing systems and redbug, a 3rd party tool built on top of them (part of the eper suite).
Profiling can be done with one of the 3-4 profilers: cprof, eprof and fprof are all slightly different in scope and in how much impact they have on your program and if they can be run on a production system or not. I tend to use eprof and I have a knob in my program which will spawn an eprof and then attach it at program start.
Try appmon:start() in a shell.
The standard vi-way of browsing large code bases is to create tags-files so you can jump to the definition point of the thing-under-the-cursor. Emacs can do the same. I have a make tags target to create these files so I can easily make jumps around in the source code. When jumping you have a stack of the former jumps so you can return to the point you jumped from later on.
Finally there are tools like xref which can be worked to create call graphs and find odd things in the code. It will require some coding on your part, but it does provide you with the necessary tooling.
Viper mode provides Vi-style keybindings. That's probably the easiest way to start. Enabling a new mode in your .emacs is a pretty fundamental part of using Emacs, so it's a learning hurdle best cleared early!
The Emacs manual contains more detailed information about making individual changes to your keybindings.
You may find Xah's keybinding tutorial helpful, as it provides many examples.
I have never used Emacs before and the first time I tried it I was so repulsed by its interface which seemed not very user friendly . But since then I have heard a lot about it improving productivity and this has rekindled my interest . But is it true for the case of web development as well? for the likes of php,python,javascript/jquery etc . How good are the code completion features?
Please suggest some resources to get me started in the right direction.
I'm a bit of a religious user when it comes to Emacs so please take this with a few bags of salt. I'll try to state my reasons for using Emacs (including for web development).
Emacs' primary strength is it's extensibility and the fact that at it's core, it's a lisp interpreter with a bunch of primitive functions useful for text editing and display. This makes it "programmable". You can customise it almost endlessly.
This has spurred a number of libraries which do (common) things like code completion, source code browsing, test harness integration, refactoring tool integration, version control integration etc. If a developer working on a project is an Emacs user, it's not uncommon to see her adding something to her project just to get it to work well with Emacs. The extensibility has also spurred a number of less that conventional libraries like mail clients, web browsers, IRC clients, music players etc.
Many Emacs users keep most of their work (except for maybe their browsers) inside Emacs. This allows them to use the same keystrokes and high level techniques for everything that they use. I myself use it for my daily coding, for my email, as my PIM and a bunch of other things. I can for example, while working on my code, just write something like "TBD" as a comment somewhere and let the PIM part remember this as a TODO item next time I open the editor. I can also for example while coding simply switch to another "buffer" (the emacs term for windows) with an IRC client and ask questions I might have to other people who are online. This makes me quite productive and quick. Also, the keystrokes are almost the same on a large number of command line UNIX programs (like my shell etc.) which helps me do my work faster.
Another advantage is that Emacs is old. People have tweaked and polished it endlessly and still do. The result is a set of commands for editing that I didn't even know that I needed. Things like "capitalise word" to make the first letter of the word my cursor is on upper case sounds trivial but while you're editing, it's quite useful.
Being extensible, Emacs has "modes". These are environments for specific programming languages. Indentation rules, syntaxes, completion etc. will change depending on the mode you're in. There are modes for almost all modern languages and they provide substantial help while editing. You have things for javascript, php etc. which help you while coding in those languages. There are also web specific tools (e.g. Emacs can talk to MozRepl so that you can refresh you browser and things while editing). People write modes all the time for what they want and it's not too hard. I recently started using jekyll to maintain my blog and wrote a mode to make my life easier). The modes add functionality but at a base level are the same (e.g. same keys to delete a character, move forward by a sentence etc.). I like this because I don't have to learn a whole new set of keys and get used to them just to code in another language.
That being said, Emacs is a tool for a different kind of developer. Most hardcore Emacs users (and there are quite a few famous ones out there) don't use many IDE type features. They usually like just a window (Without toolbars, menu bars and all that) so that the real estate for code is maximum. If you're used to leaning on a feature heavy IDE to do your work, Emacs might not be the right tool for you (I think this is what Trey meant in his comment). If however, you want a programmers editor that stays out of the way and let's you get your job done with minimum hassle, it's something you should definitely try out.
Okay, resources. The first thing to do is to start up Emacs and type Ctrl-h t. This gives you a "hands on" tutorial you can use to learn the editor basics. Once you're done with that, you can read the fine manual at http://www.gnu.org/software/emacs/manual/html_node/emacs/index.html. Once you're happy with that, you can read the Emacs lisp tutorial and start extending and customising Emacs as per your wishes. The EmacsWiki is a great place for tips, tricks and docs as is the Emacs IRC channel.
All the best!
If you don't like the interface, it's not worth it.
The question isn't is it worth learning Emacs, it is do you want to learn the interface?
If you do, then it's worth it. If you don't, then it's not.
More concretely, I'll answer your broad question with a series of links you could have gotten from the Emacs wiki:
http://www.emacswiki.org/emacs/JavaDevelopmentEnvironment
http://www.emacswiki.org/emacs/NxhtmlMode
http://www.emacswiki.org/emacs/HtmlMode
http://www.emacswiki.org/emacs/MuMaMo
http://www.emacswiki.org/emacs/PhpMode
http://www.emacswiki.org/emacs/php-completion.el
http://www.emacswiki.org/emacs/php-mode-improved.el
http://www.emacswiki.org/emacs/JavaScriptMode
http://www.emacswiki.org/emacs/FlymakeJavaScript
http://www.emacswiki.org/emacs/PythonMode
http://www.emacswiki.org/emacs/PythonProgrammingInEmacs
http://www.emacswiki.org/emacs/CategoryProgrammerUtils
Yes, people like using Emacs for web development. The above is just a sampling of modes people have written and use on a daily basis.
Is it for you? I don't know.
Is it better than editor X? or IDE Y? Yes for some things, no for others.
The code completion features are great! (unless they're not) It depends on what you want, what languages you're talking about, etc. etc. etc.
People use vi, people use Emacs, people use Notepad, people use all sorts of text editors.
Note: asking vague questions leads to vague answers.
The ultimate web programming mode is arguably nxhtml mode. You might start by taking a look at it. You might also want to check out some rich preexisting Emacs configurations like the Emacs Starter Kit or the Emacs Dev Kit.
The PHP & Python modes in Emacs are not particularly great, but are fairly decent. The JavaScript mode is certainly great. Packages such as autocomplete mode provide good completion almost everywhere.
I'm certainly biased, but I think that if you do spend some time exploring Emacs you'll find out that it will boost your productivity.
As some other posters have eluded to, it all depends on what you want out of it. If you want to feel as good about the customizations you've been able to get working in emacs as you do about the actual code that you write, then sure.. Emacs is great ;)
(Before anyone jumps down my throat, emacs is by far my favorite editor for 'nix C/C++ editing, but that's not what the OP's looking for here ;))
In my crusade to find the most productive editor for PHP, Python, Javascript etc, my favorite thus far has been Komodo Edit. It features not only code completion, but jump-to-definition (as well as many other features that a full-featured IDE should have) and is really the closest thing to Visual Studio for OS scripting development that I've seen. Oh, and it's free.
Honestly, braces against the rotten fruit/vegetables that will surely be thrown my way I've recently become a fan of the NetBeans IDE for web development. Particularly when It comes to PHP.
But to answer you question: It's only worth it if it's worth it to you. Sorry, vague questions get vague answers. ;)
If you're using an existing IDE that can do web development, than use the IDE. If not Emacs is worthwhile to learn as the text editor to go to for text editing or for programming in language that do not have a good IDE.
I have a workflow where I use grep and other tools in a shell for searching in different projects even though my main editor is emacs. I usually work on bug fixing and minor development of source code that is often unknown to me so searching the code is important. The langages I mostly work in are php, ruby, java, perl and sometimes python.
Is there some common IDE extension in emacs that would enable me to have functionality like "goto definition" from multiple files that span all these languages? Are there some other modules that could be useful, either code browsing or indexed search?
If you want to work with lots of different languages, ctags is pretty flexible. See the EmacsWiki for instructions on integration of ctags.
Code browsing can mean a bunch of different things. The mode you mention of using grep implies to me you are looking for function definitions, or perhaps looking for uses of a particular function.
While CEDET supports all the languages you list (some with the ctags parser), starting fresh in a new source code area is something CEDEt isn't too good at until it has indexed the entire project for those tasks you listed. You can, however, use GNU Global or idutils. I think idutils supports more languages.
In CEDET, the `semantic-symref' and related commands will do a grep-like operation with grep, or global, or idutils (depending on what type of tag table you created.) Unlike grep style output, the symref output buffer shows which functions are using the command in question. You can then execute macros on the hits of the symbol you care about to do large refactoring operations.
CEDET also supports a tags like jump to function, though if you are already using something like ctags that works fine too. CEDET is better when it comes to handling polymorphism in some cases.
With CEDET, you can also get structured browsing via imenu, speedbar, and ECB (the emacs code browser). ECB is particularly good in that the methods buffer allows you to quickly navigate to different parts of a class. Particularly handy for classes where the pieces are spread around, like in C++. CEDET can even create cute UML diagrams of class inheritance structures which are connected to your code.
CEDET does take some learning, and some of the languages you list are not fully supported for all the tools, though the basic browsing discussed above should be ok.
etags-select (which you can get from ELPA) makes browsing your TAGS file nicer, in my experience, if you bind M-. to etags-select-find-tag.
As well as etags/ctags try running grep with M-x grep rather than in a shell, to get clickable links in Emacs rather than having to manually find the file and line matching the grep output.
For code browsing, you can also use M-x imenu-tree
Tags browsing, with dynamic completion, filtering (substring, regexp, fuzzy), cycling:
http://www.emacswiki.org/emacs/Icicles_-_Emacs_Tags_Enhancements
I'd like to take an existing application (written in OCaml) and create an Emacs "interface" for it (like, for example, the Emacs GDB mode). I would prefer to do this without writing a ton of Lisp code. In MVC terms, I'd like for the View to be Emacs, but for the Model and Controller to remain (primarily) OCaml.
Does anybody know of a way to write Emacs extensions in a language other than Lisp? This could either take the form of bindings to the Emacs extension API in some other language (e.g., making OCaml a first-class Emacs extension language) or an Emacs interaction mode where, for example, the extension has a pipe into which it can write Emacs Lisp expressions and read out result values.
http://www.emacswiki.org/cgi-bin/emacs-en?CategoryExtensionLanguage is a list of all non-Elisp extension languages you can use.
It does appear to be dynamic language centric.
http://common-lisp.net/project/slime/ is missing from that list, as it is not quite an extension language, but an Elisp-Common Lisp bridge. Its source code would show how to communicate back and forth over sockets.
A similar IDE for Erlang is Distel, at http://fresh.homeunix.net/~luke/distel/ (currently down) and https://github.com/massemanet/distel.
Good luck!
I don't know if this will work for your particular problem, but I have been doing something similar using the shell-command-to-string function:
(shell-command-to-string
"bash -c \"script-to-exec args\"")
So for example, we have existing scripts written in python which will mangle a file, so the above lets me invoke the script via emacs lisp.
A quick google search found this page describing a system to write extensions in Python, so it seems feasible to do what you want... you will just have to see if anyone has written a similar framework for OCaml.
Some Extension Api is now possible with the incoming emacs 25.1 and dynamic modules
A Library, emacs-ffi offer a foreign function interface based on libffi.
Check out complete documentation on the README.
Try PyMacs, which allows extending Emacs in Python.
edit: updated link.
From the statically typed languages side, there is something that looks quite performant and well featured for Haskell:
https://github.com/knupfer/haskell-emacs
there is also probably something useful for Scala to be reused from the Ensime project (has a bridge for both Emacs and Vim):
https://github.com/ensime/ensime-server
Furthermore, a quick google search revealed another potential candidate for extending Emacs with a classic FP language, OCaml; the project has a lot of .ml source files so there's got to be an Emacs-OCaml bridge somewhere:
https://github.com/the-lambda-church/merlin
There is no "Extension API". Emacs Lisp is way in there, and it ain't moving.
You can run Emacs commands from your other process. Have a look at Gnuserv.
There are plenty of applications where Emacs is the View for a Model/Controller in a separate process. The Emacs GDB interface is a good example. I'm not sure of a simpler example, maybe sql-postgresql?