dundalek / closh

Bash-like shell based on Clojure
Eclipse Public License 1.0
1.62k stars 66 forks source link

Paredit + You Are Awesome #22

Open theronic opened 6 years ago

theronic commented 6 years ago

Hi! This is awesome - thank you!

How to integrate paredit support and rainbow parens?

Clj/Cljs has been my primary scripting language for a while now, but it's a pain to deal with I/O and process control, so this hits the sweet spot. I think it would aid adoption to show users how to make closh their default shell :).

dundalek commented 6 years ago

Hi, thanks. We are still very early in the project, so right now the priority is to get basic things working. But I agree we will have a great opportunity to add some sweet features in the future.

For my personal Clojure coding I prefer Parinfer, it also feels more lightweight so I am leaning towards trying integrating it into the shell first. Out of curiosity, what kind of structural commands do you use most with Paredit?

codeasone commented 6 years ago

+1 for paredit support, with configurable key bindings.

dundalek commented 6 years ago

I wonder whether integrating it into Emacs buffer would do the trick :)

theronic commented 6 years ago

@dundalek I get the feeling most Closh expressions will fit on one line, while making it easy to refer to symbols loaded from watched *.cljs files in the current & user folder that live in some namespace.

Parinfer's big idea seems to be about making whitespace meaningful / reflective of the tree structure, which does not apply to one-liners so much. I tried Parinfer for a while, but went back to Paredit + Rainbow-parens because it was more intuitive for me. Keeping track of the structural AND visual shape of my code was too much overhead for my caffeine-addled brain. Also Parinfer's Cursive impl. may not have been as mature. The only tools with decent Paredit implementations I found were Cursive and Emacs (but sadly I'm too dumb to use Emacs).

In my opinion, 90% of the value of Paredit comes from these commands:

(| means cursor)

Honourable mentions:

Keys must be configurable as everyone uses different bindings.

In thinking about one-line vs multiline code more, I think it would be nice if Closh did not eval on Enter, but Cmd+Enter instead, so you could type multiline code. Maybe it should only do this when it detects an sexp and turn a different color. Something that drives me crazy in Cursive's REPL is trying to find an old command. Pressing up-arrow in Cursive's REPL fills the textarea with commands, preventing me from pressing up arrow again, and I can't search for past commands. Throwing features at you here, but symbol-aware search for past history would be awesome :)

In the long-term, I could see something like Closh bringing the object/data-centric value of Powershell to many platforms.

Keep up the amazing work! You are moving the world forward and bringing a beautiful language to the masses :)

dundalek commented 6 years ago

@theronic Wow, thanks, what a great feedback!

You make a great point that messing with whitespace is probably not what you want to do in repl. I need to explore Paredit more. I have VIM roots and now using Atom, which has a first-class Parinfer support. I would like to try Emacs too, but it is way over my head too. One hope for me is Spacemacs with evil mode which looks more approachable. But it does not support Parinfer yet so I don't have the courage to make the leap.

This is also related to #17. My initial thoughts were that if you had unmatched parens then pressing Enter would bring you into multiline mode. With Paredit we could detect when a cursor is in the middle of a s-exp form.

Yeah, great remark about multiline mode and history issues. I guess it could work that if the cursor in on the first line and you press up arrow that would navigate the history.

willghatch commented 6 years ago

If you try emacs/spacemacs, I also recommend looking at smartparens, which is (in my opinion) a little better than paredit. Also check out my little package on-parens that makes it work well with evil/vim style editing.

In Rash right now I'm using readline for completion and command line editing, but in the long run I really want an editor that supports something like smartparens.

tomisme commented 6 years ago

+1 for Parinfer support! I can't live without it now. My gut feeling is that it makes the most sense in a shell-like context as you wouldn't need to use additional hotkeys (just tab/return).

theronic commented 6 years ago

@dundalek Paredit/Parinfer are only effective when parens are balanced, otherwise which tree structure is being navigated/mutated? Hence top commands are the balancing paredit-open-/-kill commands. (If only I could get back a lifetime spent balancing parens in C++/JavaScript!)

(Brief diatribe: computing was set back a few decades by focusing on streams of characters instead of trees of meaningful expressions. We have all these compilers that are AST-aware, but most OSes and version control tools diff text and linefeed/newline/carriage return lines instead of "you changed the type of 2nd argument named 'foo' to function 'bar' inside this macro.")

arichiardi commented 6 years ago

Abit off topic but just wanted to mention that probably inf-clojure already does a good job with syntax highlighting and basic integration would be really easy to do.

The basic operations the "REPL" needs to provide are doc, apropos, ... Lumo already has them. Add faces for closh's few custom operators and that is it. A closh-mode would really be just a few lines of elisp IMHO.

mnewt commented 6 years ago

@arichiardi I agree that a closh-mode is desirable and should be pretty easy, as it would be a tiny wrapper on inf-clojure. I'm using inf-clojure to hack on closh and it's great! I'm currently dropping to a terminal to test it end-to-end though. Would be great to keep it all in emacs. I may take a crack at it when I have the time.

arichiardi commented 6 years ago

Awesome!

NightMachinery commented 6 years ago

@dundalek Lispyville works great with Spacemacs! And who says it doesn't support Parinfer? :D Parinfer layer ;))

dundalek commented 6 years ago

@NightMachinary You are right, it does support in the develop branch. However, it requires emacs26 but my distro has only emacs24. I would have to sideload it or upgrade my OS, which I am not ready to do yet. So from my perspective the support is not yet there :)

NightMachinery commented 6 years ago

You can easily sideload it using Linuxbrew! brew install emacs-plus --HEAD would install version 27.

On Thu, Mar 29, 2018 at 5:50 PM, Jakub Dundalek notifications@github.com wrote:

@NightMachinary https://github.com/NightMachinary You are right, it does support in the develop branch. However, it requires emacs26 but my distro has only emacs24. I would have to sideload it or upgrade my OS, which I am not ready to do yet. So from my perspective the support is not yet there :)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dundalek/closh/issues/22#issuecomment-377232734, or mute the thread https://github.com/notifications/unsubscribe-auth/Aii--vf6fCSmsbT7eAey6rizwMxuKQsIks5tjN-ngaJpZM4QUqt_ .

theronic commented 5 years ago

Some encouragement from the sidelines :) Don't give up on Closh. I need it every day.

I have since switched to Parinfer now that the Cursive implementation is good enough.

dundalek commented 5 years ago

Thanks for the encouragement, it means a lot to me. I would be happier if the progress was faster, but at least it is steady and going forward.

Good to know about finding a way to Parinfer, I also find it is easier to use cognitively.