Skip to content
This repository has been archived by the owner on Aug 10, 2020. It is now read-only.

How to extend "Execute in block" feature? #20

Closed
leakyMirror opened this issue Oct 31, 2014 · 10 comments
Closed

How to extend "Execute in block" feature? #20

leakyMirror opened this issue Oct 31, 2014 · 10 comments

Comments

@leakyMirror
Copy link

I love r-box and I use with many other languages (because it works). However "execute in block" feature does not work in languages where function is defined without {}. Is it hard to make it work with this kind of syntax?:

function foo() 
  a = 1
  b = 2
  return a + b
end

I read the code and found that it uses a fancy regex to grab functions. So decided to ask you for an advice before diving deeper.

Thanks.

@randy3k
Copy link
Owner

randy3k commented Oct 31, 2014

It depends on the language itself.

PS: is it julia?

@leakyMirror
Copy link
Author

Yes it is :)

@randy3k
Copy link
Owner

randy3k commented Oct 31, 2014

I have been thinking to write a general package which extends SendText to what R-Box could do. But the "block" feature really depends on the language itself.

Perhaps, I can write a simple plugin for julia, e.g. Julia-Box....

@leakyMirror
Copy link
Author

It would be awesome. Isnt it require just to change that regex? Everything else is working, as far as I know

@randy3k
Copy link
Owner

randy3k commented Oct 31, 2014

Julia is bit tricky, there are at least the following things to consider

  1. control flow: for, while, if else etc..
  2. string "foo"
  3. command echo $HOME
  4. @begin @end, quote end
  5. comment, both # and block comment #= =#
  6. .....others

@leakyMirror
Copy link
Author

I am thinking only about function and maybe for, if and while.

These ussualy are the biggest blocks in the code. It is anoying to execute them line by line.

@randy3k
Copy link
Owner

randy3k commented Oct 31, 2014

it is necessary to consider all these, for example

function f(x)
   # end
   a = "end"
   b = @begin
   1+ 1
   @end
   if 1 > 2
      b = 2
   end
   b
end

If you don't consider them, we will not be able to find the last end.

@leakyMirror
Copy link
Author

What about matching the indetation? For example if there are 4 space before function you need to search for first end with 4 spaces.

@randy3k
Copy link
Owner

randy3k commented Nov 2, 2014

Check this out SendTextPlus.

@randy3k randy3k closed this as completed Nov 2, 2014
@leakyMirror
Copy link
Author

Super cool, thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants