Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

One of the nice features of BBEdit is that it can show a list of errors (e.g. syntax errors in a Ruby program), and clicking on the error will display the line in the source code file.

How can I bring this window up programmatically, e.g. via the command line, AppleScript, or a language module?

In my specific situation, I'm compiling SML/NJ programs. The compiler lists errors in the following format:

codegen.sml:121.31 Error: syntax error: inserting  LPAREN
codegen.sml:130.49 Error: syntax error: inserting  EQUALOP

When I get compiler errors like that, I'd like BBEdit to display those error messages and let me click on them to display the buggy line in my code.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

You can do it using AppleScript and BBEdit's results browser command. It isn't well documented, but there are some good examples around to help you out. For example: John Gruber's CSS Syntax Checker.

Here is a sample AppleScript.

tell application "BBEdit"
  set error_list to ¬
    {{result_kind: "Error", result_file: "/path/to/codegen.sml",¬
      result_line: 121, message: "syntax error: inserting  LPAREN"},¬
     {result_kind: "Error", result_file: "/path/to/codegen.sml",¬
      result_line: 130, message: "syntax error: inserting  EQUALOP"}}
  make new results browser with data error_list with properties ¬
    {name:"Errors"}
end tell

Of course, you will want to create the error_list variable programmatically, but this should get you started. If you change /path/to/codegen.sml to a file that exists on your system, you can see it in action.

share|improve this answer
    
Thanks for the detailed info! I would never have figured out the arguments from the BBEdit scripting dictionary. I wrote a Python script to filter compiler output and display the browser window. gist.github.com/3113810 –  Jay Lieske Jul 14 '12 at 23:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.