Re: ta and running java classes

From: mitchell <mforal.n....at.gmail.com>
Date: Mon, 22 Jun 2009 17:28:35 -0700 (PDT)

Martin,

> > Not sure why, but it's not showing up. Before I got a 'file not found'
> > error and now it doesn't even show up. Can you post it inline?
>
> When I attached the file, I also tried to download it - it worked, but
> now
> it doesn't, strange. OK here is the file's content:

I've included your idea in HG (r404) but tweaked it a bit. It will be
in the next release. I've included the changeset for your convenience.
I hope it works on Windows!

-Mitchell;

# HG changeset patch
# User mitchell
# Date 1245716745 14400
# Node ID ab95cc339359ca5eabaa0fa304649b9b73236eda
# Parent fd585c2478aff5da8b380af2dbc2ef1d86b31270
Can use functions to return compile or go strings; modules/textadept/
run.lua
Utilize this with Java.

diff -r fd585c2478af -r ab95cc339359 modules/textadept/run.lua
--- a/modules/textadept/run.lua Sun Jun 21 17:57:32 2009 -0400
+++ b/modules/textadept/run.lua Mon Jun 22 20:25:45 2009 -0400
@@ -37,7 +37,8 @@

 ---
 -- [Local table] File extensions and their associated 'compile'
actions.
--- Each key is a file extension whose value is a command line string
to execute.
+-- Each key is a file extension whose value is a either a command
line string to
+-- execute or a function returning one.
 -- @class table
 -- @name compile_for_ext
 local compile_for_ext = {
@@ -52,18 +53,30 @@
 function compile()
   if not buffer.filename then return end
   local action = compile_for_ext[buffer.filename:match('[^.]+$')]
- if action then execute(action) end
+ if action then execute(type(action) == 'function' and action() or
action) end
 end

 ---
 -- [Local table] File extensions and their associated 'go' actions.
--- Each key is a file extension whose value is a command line string
to execute.
+-- Each key is a file extension whose value is either a command line
string to
+-- execute or a function returning one.
 -- @class table
 -- @name go_for_ext
 local go_for_ext = {
   c = '%(filedir)%(filename_noext)',
   cpp = '%(filedir)%(filename_noext)',
- java = 'java %(filename_noext)',
+ java = function()
+ local buffer = buffer
+ local package = buffer:get_text():match('package%s+([^;]+)')
+ if package then
+ local classpath = ''
+ for dot in package:gmatch('%.') do classpath =
classpath..'../' end
+ return 'java -cp '..(WIN32 and '%CLASSPATH%:' or
'$CLASSPATH:')..
+ classpath..'../ '..package..'.%(filename_noext)'
+ else
+ return 'java %(filename_noext)'
+ end
+ end,
   lua = 'lua %(filename)',
   pl = 'perl %(filename)',
   php = 'php -f %(filename)',
@@ -77,7 +90,7 @@
 function go()
   if not buffer.filename then return end
   local action = go_for_ext[buffer.filename:match('[^.]+$')]
- if action then execute(action) end
+ if action then execute(type(action) == 'function' and action() or
action) end
Received on Mon 22 Jun 2009 - 20:28:35 EDT

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 11:38:10 EST