Bespin + Ubiquity

The great thing about Bespin’s command system is that it’s designed to be very similar to Ubiquity’s. Hence, it’s not very tough to turn Bespin commands into Ubiquity commands. Here’s a command that just that – it lets you run Bespin commands from Ubiquity itself. One less hotkey to remember!

Bespin commands on Ubiquity

Initially, I tried to mimic the Bespin environment and execute it from the command sandbox but then, I figured out that I could simply execute the command using the Bespin object loaded on the Bespin page so the code is actually pretty short. But as I explain below, this also imposed some restrictions.

Get the command and test it right away. Go ahead, try “save” or “help” or “export” or anything else.

Quick Improvements

  • Commands ought to be loaded dynamically so if you have custom commands in your BespinSettings project, Ubiquity would be able to load them too. But that doesn’t work currently.
  • Commands should only work on the Bespin page. If you typed “save” on any other page, the Bespin command should not even show up.

A Few Notes

  • Bespin’s command parser itself is very simple when compared to Ubiquity’s. For example, it is not possible to write “export tgz” to export the current project in .tgz format. You could write “export” to get it in the default format (.zip) but if you wanted it in .tgz, you have to write “export SampleProjectName tgz”. In my earlier (longer) version of the hack, this would work because I was extracting the arguments myself but now, I’m passing it directly to the Bespin parser.
  • On a related note, commands are now semantic in Ubiquity 0.5 but Bespin commands aren’t. If a command has two or more arguments, I am artitaribly adding some “semantics”. “export [project] [archivetype]” becomes “export [project] to [archivetype]” (obviously, export [project] as [archivetype] would make more sense here). It would be better to individually figure out how it should be for each Bespin command. At the moment, this screws with the semantic nature of Ubiquity commands.
  • Auto-completion in the Bespin command line is broken. Try writing “ex” into the command line and executing it, it will fail. But, why should it throw an error when it clearly knows what the user meant by “ex” (because export is only command that starts with “ex”)? Instead, it requires one more keystroke (TAB).
    No autocompletion
  • Bespin should use Yip/Growl notifications and if that fails (for the millions for people who don’t have Yip yet!) revert to in-browser notifications which need to be much better than they currently are. As seen below, they obscure your content and clicking on the notification doesn’t hide them (you have to click the tiny X at the top-right).
    Notification overlay hides content
  • The ability to run Ubiquity commands from the Bespin command line might be handy for some who are used to the Bespin command line. “run selector-selector” and “escape HTML entities” are just two Ubiquity commands that developers might find useful.
  • Bespin commands need better descriptions and help.

How can this be more useful? What other aspects of Ubiquity and Bespin can be integrated?

About these ads

5 Comments

Filed under Programming

5 Responses to Bespin + Ubiquity

  1. It’s great to integrate Bespin in Ubiquity, but I don’t like to use Bespin because it has problems with french keyboards (I’ve only tested on mac). So if i want to type , which is essential when coding in HTML, i have to switch to the English keyboard and I’m not used to it.

  2. What parser is integrated in Bespin?
    Is it a fork of an earlier version of Ubiquity? Or is it an independent one?
    And what would be the best way to integrate a parser similar to Ubiquity in a website? To re-use some components of Ubiquity or to use the parser of Bespin?
    Thank you in advance.

  3. abi

    @Philippe If and when we use the Bespin code editor in Ubiquity, we’ll certainly have an option to turn it off and simply use a normal textarea too.

    @Blair Great!

    @lrbabe No, I don’t think it’s a fork of an earlier version of Ubiquity. It’s really simple, they use space as the delimiter and just split the arguments and the commands. Check out the _splitCommandAndArgs function in this page[1]. This is in a way similar to Ubiquity’s earliest parser but I believe they wrote it themselves.

    If you want a simple parser like Bespin’s, you can copy their function or just write it yourself. It’s too simple. If you want the capabilities of Ubiquity’s, take a look at the Parser 2 docs that are included with your local install of Ubiquity. Hope this helps.

    I’m actually trying something similar right now – making Ubiquity work from a website but my attempt does not make use only of the Parser. Blogpost coming up for that soon.

    [1] http://hg.mozilla.org/labs/bespin/file/cef488528a51/frontend/js/bespin/cmd/commandline.js

  4. Pingback: Mashing up some GUI with your ancient command line on Dion Almaer's Blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s