Archive for the ‘emacs’ Category

Working with emacs


When it comes to coding the use of IDEs is generally very popular, and dominant within most corporate/enterprise spaces. In particular:

  • Visual Studio (with Resharper) for my day-to-day development tasks (and have done since 2002) in .NET land & it’s SQL Server derivatives for working with that (SSMS, BIDS, & now SSDT)
  • Eclipse & its derivative IBM Rational System Architect
  • Apple’s XCode for MacOS and iOS development with Objective-C
  • JetBrains IDEs – especially IntelliJ for Java

These are great, but with the possible exception of Eclipse, they tend to be very focused on working with a particular language or platform (eg JVM or CLR). When working with these mainstream techsets, despite some bloat related slowness, they do provide a very productive development experience for the amount of investment in skills they require to use them effectively. They are intuitive, simple, and can be very powerful.

When working with less mainstream technologies, and for those willing to invest in the effort to master it, GNU Emacs offers a very effective experience. It also offers an advantage when attempting to learn a new language and its associated toolset. Unlike environments like Visual Studio, Eclipse, and IntelliJ which often hide some of what is going on from the user (such as working with the compiler, or debuggers) it’s typically less complete support in these areas requires the learner to understand them in order to work. This provides a range of advantages after transferring back to an IDE, in particular when things don’t work as expected.

Emacs benefits from having a wide range of modes available for it, and with the use of an emacs package manager (I use Marmalade) getting these packages installed is typically very simple. Even where the mode you want is not available as a compatible package, it tends to be very simple to get it installed (typically a matter of putting it in a suitable location) and then editing the .emacs file using emacs. Most languages tend to have a mode developed for them, and often before they become available in IDEs. In some communities emacs tends to be the standard editor to use, with no IDEs gaining comparable mindshare. For example with lisp based languages like common lisp, clojure and scheme (emacs is written in lisp, and can be fully customised using its own elisp variant). Additionally erlang has great support in emacs, with the Wrangler refactoring tool complementing its major mode.

Emacs has a certain reputation for the complexity of its keyboard shortcuts. Its use of keyboard combinations such as Ctrl-x, r, Space, #register_number to save the current position of the point (the caret) in a register draw humorous derision from users of other editors (in particular the Vi(m) community). Complaints about this tend to be unusual with most emacs users, and typically come from the outside. It can though be intimidating to a new user of the system.

Because of this I created a small github site to capture in one place emacs commands that I use a lot.

Because of this I’ve created a small github site to capture in one place common emacs commands. Twitter bootstrap was used to put the site quickly together.

You can find it here: emacs_shortcuts. Pages are included for SML Mode (Standard ML Mode) and the HTML Mode. Other modes may be added in time (though use of Ctrl-h, m) makes this a bit moot, and pull requests are very welcome.

Advertisements

Read Full Post »


I’m using Standard ML of New Jersey, the latest release available at this time is the 110.74 version from Jan 20, 2012. This can be found here (where any newer versions released since should also be linked to): http://www.smlnj.org/dist/working/ Unfortunately, at least for me, it isn’t the easiest to find this page as google’s top hit sent me to the Sourceforge site for Standard ML of New Jersey (http://smlnj.sourceforge.net/) where the latest version available is the 110.60 version from back in December 2006. I used the Intel specific Mac OS installer package and this placed the files in the folder /usr/local/smlnj-110.74 Navigating to there and running sml from the bin (./bin/sml) provides access to a repl console. To exit the repl use ctrl+d. Next up for me was to get the sml-mode for emacs working. Sadly I couldn’t see any elisp packages available to do this for me (M-x list-packages), and besides doing these things manually provides more learnings I find. To get sml and emacs working together happily involved:

  1. getting the sml-mode elisp files and placing them in a new folder ‘~/.emacs.d/sml-mode’ – I like to keep all my emacs mode & other mod files together here
    1. I downloaded the sml-mode using the link here: ‘http://www.iro.umontreal.ca/~monnier/elisp/‘ – I plumped for the Download 5.0 July 2012. Running make for me resulted in a fair few warnings, but nothing too concerning I thought.
  2. editing my ~/.emacs file so that it can find that folder and will use the sml-mode when a .sml file is loaded into emacs, and so that the sml inferior mode is available to give me access to the sml repl from within emacs

;;; use sml-mode when file ends in .sml
(autoload ‘sml-mode “sml-mode” “Major mode for editing Standard ML code.” t)
(autoload ‘run-sml “sml-proc” “Inferior mode for running the compiler in a separate buffer.” t)
(setq auto-mode-alist
(append ‘((“\\.sml$” . sml-mode)) auto-mode-alist))
(setq sml-program-name “/usr/local/smlnj-110.74/./bin/sml”)

With this done if you load a file with the .sml extension or otherwise when you meta-X sml-mode then you get some syntax highlighting and help with indentation.

Also, if you meta-X run-sml and then hit enter (presuming that you’ve adjusted the sml-program-name from my path above if necessary) then you’ll get a new buffer opened with the sml repl running.

EDIT: I’ve created a small site with details of useful emacs commands, as well as detailing the SML Mode commands: http://neilrobbins.github.com/emacs_shortcuts/

To get this going I found this site on sml-mode very helpful and I recommend looking at it: http://www.smlnj.org/doc/Emacs/sml-mode.html#SML-Mode

This page also has some useful advice: http://www.cs.washington.edu/education/courses/cse341/07sp/help/sml-repl.html

 

 

Read Full Post »

%d bloggers like this: