-
Notifications
You must be signed in to change notification settings - Fork 42
Description
Unbalanced | inside a comment:
;; |
(defun foo (
2Maybe similar to the "dangerous quotes" problem with an unbalanced " in a comment, but I think this one could come up more often.
If so, it should at least be documented along with ".
The documentation on dangerous quotes suggests that this wouldn't be an issue if we could tell start quotes from end quotes. Not 100% reliable, but usually, you can tell if a " starts or ends a string by the immediately surrounding characters. A (" or " probably starts a string, while a ") or " probably ends it. On the other hand, | can occur inside of symbols, so it's not as easy, but again, they're usually on the outside, so a (| or | probably starts a symbol, while a |) or | probably ends it. You could tally the whole file and see if most of the quotes you think are start quotes look like start quotes and if most of the end quotes look like end quotes. If it's the reverse, you're probably in a temporary inverted situation. Another heuristic might be the relative length of code vs strings.
Maybe most of the time you could get buy on these heuristics, but in cases where certainty isn't as high, you could fall back to the current behavior. The user needs to know why this is happening though.
Is it possible for Parinfer to at least report the location of the dangerous " or | so the editor can highlight it? (Or does it do this already?) The Spacemacs Parinfer layer, at least, doesn't handle this very well. It just mysteriously stops working, maybe with a cryptic #<user-ptr... message that's easy to miss.
It would also be nice if there was a way to turn Parinfer off for just a section of the code. Something like a ;; Parinfer: off and ;; Parinfer: on pair. This would make it easier for the user to find problems with a binary search approach. It would also allow a dangerous " or | if the user super needs it for some reason without giving up on Parinfer for the whole file. A ;; Parinfer: skip above a top-level form could also help. It might be easier to implement.