Mismatched sexp state: wrapping would break structure
Expected behavior
Pressing '(' with text selected should wrap in parens
Actual behavior
Most of the time it works. Then the the problem described below will start happening, and things won't work normally again until emacs is restarted.
The '(' appears where point currently is, the closing paren isn't made, and everything in the buffer between point and the next '(' in the buffer is deleted. Then this message appears:
Mismatched sexp state: wrapping would break structure
Steps to reproduce the problem
I have no idea :( I assume it has something to do with who knows what in my config. Looking for any suggestions for how to debug further, since there is no error and I can't consistently reproduce. I think the fact that I have to restart emacs to get the correct behavior suggests maybe the wrapping code modifies global state somewhere?
Backtraces if necessary (M-x toggle-debug-on-error)
None appears.
Environment & version information
-
smartparensversion: 20181028.1005 - Active
major-mode:package-menu-mode - Smartparens strict mode: nil
- Emacs version (
M-x emacs-version): GNU Emacs 26.1 (build 1, x86_64-pc-linux-gnu, X toolkit) of 2018-11-14 - Starterkit/Distribution: Vanilla
- OS: gnu/linux
That definitely sounds odd.
The env information mentions that the major mode is package-menu-mode, is this correct? That buffer should be read only no? I'm asking so I can try to narrow down the repro cases.
I just happened to have the cursor in that buffer when I ran the command, because I was looking up the package version before I realized there was the command to dump the information.
I spend most of my time editing C++ buffers. I thought to check this issue again because it just happened to me again, where I am seeing the same weird deleting behavior, but I am not getting the message this time and instead I actually do get a trace:
Debugger entered--Lisp error: (args-out-of-range #<buffer temp8kZK21> 25 6536)
delete-and-extract-region(6536 25)
sp-wrap--initialize()
sp--post-self-insert-hook-handler()
self-insert-command(1)
funcall-interactively(self-insert-command 1)
call-interactively(self-insert-command nil nil)
command-execute(self-insert-command)
I was in a C++ buffer when this first happened, but the trace is from trying to repeat it in a fundamental buffer.
text beforein a fundamental buffer only one line:
Testing testing testing
then I put cursor here:
Testing |testing testing
activated mark and put cursor here:
Testing testing testing|
then pressed '(' giving me this text and the trace:
Testing testing testing(
Thanks for the additional info! I've labeled the issue so it will pop up in the queue some day. I can't promise when though.
Problem just happened again, but this time erased the whole buffer up to where I tried to do the wrap @_@ Different trace though:
Debugger entered--Lisp error: (wrong-type-argument stringp nil)
propertize(nil face sp-wrap-overlay-opening-pair)
#f(compiled-function (x) #<bytecode 0x1098999>)((:open nil :close "\\\\)" :actions (insert wrap autoskip navigate) :open-real "\\\\("))
mapconcat(#f(compiled-function (x) #<bytecode 0x1098999>) ((:open nil :close "\\\\)" :actions (insert wrap autoskip navigate) :open-real "\\\\(") (:open nil :close "\\}" :actions (insert wrap autoskip navigate) :open-real "\\{") (:open nil :close "\\)" :actions (insert wrap autoskip navigate) :open-real "\\(") (:open nil :close "\\\"" :actions (insert wrap autoskip navigate) :open-real "\\\"") (:open nil :close "\"" :actions (insert wrap autoskip navigate escape) :unless (sp-in-string-quotes-p) :post-handlers (sp-escape-wrapped-region sp-escape-quotes-after-insert) :open-real "\"") (:open nil :close "'" :actions (insert wrap autoskip navigate escape) :unless (sp-in-string-quotes-p sp-point-after-word-p) :post-handlers (sp-escape-wrapped-region sp-escape-quotes-after-insert) :open-real "'") (:open nil :close ")" :actions (insert wrap autoskip navigate) :open-real "(") (:open nil :close "]" :actions (insert wrap autoskip navigate) :open-real "[") (:open nil :close "}" :actions (insert wrap autoskip navigate) :open-real "{") (:open nil :close "`" :actions (insert wrap autoskip navigate) :open-real "`") (:open "\\\\(" :close "\\\\)" :actions (insert wrap autoskip navigate)) (:open "\\{" :close "\\}" :actions (insert wrap autoskip navigate)) (:open "\\(" :close "\\)" :actions (insert wrap autoskip navigate)) (:open "\\\"" :close "\\\"" :actions (insert wrap autoskip navigate)) (:open "\"" :close "\"" :actions (insert wrap autoskip navigate escape) :unless (sp-in-string-quotes-p) :post-handlers (sp-escape-wrapped-region sp-escape-quotes-after-insert)) (:open "'" :close "'" :actions (insert wrap autoskip navigate escape) :unless (sp-in-string-quotes-p sp-point-after-word-p) :post-handlers (sp-escape-wrapped-region sp-escape-quotes-after-insert)) (:open "(" :close ")" :actions (insert wrap autoskip navigate)) (:open "[" :close "]" :actions (insert wrap autoskip navigate)) (:open "{" :close "}" :actions (insert wrap autoskip navigate)) (:open "`" :close "`" :actions (insert wrap autoskip navigate))) " ")
sp-wrap()
sp--post-self-insert-hook-handler()
self-insert-command(1)
funcall-interactively(self-insert-command 1)
call-interactively(self-insert-command nil nil)
command-execute(self-insert-command)
smartparens always deletes text for me if used in a c++ buffer. Also, undo history gets broken.
Same issue here, Emacs version 29.1. Also got similar trace as jgarvin.