4 ms·
Congrats! And thank you! This changed my lisp experience and my wishlist for interacting with non-s-exp code when I found it years ago.
by tsuru 4y ago
Congrats! And thank you! This changed my lisp experience and my wishlist for interacting with non-s-exp code when I found it years ago.
- capableweb 4y agoSame here. After getting used to the "automatic" way of editing and writing s-expressions, I can't believe something similar doesn't exists for the C-like code most people write today, but then I remember how much syntax all those languages really contain. Rust is like a trivia answer for "How much syntax could you possibly put into one language?".
- Myrmornis 4y agoBasic paredit operations work surprisingly well on C-like languages like Python. Try it! I think it does ok on Rust too. I'm thinking mainly of paredit-kill and navigating paired delimiters. A long time ago I collected together some tweaks for using it with Python etc here: https://github.com/dandavison/paredit-c https://github.com/dandavison/paredit-c
- mickeyp 4y agoHa. I, too, hacked paredit to work with Python about a decade ago for the same reasons as you. And yes, it does work better than you'd think.
- Myrmornis 4y agoHi Mickey, ah no -- you've done WAY more than me in this area! I had been meaning to try your combobulate package. FWIW: after 20 years of Emacs I personally switched to VSCode a couple of years ago because I felt that in Emacs I was missing out on the LSP experience that VSCode provided in Rust, Typescript, Scala, etc. (I was using Eglot). In any case, there's a very nice Emacs emulation mode in VSCode https://github.com/whitphx/vscode-emacs-mcx https://github.com/whitphx/vscode-emacs-mcx which includes some paredit functionality courtesy of https://robert.kra.hn/past-projects/paredit-js.html https://robert.kra.hn/past-projects/paredit-js.html and I'm working on porting my favorite paredit function, paredit-kill. Unfortunately that's the one where the paredit author left this comment in the code: ;;; Please do not try to understand this code unless you have a VERY ;;; good reason to do so. I gave up trying to figure it out well ;;; enough to explain it, long ago.
- capableweb 4y agoDoes it automatically balances all the parenthesis/brackets/other characters? I think that's what I'm missing the most.
- Myrmornis 4y agoYep.
- tuukkah 4y ago> C-like languages like Python I can see Paredit working somehow with the curly brace blocks of C, but how does it handle the significant whitespace of Python? Are indent and dedent handled as tokens?
- Myrmornis 4y agoNo, I've never tried to make it do that. So in Python paredit-kill will not kill a function definition, whereas it would in a language that uses braces for function bodies.
- mickeyp 4y agoI did something far cruder which is also how paredit itself works internally. Redefine the meaning of moving up, down, left or right by syntactic token. In Python up/down is either by block (try, if, etc.) or by s-exp ([], {}, etc.) which Emacs is already capable of doing. By doing that you can effectively teach paredit a little bit about how the language works, as you're moving point around for it. Note that my crude hack was never more than a prototype. Though it did work in more places than it ought to.
- bhrgunatha 4y agoHere's hoping that type of structured movement and editing will spread much wider now tree-sitter is merged into emacs master. Already quite a few parsers/grammars available for tree sitter: https://tree-sitter.github.io/tree-sitter/#available-parsers https://tree-sitter.github.io/tree-sitter/#available-parsers