bbatsov / prelude

Prelude is an enhanced Emacs 25.1+ distribution that should make your experience with Emacs both more pleasant and more powerful.
https://prelude.emacsredux.com
5.1k stars 1.85k forks source link

web-mode smartparens issue with ERB #941

Closed hut8 closed 5 years ago

hut8 commented 8 years ago

Thank you very much for Prelude. I've spent years perfecting my .emacs, then tried Prelude and it immediately won me over :+1:

I have found one rather irritating bug when editing ERB templates in web-mode: Typing < % is fine, resulting in <%|%> where | is the point. But then, typing < % `(with a space) results in this:<% |%>%>` -- :open_mouth:

I tried this with a fresh clone so I believe it should work fine. I believe the bug is somewhere in modules/prelude-web.el but my emacs lisp-foo is weak. Going through the source to try to find the issue, I saw that you added a shortcut, C-c % which does this correctly (and more quickly). However I wouldn't expect that this would actually break the old-fashioned way.

Thoughts?

cank commented 8 years ago

I am running into this issue too. Adding the following to my personal/custom.el file fixes it, but then obviously removes auto-paring of %

(sp-local-pair '(web-mode) "%" nil :actions :rem)

The error seems to stem from this commit: https://github.com/bbatsov/prelude/commit/207ec885db240b24e19e4613b87e6b5665638da6

I can submit a pull request simply removing the definition for the '%' pair, but this seems like it will break whatever was originally intended to be fixed.

hut8 commented 8 years ago

@cank did you update your packages today or yesterday? It looks fixed to me now (I saw that smartparens updated itself). I'm going to go ahead and close it.

hut8 commented 8 years ago

Whoops, still happens with <% %> -- that was not fixed. Sorry.

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution and understanding!

stale[bot] commented 5 years ago

This issues been automatically closed due to lack of activity. Feel free to re-open it if you ever come back to it.

mruegenberg commented 3 years ago

(|=cursor in the below)

Hi, I've just run into this issue. Typing <% (ie space at the end) results in <% %>> rather than the expected <% %>, same for <%= resulting in <%= %>>.

Similarly, without a space, I'd still want <%|%>.

Also, it's not possible to just "type through" the end of the parenthesed expression, i.e I can't first type <% end and then type %> without actually inserting extra symbols. The reason is that the space isn't recognized as part of the closing paren (might be a bit tricky to make it work, since it would only be part of the closing paren if followed by %>.

When typing <%|, I get <%|> , but in this case can also just keep typing to close it (I assume because < is recognized as the paren character)

The above fix doesn't really change anything for me.

mruegenberg commented 3 years ago

Quick update:

copying some of the code here: https://github.com/bbatsov/prelude/blob/master/modules/prelude-web.el made the two play nicely together, but it might be good to incorporate these improvements into smartparens (or web-mode)