tmallen has asked for the wisdom of the Perl Monks concerning the following question:

This is a bit of a general question, but I figure there are probably few developers that use the wise, aged Vim and Emacs more than Perl coders. Vim has always come easily to me, but I keep reading that Emacs can handle code more intelligently, etc. I'm a Mac TextMate user, so the extensive and purportedly easy customization offered by Emacs is very appealing as well.

It seems that Vim's reputation as having a steep learning curve has spurred Vim proponents to write numerous excellent guides for new users. However, for Emacs, I can't get beyond simple text editing, saving files, etc. I haven't found any good guides to Emacs that explain the ecosystem, good coding helpers, and other useful information for a new user: Everything I'm finding is way too comprehensive, and if I'm going to use this editor I need to be able to work in the environment relatively well early on.

Also, will Emacs answer my needs for HTML, CSS, JavaScript, PHP, MySQL, Perl, and Python coding? Especially when, for example, HTML and CSS, or PHP and HTML are mixed in a file?

Thanks!

Replies are listed 'Best First'.
Re: Getting into Emacs?
by Joost (Canon) on Apr 11, 2008 at 15:27 UTC
    Just dumping a few links:

    http://www.emacswiki.org/cgi-bin/wiki/ contains great pointers to all kinds of docs, extensions, customizations and other stuff that emacs users found useful. Really the first place to look. For a start, take a look at the emacsnewbie and programming categories.

    Lispcast recently did a nice article on improving your emacs skills

    the reference card is helpful too (links to a generated pdf. your emacs bundle should contain the at least the tex source if you want to generate one yourself).

    Also, comp.emacs is a useful usenet group.

    Also, will Emacs answer my needs for HTML, CSS, JavaScript, PHP, MySQL, Perl, and Python coding? Especially when, for example, HTML and CSS, or PHP and HTML are mixed in a file?
    Yes it will, but you will need to install at least a few of those language modes yourself, since current emacs doesn't come with, for example, a javascript mode (I've been informed that this is probably going to change). Again, see the emacswiki. As for combining them, mmm-mode is probably the most used mode for this problem, and it works fine.

Re: Getting into Emacs?
by FunkyMonk (Bishop) on Apr 11, 2008 at 15:30 UTC
    O'Reilly's Learning GNU Emacs, Third Edition is probably your best bet, it taught me an awful lot about emacs, and I'd been using emacs for years before I read it.

    Emacs has an excellent help system (C-h ?) that can teach you a lot about Emacs. Apropos (C-h a) is very useful for searching for the keystrokes to do something. If you've got a few weeks to spare, C-h b will show you all ~700 keyboard commands:) The Emacs Manual is also available in the help system (C-h i s emacs RET)

    The emacs wiki is a very good resource, Learning About Emacs may help you.

    Finally, for use with Perl, cperl-mode is a must, but get a more recent version than the one that ships with Emacs

Re: Getting into Emacs?
by Old_Gray_Bear (Bishop) on Apr 11, 2008 at 14:53 UTC
    I ran across this in Hunt and Thomas's The Pragmatic Programmer:

    EMACS
    The ultimate in big editors, containing every feature that any editor has ever had, Emacs has a near-vertical learning curve, but repays handsomely once you’ve mastered it. It also makes a great mail and news reader, address book, calendar and diary, adventure game, ...

    I thought they were joking.

    ----
    I Go Back to Sleep, Now.

    OGB

      I got very drunk last night, and definitely enjoyed myself. Now it's morning, I'm pushing through a little hangover, and I found a ~600 page Vim guide (PDF) on my desktop. I don't know how it got there, who it was written by, or anything along those lines, but I do know that it wasn't there last night. The filename is "vimbook-OPL.pdf". Anyway, I think this is an eery sign that I should go with Vim.
Re: Getting into Emacs?
by swampyankee (Parson) on Apr 11, 2008 at 15:43 UTC

    O'Reilly has at least one volume about emacs and I found several here.

    I happen to love emacs, but not obsessively so, and find it to be an incredibly useful editor. And I've used others, including crisp and multiedit, and kept wishing for emacs. Or vim.


    Information about American English usage here and here. Floating point issues? Please read this before posting. — emc

Re: Getting into Emacs?
by Erez (Priest) on Apr 11, 2008 at 15:53 UTC

    will Emacs answer my needs for HTML, CSS, JavaScript, PHP, MySQL, Perl, and Python coding?

    Just what exactly are your needs? No editor, be as good or as complicated as it can be can code for you. It won't suggest the right algorithm, nor will it correct your data-structures. If you can specify what do you look for in an editor, perhaps a better suggestion will be available.

    This been said, try this EMACS page it seems to know what it's doing.

    UPDATE: But then again, it might not, see following remarks. This is what happens when you recommend things without checking them up first.

    Also, two side notes, EMACS is fully programmable, meaning you can create an elisp file that will alter its behavior in a way that will support whatever you want to do (and most chances are that someone already did it). So the answer to any EMACS q is usually "yes", but it may need to be added, or created.
    Two, a steep learning curve means that you can get on top of things (the y grid) very fast (the x grid). What you mean is a very gradual, or flat, learning curve (takes lots of time to learn how to do something)

    Software speaks in tongues of man.
    Stop saying 'script'. Stop saying 'line-noise'.
    We have nothing to lose but our metaphors.

      Seeing that I learned the basics in SimpleText on OS8, I definitely don't need my editor to code for me :^) Here are my needs, but of course I'm forgetting some:
      Syntax highlighting
      Most editors have this. I need it to highlight CSS in the head of a document, HTML in a PHP file, JavaScript in HTML, etc. Not so much for inline style="" or onclick="" attributes but when separated explicitly with style and script tags.
      Indentation
      Good, automatic, context-sensitive indentation
      Code completion
      Index my functions, classes, even variables so I don't have to repeat so much typing. Library function completion is nice too...
      Project management
      I need to be able to access my filesystem to some degree from the editor. It's very nice to be able to see a list of files in a project too, and to be able to launch projects by name. Finally, in TextMate I use Control+T which has a great project file quicksearch, so "Ctrl+T: head" will bring up a list of all files with these letters, regardless of their directory.
      Access to shell, maybe a debugger
      Access to the shell would be great, and I'm sure Emacs does this. I honestly don't know what a debugger is, and I always manually debug my code. Being able to run scripts while in Emacs would be great. Dropping to a shell and using "python ./some_script.py" works, but not as elegantly.

      I know Emacs has plugins to do snippets like TextMate, so that's not a concern. And I'm willing to learn rudimentary ELisp to maximize customization.

        Emacs can do all of this, though real thorough code completion is really dependent on the support of and mode for the language you're using. There are a whole bunch of generic completion minor modes too, so you'll never be completely without it if you don't want to.

        For perl, I don't really use the debugger much at all. You may also be interested in Sepia, which runs an "inferor perl" more or less like Slime for Lisp, which means it can catch/debug exceptions when they occor, do completions based on whatever is currently defined in your running perl process etc. This is a pretty different way of developing than the usual save/compile/run methods, and suits some kinds of programs better than others.

      "This been said, try this EMACS page it seems to know what it's doing." Ah, yes "Xah's Emacs Tutorial"

      Xah certainly knows his way around emacs, but he's a bit of a windows weenie... he gets a bit snarky that a lot of us have trouble caring about things like this:

      "Turn on CUA Mode" ... "The CUA mode will make emacs behave more like modern applications"

      Of course, if you're also coming from a windows background, it could be his advice is just what you need.

        OTOH, Xah is a well-known USENET troll and should be avoided at all costs, IMHO.

        I haven't read what he's got to say about Emacs. It may be very good, I just assume it's as worthless as all his posts to comp.lang.perl.misc and elsewhere.

      First off, the emacs community widely agrees that xah is insane. I recommend not linking newbies to his site.

      Secondly, I disagree about Emacs' learning curve. You can immediately open a file, start typing (with syntax highlighting, etc.), save it, etc. all without ever needing to know anything about emacs. Just use the menubar or toolbar like in any GUI application.

      Once you decide Emacs is decent, then you can invest in learning the key bindings and the advanced features. Emacs comes with very good documentation, and it's self-documenting. So if you accidentally press a key and like what it does, you can can C-h k <that key command again> and get detailed information on that command.

      And of course, elisp makes it very easy to extend emacs. Emacs makes programming in elisp quite enjoyable, even though elisp is definitely Not Perl.

      YMMV, but vi will never have the level of documentation and extension ability that emacs does.

Re: Getting into Emacs?
by mhearse (Chaplain) on Apr 11, 2008 at 16:40 UTC
    There is a really nice 7 part tutorial at IBM Developerworks:
    1 2 3 4 5 6 7 
Re: Getting into Emacs?
by perrin (Chancellor) on Apr 11, 2008 at 16:13 UTC
    Also, will Emacs answer my needs for HTML, CSS, JavaScript, PHP, MySQL, Perl, and Python coding? Especially when, for example, HTML and CSS, or PHP and HTML are mixed in a file?

    Emacs has a "mixed mode" which allows it to handle this sort of thing. I use it for editing Mason pages with in-line perl code.

      Emacs has a "mixed mode" which allows it to handle this sort of thing. I use it for editing Mason pages with in-line perl code.
      Yes, you probably mean "mmm-mode"... it was originally written to deal with Mason (perl and html intermixed) so that case should certainly work out-of-the-box. In theory, with a little setup you can use this on any number of combinations (myself, I still need to look into how to deal with SQL embedded in perl heredocs...):
      On the emacswiki:
      MultipleModes
      HtmlModeDeluxe

      I could not tell you if something like this has ever been written for vim, but I have my doubts it would be that easy to do... certainly I've never heard of anything like it.

      Obviously, I also like the emacswiki, and I tell people to check there first because for some reason the site doesn't rank very high in google searches. There's a page with pointers to different perl-related emacs projects:

      PerlLanguage

      (One of my fantasies is to someday set-up some kind of emacs bundle for people who want to use it to hack on perl...)

        Two seconds of googling would have confirmed that Vim has its own Mason mode with separate perl and HTML highlighting. It may not be implemented in the same way as the Emacs one, but it sounds pretty good.
      And here's the other big question: Can Vim do these things as well?
        Of course. I don't use vim, but no editor could survive this long without capabilities like that.
Re: Getting into Emacs?
by Your Mother (Archbishop) on Apr 11, 2008 at 17:01 UTC

    I'm an Emacs user and fan and I've been starting to use TextMate a bit more. I see it as a sort of candy coated Emacs; in a good way. Emacs has more corners to explore than probably any other editor in the world but sometimes a simple popup menu that goes with the mode you'll only use now and then is better than having the complete range of possibilities tied to short-cuts, customizations, and key-completions. TextMate bundles, I think they're called, are also getting more and more specific. A couple of the JavaScript libraries have them, for example. Not to dissuade, because Emacs (and vim) is pretty much always going to be there wherever you get stuck having to work on something, but I could see myself moving entirely to TextMate for home hacking over the next year or so.

    Update: deleted typo’d letter.

      Exactly. I'm at a new job (in a ColdFusion environment, of all things) and they've stuck me on a Windows box like all of my other web design jobs. My muscle memory and best productivity is in TextMate, but obviously that won't happen here, and I'm not going to get the company to pony up the money for Windows TextMate knockoff "E".

      I'll be damned if I use the Dreamweaver editor much longer, so I've been considering having IT install either Vim or Emacs (or both) since nobody will whine, the software being free and relatively resource-conservative. And obviously I'm going to become pretty good with whichever one I choose, so I'd like that one to be an editor that best fits my future needs, and that maybe I can use on all platforms since using a Mac-only text editor is not the best idea when I'm regularly going between Mac, Linux, BSD, and Windows.
        There is something called E Text Editor which is an attempt to replicate TextMate on windows. As far as I saw, it's good.
Re: Getting into Emacs?
by BKB (Novice) on Apr 13, 2008 at 00:44 UTC

    About learning Emacs

    I recommend first of all using Ctrl-h t to do the Emacs tutorial. If you are still happy to carry on using Emacs after this initial experience, then I recommend you to buy a printed copy of the GNU Emacs Manual by Richard Stallman

    Reading the whole of this book at the start of your Emacs learning process will save you much pain later on.

    It's also much better than the O'Reilly book mentioned above.

    What Emacs does for you

    Emacs (I use cperl mode) can make writing source code much easier by doing things like indenting the lines of code automatically, or colouring in the key words and variable types. For example, see this blog post, which was created using Emacs's colourings for cperl mode with htmlize.el.

    Emacs for other languages

    Emacs has patchy coverage for languages. Coverage for Emacs Lisp and C is excellent, but it doesn't come with a JavaScript mode, although there are ones that can be installed. The default CSS mode in Emacs is pretty strange, but it is possible to set it up better. Emacs' HTML mode seems OK to me, but I don't know anything about MySQL (it has an SQL mode but I don't know anything about it), Python, or PHP. As for mixed languages in the same file, as far as I know Emacs doesn't do that at all well. You have to switch between modes in different parts of the file.
      cperl mode has a few other nice features besides just indenting and coloring. There is a "Perl" menu available whenever editing perl files with nice perl-specific entries. Another feature I enjoy is the "cperl-get-help" function, which will provide context-sensitive format help for perl constructs. You can bind it to a key, or turn on "autohelp", providing context-sensitive help after a period of inactivity. This can be very convenient for perl constructions that you don't use often (e.g., secsockopt()) where you know what you want but don't remember the order of parameters, etc..
Re: Getting into Emacs?
by mr_mischief (Monsignor) on Apr 11, 2008 at 16:59 UTC
    I'm a vim user through and through, and I've found O'Reilly's vi pocket reference quite handy at times. There's an equivalent ISBN 1565924967 for Emacs which I'd guess would be just as handy. Sorry, but I can't vouch for it specifically.

    The pocket guides are a nice size in between an A4 reference sheet and a full manual.

Re: Getting into Emacs?
by dhosek (Beadle) on Apr 11, 2008 at 17:24 UTC
    For a Mac User, it's well worth using the Aquamacs Emacs environment which bundles most of the extra Emacs stuff that you'd want as well as sets up a default environment that supports the most common UI key combinations that you're accustomed to (e.g., cmd-x/c/v for cut/copy/paste. cmd-s to save, etc.).

    Donald Hosek, Tech Lead at oversee.net
    L.A. perl people, we're hiring.

      The Aquamacs changes are very annoying if you try to use Emacs on another platform as well; an Emacs configuration that sets up M-x to be "cut" is almost trying to make people's life difficult down the road. Better to swallow the bitter pill right up front and learn to C-w and C-y like everyone else. (Or A-x and A-v if you really can't do without something vaguely familiar.)

      That said, once all the silly defaults are disabled and the standard Emacs behaviour is restored, it's arguably a better Emacs port than Carbon Emacs, and thus is what I use when I'm working on a Mac.

        Actually, it doesn't set M-X to be cut. It sets Cmd-X to be cut. It's trying to make the command key into meta that's the problem. On every other platform, it's esc, that's what I've always been accustomed to, so there's no conflict.

        Donald Hosek, Tech Lead at oversee.net
        L.A. perl people, we're hiring.
      IMHO Aquamacs is a terrible idea. If you want to learn Emacs, either find someone who uses it and steal their configuration, or learn from the Emacs Wiki. Aquamacs makes a lot of dumb interface choices, e.g. mode-specific color themes and one buffer per frame. Plus, it dials home regularly to report your usage statistics. Use the carbon emacs package from apple.com, which does the bundling without breakage or spying.
Re: Getting into Emacs?
by rudder (Scribe) on Apr 11, 2008 at 19:41 UTC
Re: Getting into Emacs?
by Gavin (Archbishop) on Apr 12, 2008 at 15:11 UTC
    "Also, will Emacs answer my needs for HTML, CSS, JavaScript, PHP, MySQL, Perl, and Python coding? Especially when, for example, HTML and CSS, or PHP and HTML are mixed in a file?"

    My personal choice for Perl and MySQL has always been a free small editor called PFE and for CSS, PHP, HTML, XHTML, Javascript, ASP etc I find I never use anything other than Dreamweaver and now with AJAX extensions its a one stop shop.

Re: Getting into Emacs?
by Your Mother (Archbishop) on Apr 16, 2008 at 21:57 UTC

    Sorry to come back to this late but it just occurred to me. Emacs and many OS X apps share lots of keyboard shortcuts for things like skipping/deleting words or jumping around text. Fringe benefit of knowing Emacs is you can go mouseless a bit more in OS X.