Hacker News new | past | comments | ask | show | jobs | submit login

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.



Same 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?".


Basic 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


Ha. 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.


Hi 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

which includes some paredit functionality courtesy of

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.


> 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?


I 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.


No, 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.


Does it automatically balances all the parenthesis/brackets/other characters? I think that's what I'm missing the most.


Yep.


Here'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




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: