parinfer-mode icon indicating copy to clipboard operation
parinfer-mode copied to clipboard

Smart mode status?

Open Engelberg opened this issue 6 years ago • 18 comments

What's the status of smart mode? Is it ready for prime time? If so, what is the method for installing the smart mode branch?

Thanks.

Engelberg avatar Oct 29 '18 01:10 Engelberg

I'm very sorry to say recently I don't have time on develop work on this project. the smart mode is almost done on the smart branch with few known problems in my use case. 1, not work with multiple edit(automatically disabled) 2, every change will refresh the whole buffer, It's fast, but will break cider's hint on fringe and some modes like hideshow 3, will not delete the close parens when delete semicolon for a comment line.

the problem 2 is hard to solve, so I decide to rewrite when have time.

DogLooksGood avatar Nov 16 '18 09:11 DogLooksGood

I'm not sure what would be even involved to finish smart mode, so i feel i'm a poor candidate for taking it on. The project seems to have a good bit of interest though, maybe we could start a Patron to help ppl pay you back for this and future work. I just know i would be excited to start using smart mode on emacs

drewverlee avatar Dec 31 '18 02:12 drewverlee

break cider's hint on fringe and some modes like hideshow

can you explain a bit more on what that means?

drewverlee avatar Dec 31 '18 02:12 drewverlee

It seems that this fork has working smart mode: https://github.com/jvshahid/parinfer-mode/tree/master

@jvshahid Any plans to merge your work into this package?

andreyorst avatar Mar 24 '20 07:03 andreyorst

@andreyorst see https://github.com/shaunlebron/parinfer/blob/master/lib/README.md

next-mad-hatter avatar Mar 26 '20 12:03 next-mad-hatter

@andreyorst see https://github.com/shaunlebron/parinfer/blob/master/lib/README.md

and?

Smart mode works fairly well in that implementation, as well as in https://github.com/eraserhd/parinfer-rust. It's just a matter of telling users that it would not work in these specific situations. Also allowing toggling between all three modes as done in Atom and parinfer-rust is a possible way to workaround most these problems.

andreyorst avatar Mar 26 '20 12:03 andreyorst

@andreyorst fair enough -- I haven't used smart mode in a long time and it seemed to me like it was being abandoned, but maybe I was mistaken :)

next-mad-hatter avatar Mar 26 '20 13:03 next-mad-hatter

@jvshahid Any plans to merge your work into this package?

My repo isn't really a fork. I just merged the smart branch into master, since both had features that I wanted to use. I don't use smart mode anymore, since I encountered a lot of edge cases while using it.

jvshahid avatar Mar 26 '20 14:03 jvshahid

Anyone have some experience with parinfer-rust-mode? It looks promising.

https://github.com/justinbarclay/parinfer-rust-mode

DogLooksGood avatar Mar 26 '20 15:03 DogLooksGood

I do. Used it in Kakoune. There were some issues with long running sessions, but performance-wise its good

andreyorst avatar Mar 26 '20 15:03 andreyorst

Although the big point for me is that this package is pure elisp. Which means that it works on my phone, and on PC

andreyorst avatar Mar 28 '20 13:03 andreyorst

I'm going to explore how I can integrate smart mode with paren and indent modes, because currently you're locked into smart mode. If I will figure this out are here willing to accep PR with smart mode? I mean it really works that well for me, I've wrote a lot of Clojure, ELisp, Scheme and Racket in past two weeks and had no issues so far, so it only need a little polish here and there

andreyorst avatar Apr 11 '20 15:04 andreyorst

There is a big problem, I'm still exploring how to make parinfer fast in Elisp. There're so many edge cases if you can't parse the whole buffer.

My first plan is writing a faster indent/paren mode. If this is possible, target to the smart mode.

DogLooksGood avatar Apr 11 '20 15:04 DogLooksGood

Glad to hear that you have plans on improving this package

I don't know implementation details, but will it be possible to parse expression inside-out? E.g. if we're inside expression, take this as starting point and expand until reached top level. This will reduce reparsing to current expression as a whole. Of course if whole file is one big expression this is not going to work...

Edit: oh, well, perhaps if parentheses unbalanced such algorithm will misbehave a lot.

andreyorst avatar Apr 11 '20 17:04 andreyorst

In some cases, it is possible to assume we are working on balanced parens, so just run parinfer in a top-level or parent sexp. But when you do kill, especially those without a region, like kill-line, it will break. And there are a lot kill commands.

DogLooksGood avatar Apr 11 '20 17:04 DogLooksGood

Yeah, I've realized that. I have high hopes for native compilation of emacs lisp. I'm currently using this branch and it is really fast.

andreyorst avatar Apr 11 '20 17:04 andreyorst

I've heard of this, is it require a very long time to compile the Emacs and packages? I also curious about what if implement parinfer in C, provide as a dynamic module. If there's no other dependencies, user only need gcc, make installed, and compile can be done automatically.

DogLooksGood avatar Apr 11 '20 17:04 DogLooksGood

I've heard of this, is it require a very long time to compile the Emacs and packages?

Not quite. It's longer, but, and it's a big but, you can compile Emacs as usual, and it will asyncronously compile and load compiled elisp while running:

./autogen.sh && ./configure --with-nativecomp && make NATIVE_FAST_BOOT=1 -j4

I also curious about what if implement parinfer in C, provide as a dynamic module.

I think this can be done, and since there's Rust implementation, I think it can be translated to C pretty much directly for the most part. Although it uses quite a lot of dependencies.

Generally speaking, I really like this idea. I'm using vterm which compiles itself on first launch after update/install and it is quite useful

andreyorst avatar Apr 11 '20 17:04 andreyorst