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.82k stars 195 forks source link

Issue with deleting region of whitespaces. #703

Closed Ailrun closed 6 months ago

Ailrun commented 7 years ago

Is there any good ways to delete region filled with whitespaces, without deleting wrapped parenthesis?

For example, when we have

(

 |)

and mark region from there to

(|

 )

here, and type <backspace>, the result is

|

but what I want is

(|)

However, when I mark region in reverse direction, i.e.

(|

 )

mark there to

(

 |)

here, and type <backspace>, it just delete whitespaces, so in this case, the result is actually what I want.

()

I think this is the problem of advise of backward-delete-char that use sp-delete-pair, since backward-delete-char takes care about use-region state, where sp-delete-pair does not.

Is there any customizable variable for this situation? Does this issue occurs because of my own ignorance?

I'm waiting your answer, thank you.

Ailrun commented 7 years ago

P.S. in smartparens-strict-mode, <backspace> key can't delete any region at all. Is that behavior intended? If it isn't, is there any plan to fix it?

Fuco1 commented 7 years ago

I can't repro this. In both strict and nonstrict modes it leaves the parens intact with region selected in either way.

What version of emacs/smartparens do you use?

Ailrun commented 7 years ago

I use emacs 25.1 and smartparen 20170129.956 in melpa.

Ailrun commented 7 years ago

When I turn off smartparens-mode, deletion works well.

My emacs settings use

  1. delete-active-region is t. (probably default)
  2. sp-autodelete-pair, closing-pair, openinh-pair are t.
  3. Use company mode.
  4. Problem ocurrs major modes including emacs-lisp-mode.
Ailrun commented 7 years ago

When with these simple configuration, I can reproduce this issue. (emacs without init file, and evaluate (require 'package) (package-initialize) (require 'smartparens) (smartparens-global-mode) and turn off every other minor modes except blink-cursor-mode, font-lock-mode, transient-mark-mode)

image

mark it to,

image

here, and hit <backspace>.

image

Ailrun commented 7 years ago

@Fuco1 I try this for vanilla emacs(not just without init file, but wholly pure emacs) after only installing smartparens, and result is same.

On Windows 10, and Linux(CentOS), with emacs 25.1, installed version of smartparen is 20170129.956.

Ailrun commented 6 years ago

@Fuco1 Sorry for disturbing you. Is there any progress?

Fuco1 commented 6 years ago

Not really. I've switched to Emacs 25 though so I'm slowly going through the issues which were only relevant to that version. I'll schedule this for the next release since you've asked, I might as well randomly prefer this issue over the others ;D

Fuco1 commented 6 years ago

Hey @Ailrun I think this might have been fixed in 7a8dff4c6f0eb433c3f2bb92b04b5aac5d06d416 (about 4 months ago). Can you try to verify this?

Ailrun commented 6 years ago

@Fuco1 It still does not work. I didn't test it with pure emacs, however, I tested with

emacs -q --eval "(progn (load-file \"~/.emacs.d/elpa/dash-20180206.2124/dash.elc\") (load-file \"~/.emacs.d/elpa/smartparens-20180306.305/smartparens.elc\") (smartparens-global-mode))"

and it still delete surrounding parens.

This time, OS is Manjaro 17.1.4, emacs version is 25.3.1,
smartparens version is 20180306.305 melpa,
and dash version is 20180206.2124 melpa.

For your convenience, formatted evaluated code is

(progn
  (load-file "~/.emacs.d/elpa/dash-20180206.2124/dash.elc")
  (load-file "~/.emacs.d/elpa/smartparens-20180306.305/smartparens.elc")
  (smartparens-global-mode))
Fuco1 commented 6 years ago

Are you using delete-selection-mode?

Ailrun commented 6 years ago

@Fuco1 I don't know what it is, so probably I don't use it (or if it's on by default, I use it, since I don't change anything related with it.)

Fuco1 commented 6 years ago

It's built-in mode to handle deleting of active regions but I don't know if it is on by default. Can you try to turn it on (M-x delete-selection-mode) and then try the above scenario?

Ailrun commented 6 years ago

@Fuco1 I just tried it. It's off by default, and even after I turned it on, same issue happened. I also tried again after re-turning it off, and the result is same.

Fuco1 commented 6 months ago

I reproduced the problem and pushed a fix. Thanks for the report!