smartparens icon indicating copy to clipboard operation
smartparens copied to clipboard

smartparens not working with delete-selection-mode enabled

Open LukeXuan opened this issue 5 years ago • 4 comments

Expected behavior

The expression in the region should be wrapped by brackets.

Actual behavior

The region gets deleted and/or strange unpaired brackets get inserted.

Also, when trying to view sp-local-pairs, an error is raised.

Steps to reproduce the problem

For any csharp/c/c++ file on my computer, it does not work. (However, smartparens is still working in elisp mode)

Backtraces if necessary (M-x toggle-debug-on-error)

For sp-local-pairs,

Debugger entered--Lisp error: (scan-error "Containing expression ends prematurely" 845 845)
  scan-sexps(847 -1)
  forward-sexp(-1)
  calculate-lisp-indent((2 845 879 nil nil nil 1 nil nil (1 845) nil))
  lisp-indent-calc-next(#s(lisp-indent-state :stack (1 nil) :ppss (1 1 772 nil nil nil 1 nil nil (1) nil) :ppss-point 843))
  indent-sexp()
  pp-buffer()
  describe-variable(sp-local-pairs)
  funcall-interactively(describe-variable sp-local-pairs)
  call-interactively(describe-variable)
  lazy-helm/describe-variable()
  funcall-interactively(lazy-helm/describe-variable)
  call-interactively(lazy-helm/describe-variable nil nil)
  command-execute(lazy-helm/describe-variable)

Environment & version information

  • smartparens version: 20181007.1501
  • Active major-mode: c++-mode
  • Smartparens strict mode: nil
  • Emacs version (M-x emacs-version): GNU Emacs 26.1 (build 1, x86_64-apple-darwin18.0.0, Carbon Version 158 AppKit 1671) of 2018-10-21
  • Starterkit/Distribution: Spacemacs dev
  • OS: darwin

LukeXuan avatar Oct 21 '18 07:10 LukeXuan

Possible reason: something from rtag break it. Didn't confirm but it works now when I disable rtag mode. It's strange that rtag does never throw any error.

LukeXuan avatar Oct 21 '18 07:10 LukeXuan

I have pushed a fix which might have been related to this issue. Can you check on the latest master build? (it will be on melpa in a couple hours or you can grab the git version manually)

Fuco1 avatar Oct 27 '18 09:10 Fuco1

I'm using version 20181027.1542 from melpa and it's still broken when rtags enabled and working when rtags disabled. I might report the bug to rtags as well.

LukeXuan avatar Oct 27 '18 22:10 LukeXuan

Did this ever get fixed? I am using smartparens with c/c++ mode and if I select a region and insert a parenthesis - it just wipes out entire region and leaves me with empty string. Seems to be only happening with c/c++ mode. I am not using rtags though but I do have lsp-mode enabled and delete-selection-mode enabled.

gnufied avatar Sep 20 '21 16:09 gnufied

In C++ mode if I select a region and press (, [ or { it gets wrapped normally. Maybe there are some other "electric" settings from c++ mode interfering? I can't reproduce this issue.

Fuco1 avatar Mar 24 '24 16:03 Fuco1

I no longer actively write code in C++ and I also changed my emacs packages drastically in last few years. All I can say is it's working for me right now.

LukeXuan avatar Mar 25 '24 20:03 LukeXuan

Thank you for the feedback. I will close the issue now as it was already very old (sorry for being so slow :blush:). Hopefully it is fixed now.

Fuco1 avatar Mar 25 '24 21:03 Fuco1