Fuco1 / smartparens

Minor mode for Emacs that deals with parens pairs and tries to be smart about it.
GNU General Public License v3.0
1.83k stars 194 forks source link

Typing C-k (sp-kill-hybrid-sexp) kills to the end of the line inside of a sexp in a comment when smartparens-strict-mode is enabled. #838

Open wusticality opened 6 years ago

wusticality commented 6 years ago

Expected behavior

Typing C-k (sp-kill-hybrid-sexp) inside of a sexp in a comment should only kill to the end of the sexp, not to the end of the line when smartparens-strict-mode is enabled.

Actual behavior

Typing C-k (sp-kill-hybrid-sexp) inside of a sexp in a comment kills to the end of the line when smartparens-strict-mode is enabled.

Steps to reproduce the problem

Open a lisp buffer, put a sexp into a comment, enable smartparens-strict-mode, and type C-k inside of the sexp.

Feature Requests

A few related feature requests (not sure where to put them):

Environment & version information

Fuco1 commented 6 years ago

Some strict mode features work inside comments, for example you can't delete a paren with backspace or C-d. Some do not, for example C-k as you mention.

This is a bit unfortunate situation we're in. I can see that sp-strict-mode-affects-comments might be useful but probably people will then want to customize subsets of commands as well... in the past these global settings did not work the best for us.

I have lot of ideas about the configuration but I don't want to make it extremly complicated... and there's a lot of things now which are not quite consistent across all the settings/modes :D The banes of legacy software hah.

wusticality commented 6 years ago

Yeah I was wondering about that. Seems like it'd be good to treat comments entirely separately, that is, to have smartparens-strict-mode enabled for regular code, but not for comments. Or perhaps to allow exactly how strict it is for comments. I realize that sounds like a nightmare.

On that front, I have a really pressing question about strings. I sometimes have stuff like this in code:

(setq foo "(")

This seems to break smartparens everywhere else in the buffer when smartparens-strict-mode is enabled (for example, trying to delete an arbitrary defun will die with a message about being unbalanced). This also makes it damn near impossible to construct regular expressions in strings. I'm not sure what the workaround is for this outside of using rx or something which isn't ideal.

I've noticed that paredit (which I've used for awhile) will only holler about being unbalanced if you actually navigate into "(" which is really nice. Thoughts?

Fuco1 commented 6 years ago

Having (setq foo "(") should not be a problem at all because the balance check in code skips the strings. Can you give a repro? I put that string in an elisp buffer and can delete it without any problem.

wusticality commented 6 years ago

Sure thing, let me get back to you on that, I remember it happening in my init.el. :)