Skip to content

Commit

Permalink
enh: allow C-w to work on inactive regions, like the stock one
Browse files Browse the repository at this point in the history
  • Loading branch information
vifon authored Jan 22, 2023
1 parent 7838df1 commit 93a25f7
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions puni.el
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 93a25f7

Please sign in to comment.