nflath / hungry-delete

Enables hungry deletion in all modes.
98 stars 16 forks source link

Add reluctant joining #41

Closed anlsh closed 4 years ago

anlsh commented 4 years ago

Hi, I was a little annoyed by how hungry delete would often join words when I really just wanted to delete some extra whitespace between them.

;; State A
(defun foo ()    (bar))
                 ^
;; Press backspace
;; State B
(defun foo ()(bar))
             ^

I feel that better behavior for hungry deletion in state A would be to transition to the following state

;; State C
(defun foo () (bar))
              ^

From where the user could press backspace again to get to state C

This change adds a switch, hungry-delete-join-reluctantly, to enable the above behavior. The switch is off by default of course, so the default behavior should be unchanged

From my rudimentary testing, it seems to work as I expect it to. Let me know if the code looks good and if you'd consider merging the PR. If so, I'll amend the readme to add some documentation as well

anlsh commented 4 years ago

Looks like I should be defining the switch via defcustom at the very least