-
Notifications
You must be signed in to change notification settings - Fork 22
Useful commands
AmaiKinono edited this page Sep 7, 2021
·
5 revisions
This kill-line
command will kill backward if nothing can be killed forward. So you can press C-k
twice to kill the part inside the pairs. One more C-k
will kill the pairs.
(defun my-kill-line ()
"Kill a line forward while keeping expressions balanced.
If nothing can be deleted, kill backward. If still nothing can be
deleted, kill the pairs around point."
(interactive)
(let ((bounds (puni-bounds-of-list-around-point)))
(if (eq (car bounds) (cdr bounds))
(when-let ((sexp-bounds (puni-bounds-of-sexp-around-point)))
(puni-delete-region (car sexp-bounds) (cdr sexp-bounds) 'kill))
(if (eq (point) (cdr bounds))
(puni-backward-kill-line)
(puni-kill-line)))))