I've been looking for a good editor for Haskell for a few months now and two days ago I discovered this one. I've tried pretty much all the other editors aimed at programmers and this is the first one that actually has correct syntax highlighting for Haskell. The python programmability makes it even more awesome. Too bad it isn't open source or even free, but I guess you can't have everything.

Before this I used Programmer's Notepad and that has one feature that isn't currently included: The ability to run other programs and pipe their output to the output panel (specifically, running Ghci or Runhaskell on the current file). No problem, Sublime is programmable so I figured I'd just make a plugin. Running a program and capturing the output as a string isn't too difficult (os.popen), but I'm having some problems with the output panel. Specifically, I can't find any API functions to show or print to it. I tried sublime.runCommand("showPanel output nofocus") but that does nothing. If these functions are currently available, can someone tell me what they're called? If not I'd like to request them being added to the API.

Thanks in advance.

EDIT: Also, the API doesn't list a way to save the file before running the program. Am I just looking in the wrong place?

Jon will hopefully answer in more detail if necessary, but have you had any luck with the build system? If you look in the Tools menu, you'll see a 'Build System' submenu, and a 'Haskell (GHC)' under that. Select that, and it'll run GHC when you hit F7 -- there are options on the same menu to save open files before build, and the output is piped to the output window. I think GHC must be in your path.

If you want, you can also write your own build options, say for Runhaskell. Copy the Haskel (ghc).sublime-build file into <user-app-data>\Sublime Text\Packages\Default and rename it to Runhaskell.sublime-build. Open it, and edit the command-line inside-- something like this?

FalconNL wrote:Too bad it isn't open source or even free, but I guess you can't have everything.

If it helps, you could consider the price to be a support contract -- Jon is fantastically responsive at incorporating changes and helping with any problems. Hell, emacs is free, but try getting Richard Stallman to update emacs for 60 bucks

SteveCooperOrg wrote:Jon will hopefully answer in more detail if necessary, but have you had any luck with the build system? If you look in the Tools menu, you'll see a 'Build System' submenu, and a 'Haskell (GHC)' under that. Select that, and it'll run GHC when you hit F7 -- there are options on the same menu to save open files before build, and the output is piped to the output window. I think GHC must be in your path.

If you want, you can also write your own build options, say for Runhaskell. Copy the Haskel (ghc).sublime-build file into <user-app-data>\Sublime Text\Packages\Default and rename it to Runhaskell.sublime-build. Open it, and edit the command-line inside-- something like this?

The Runhaskell build option will appear immediately in the list of build options from the tools menu.

Hope that does what you need...

The problem with that approach is that I often switch between runhaskell and ghci, which would require switching the build system every time. I chose the plugin route so I could bind runhaskell to F5 and Ghci to F6 just like I had in Programmer's Notepad. Thanks for the suggestion though.

The .sublime-build files are a thin wrapper around the exec command, which you can use without having to deal with sublime-build files. What you want is to bind a key to the exec command directly: Create a Default.sublime-keymap file under the Packages/User directory (In C:\Documents and Settings\<username>\Application Data\Sublime Text on XP) that looks something like:

The exec command takes a regex to match line numbers as the first argument, with the remaining arguments being the command line to execute. Within the given command line, the following substitutions are available:

$FileDir (Directory portion of the file name)

$FileName (Non-directory portion of the file name)

$FileExt (File extension)

$File (Full file name)

$BaseName (Filename with no directory and no extension)

Because the regex should be a quoted string, any quotes contained within should be escaped, and any backslashes should be double escaped. The first submatch should match against the file name, the second against the line number, and the third against the column (All of which are optional). If you don't care about being able to double click on lines in the output window, just make the regex empty.

(In the above example, any double quotes have to encoded as &quot; to make the XML parser happy)

However, pressing F5 then produces the status message "Unknown macro command exec '^(...*?):([0-9]*):?([0-9]*)' L:/progra~1/ghc-6.8.2/bin/runhaskell.exe '&quot;$File&quot;'"I tried replacing the &quot;s with "s, but no luck. Commenting out the line produces "Unknown macro command save". Hm. "expandSelectionTo line" works just like in the Delete Line macro, nextView produces another Unknown macro command. Are view-related commands not allowed in macros?

2) When I run the exec command directly from the keybinding everything works as expected, with one exception: The output window seems to have some sort of update problem. I have a test program that outputs one line of text of about 100 to 120 characters. After pressing F5 the output window only shows part of the line. The amount of characters printed is random. I was able to produce 3 characters, the entire string and plenty of in-between values. Clicking on the output window or switching to another application causes the entire string to be shown, so I assume this a screen update/redraw problem.

3) While the output panel is sufficient for runhaskell, which only produces output, it doesn't work for ghci, which is an interactive prompt. Therefore I still have to rely on the python script do use that one. Obviously, I need to save the file here as well. The obvious solution is to be to use