Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent paredit from inserting a space when inserting parentheses - and other issues

Tags:

emacs

paredit

I love paredit. But there are a couple of things I hate, and have not yet come around to fixing them:

  • Opening a parenthesis inserts a space before the parenthesis. I understand this is probably the preferred style of the whole internet, but it is not mine. How can avoid this?
  • When inside a quoted area (''), I am not able to back-delete. Also, typing a double quote (") will insert a backslash (obviously to escape the double quote - only that this is not needed, at least in python. So I do not want the backslash. How to configure this?
  • Actually, paredit tries (and fails) to be very wise relating backspace. My backspace should always delete the previous character, no matter whether I am in an unfinished quoting area (paredit just refuses to do anything if the quotes do not match. Try to delete here: "helloo). The only situation where a delete makes sense to be treated specially is when the point is just before an opening parenthesis.
like image 530
blueFast Avatar asked Nov 24 '25 17:11

blueFast


2 Answers

This is not an answer, but too long for a comment...

Paredit is intended for languages where not having a space before a ( would be horrible, and ones that do not have python's "quote-cleverness". You could probably hack it for these issues, but the syntax of python is sufficiently different that making it work there would be a non-trivial project.

As for your last point, that sounds like you don't want paredit at all, since it's very intentionally trying to keep your parens & quotations balanced, so maybe it's not the right tool for you. IOW, you might prefer auto pairs or electric pair or a bunch of other similar tools.

like image 113
Eli Barzilay Avatar answered Nov 28 '25 15:11

Eli Barzilay


You can customize paredit's insertion of space around delimiters via the paredit-space-for-delimiter-predicates variable -- see the docstring for details. There are some examples of its use kicking around the internet, but I don't remember where they are.

Paredit's handling of strings is limited to the string notation common to many Lisps, and changing it is not trivial, so if you want to use it with exotic syntax such as Python's various one-or-three-delimiter single-or-double-quote formats, you'll need to mess around deep inside paredit.

like image 36
Edmund Wells Avatar answered Nov 28 '25 15:11

Edmund Wells