diff --git a/puni.el b/puni.el index 799c90d..f560097 100644 --- a/puni.el +++ b/puni.el @@ -1482,6 +1482,19 @@ Continue? ")) (puni-delete-region beg end))) (user-error "No active region"))) +;;;###autoload +(defun puni-kill-region (beg end) + "Kill region (from BEG to END). +When this will cause unbalanced state, ask the user to confirm, +unless `puni-confirm-when-delete-unbalanced-active-region'." + (interactive "r") + (when (or (not puni-confirm-when-delete-unbalanced-active-region) + (puni-region-balance-p beg end) + (y-or-n-p "Delete the region will cause unbalanced state. \ +Continue? ")) + (setq this-command 'kill-region) + (puni-delete-region beg end 'kill))) + ;;;###autoload (defun puni-kill-active-region () "Kill active region. @@ -1491,12 +1504,7 @@ unless `puni-confirm-when-delete-unbalanced-active-region'." (if (use-region-p) (let ((beg (region-beginning)) (end (region-end))) - (when (or (not puni-confirm-when-delete-unbalanced-active-region) - (puni-region-balance-p beg end) - (y-or-n-p "Delete the region will cause unbalanced state. \ -Continue? ")) - (setq this-command 'kill-region) - (puni-delete-region beg end 'kill))) + (puni-kill-region beg end)) (user-error "No active region"))) ;;;;; Char @@ -2563,7 +2571,7 @@ S-expression." (define-key map (kbd "C-k") 'puni-kill-line) (define-key map (kbd "C-S-k") 'puni-backward-kill-line) (define-key map (kbd "C-c DEL") 'puni-force-delete) - (define-key map (kbd "C-w") 'puni-kill-active-region) + (define-key map (kbd "C-w") 'puni-kill-region) (define-key map (kbd "C-M-f") 'puni-forward-sexp) (define-key map (kbd "C-M-b") 'puni-backward-sexp) (define-key map (kbd "C-M-a") 'puni-beginning-of-sexp)