2

I have a jEdit BeanShell macro that runs my Markdown files through Maruku when I save them:

if (buffer.getMode().toString().equals("markdown")) {
  cmd = "C:\\Ruby\\bin\\maruku.bat -o " + buffer.getDirectory() + buffer.getName().replaceAll("markdown$", "html") + " " + buffer.getPath(); 
  exec(cmd);
}

This works great when the Markdown file is valid. But if I've made a mistake, jEdit just waits around forever for the exec() call to "succeed," which it never will. When this happens, I have to kill jEdit's javaw.exe process and run Maruku manually from the command line to discover the error, e.g.:

E:\docs>maruku mydoc.markdown

 ___________________________________________________________________________
| Maruku tells you:
+---------------------------------------------------------------------------
| Could not find ref_id = "17" for md_link(["17"],"17")
| Available refs are []
+---------------------------------------------------------------------------
!C:/Ruby/lib/ruby/gems/1.8/gems/maruku-0.6.0/lib/maruku/errors_management.rb:49:in `maruku_error'
!C:/Ruby/lib/ruby/gems/1.8/gems/maruku-0.6.0/lib/maruku/output/to_html.rb:716:in `to_html_link'
!C:/Ruby/lib/ruby/gems/1.8/gems/maruku-0.6.0/lib/maruku/output/to_html.rb:970:in `send'
!C:/Ruby/lib/ruby/gems/1.8/gems/maruku-0.6.0/lib/maruku/output/to_html.rb:970:in `array_to_html'
!C:/Ruby/lib/ruby/gems/1.8/gems/maruku-0.6.0/lib/maruku/output/to_html.rb:961:in `each'
\___________________________________________________________________________
Not creating a link for ref_id = "17".

Then I restart jEdit, fix the error, and re-save the file, at which point the macro succeeds.

How can I make my macro more resilient to either die helpfully (display Maruku's error output) or, at the very least, die silently so I don't have to kill jEdit?

rossmeissl
  • 153
  • 2
  • 6

2 Answers2

0

I use a slightly different call inside my macros to execute a system command:

Runtime.getRuntime().exec("asdf");

When I run this, Jedit gives me a popup: Jedit popup on <code>exec</code> failure

I'm running Jedit 4.4.1 with JDK 1.6.0_26.

Ross Rogers
  • 23,523
  • 27
  • 108
  • 164
0

It's possible that ErrorList plugin is involved here and a deadlock occurs. The bug is fixed, although the fix is not released yet. Anyway in the bug tracker you may find workarounds for the problem.

Jarekczek
  • 7,456
  • 3
  • 46
  • 66