Strange auto-indentation while using Julia plugin

I am trying the Julia plugin by @mgubi from https://github.com/mgubi/tm-julia/tree/main and it works great. However it seems to have a strange auto-indentation issue, after the writing first line in a Julia session, going to the second line puts a TAB automatically on the second line, but from the third line and beyond there is not such auto-indentation. So the code ends up looking like this:

>>> function test(x)
                    println("hello world") # this indentation happens automatically 
                    return x # no indentation from this line and beyond
                    end

and as a result, the code looks very odd. Of course, one can always manually use backspace to remove the TAB indentation on the second line, but this can get tedious. Is there a way to suppress the auto-indentation on the second line in the Julia sessions?

Can you please try

(tm-define (program-compute-indentation doc row col)
      (:mode in-prog-julia?)
    0)

I have a partial intuition on how this computation works, and the key is (:mode in-prog-julia?), where I think that the predicate in-prog-julia? is generated automatically by the program.

Please let me know if this works. It may be worth it to figure out why the auto-indentation works in the way you have shown regardless of whether the code I posted here works or not.

1 Like

Yes, it works, thank you very much. If I start a scheme session and evaluate the code in Scheme:

(tm-define (program-compute-indentation doc row col)
      (:mode in-prog-julia?)
    0)

it turns off the auto-indentation. Another question: how do I ensure this behavior globally (no indentation in Julia), without executing the code manually everytime? Any tips will be appreciated, as I am a beginner TeXmacs user.

Please try and put it into your personal initialization file my-init-texmacs.scm. If I find a better way I will write again.

You can refer to

to see how to edit your my-init-texmacs.scm.

A “trick” to figure out where the file is: start on that file the “Save as” command from the menu, it will propose you the directory of the file you are “saving as”.

2 Likes

Great, thanks very much!