julia-repl icon indicating copy to clipboard operation
julia-repl copied to clipboard

evaluate function

Open tpapp opened this issue 8 years ago • 5 comments

Add the following functionality: when inside a function, select the whole body of the function and send it to the REPL, Similarly to C-c C-c in ESS. Should work with embedded functions.

function foo()
    function bar()
        # cursor here
    end
end

should send function foo() ... end.

Possibly the same machinery that is used for indentation in julia-mode can be used for selecting the relevant block.

tpapp avatar Mar 03 '17 10:03 tpapp

This would be as difficult as calling mark-defun, but you need a proper definition of beginning-of-defun-function and end-of-defun-function and I think that julia-mode doesn't set them. Thus I think that most of the work should be done in the upstream mode. This is also closely related to #7.

Getting the end of defun is tricky, because you have to skip the end keywords of other blocks, like begin, for, etc... If I remember well, fortran-mode has a fairly robust implementation of this function.

giordano avatar Mar 16 '17 11:03 giordano

One thing that could be done as a stopgap solution is to just rely on the indentation. ie., once the editor sees function, every line after that is seen as part of that function until the indentation comes back to the same level as function. Obviously, this isn't ideal but it should cover most cases.

MasonProtter avatar Jul 30 '18 15:07 MasonProtter

Unfortunately, this would not work for functions with empty lines in them (which are not uncommon).

tpapp avatar Jul 31 '18 05:07 tpapp

Can’t we just make it ignore empty lines?

MasonProtter avatar Jul 31 '18 14:07 MasonProtter

Ignoring empty lines still does not solve the nested case in the issue.

Also, I have to admit that with Revise.jl, this issue is not as pressing as it once was.

tpapp avatar Jul 31 '18 14:07 tpapp