smartparens icon indicating copy to clipboard operation
smartparens copied to clipboard

How much effort would it be to implement sp-kill-hybrid-sexp for julia?

Open vxe opened this issue 4 years ago • 6 comments

Expected behavior

sp-kill-hybrid-sexp implemented for julia and allows killing of function definitions and control structures

here are examples of the use main usages of the language: https://juliabyexample.helpmanual.io/#Hello-World

Actual behavior

does not exist

Steps to reproduce the problem

Backtraces if necessary (M-x toggle-debug-on-error)

Environment & version information

In recent enough smartparens you can call M-x sp-describe-system to generate this report. Please fill manually what we could not detect automatically. Edit the output as you see fit to protect your privacy.

  • smartparens version: 20201007.1753
  • Active major-mode: julia-mode
  • Smartparens strict mode: nil
  • Emacs version (M-x emacs-version): GNU Emacs 27.1 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60 Version 10.14.6 (Build 18G95)) of 2020-08-11
  • Starterkit/Distribution: Spacemacs
  • OS: darwin

vxe avatar Dec 18 '20 03:12 vxe

Well, we can really only work with pair delimiters. If there are pairs such as for ... end or while ... end etc this can be defined in a similar way as ruby or elixir.

If it is indent driven like python, I would say currently it's not possible/feasible. Although I always wanted to introduce some sort of "virtual parens", such as for a python block at the change of indent. But this would have to be thought out really well to work generically.

Fuco1 avatar Dec 20 '20 18:12 Fuco1

Thankfully its indent based, and blocks are delimited with end

function quadratic2(a::Float64, b::Float64, c::Float64)
    # unlike other languages 2a is equivalent to 2*a
    # a^2 is used instead of a**2 or pow(a,2)
    sqr_term = sqrt(b^2-4a*c)
    r1 = quadratic(a, sqr_term, b)
    r2 = quadratic(a, -sqr_term, b)
    # multiple values can be returned from a function using tuples
    # if the return keyword is omitted, the last term is returned
    r1, r2
end



if true
    println("It's true!")
else
    println("It's false!")
end

vxe avatar Dec 26 '20 07:12 vxe

Thankfully its indent based, and blocks are delimited with end

By saying that it is indent based do you mean that it will not compile with incorrect indentation? E.g. is this a valid code?

if true
println("It's true!")
    else
  println("It's false!")
        end

andreyorst avatar Dec 30 '20 17:12 andreyorst

wow sorry, I meant to write its not indent based, sorry for the confusion. The example provided is valid code

╰─➛ julia                                                                                                                                                     12:31PM 31-12-2020
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.5.3 (2020-11-09)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> if true
       println("It's true!")
           else
         println("It's false!")
               end
It's true!

vxe avatar Dec 31 '20 04:12 vxe

In that case it should be possible to adapt some code from e.g. ruby mode, but care needs to be taken for various edge-cases of the language. As a non-user, this is not a task I would want to pick up myself.

If you know Elisp and wants to have a go, I'll be happy to provide feedback if you have some questions about smartparens architecture.

Fuco1 avatar Jan 10 '21 17:01 Fuco1

ok will take a look

vxe avatar Jan 12 '21 09:01 vxe