nflath / hungry-delete

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

Add hungry-delete-chars-to-skip for customization. #15

Closed jschaf closed 10 years ago

jschaf commented 10 years ago

I factored out the whitespace character string into a separate variable because it allows for easier customization.

Specifically, I wanted to define a function that deletes non-vertical white-space on the first press and all whitespace on the second press.

Without a way to modify the characters that are skipped it would have been much more difficult. The function I defined using the refactor is below.

(defun my:hungry-delete-backward (n &optional killflag)
  "Delete non-vertical whitespace backwards on first key press.
Delete all whitespace on a successive key press."
  (interactive "p\nP")
  (if (eq last-command 'my:hungry-delete-backward)
      (hungry-delete-backward n killflag)
    (let ((hungry-delete-chars-to-skip " \t\f\v"))
      (hungry-delete-backward n killflag))))
mwfogleman commented 10 years ago

Looks good!

nflath commented 10 years ago

Thanks!