-
Notifications
You must be signed in to change notification settings - Fork 22
Useful commands
AmaiKinono edited this page Aug 19, 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.
(defun my-kill-line ()
"Kill a line forward while keeping expressions balanced.
If nothing can be deleted, kill backward."
(interactive)
(let ((forward-line (lambda ()
(if (eolp) (forward-char) (end-of-line))))
(backward-line (lambda ()
(if (bolp) (forward-char -1) (beginning-of-line)))))
(and
(or (puni-soft-delete-by-move forward-line 'strict-sexp 'beyond 'kill)
(puni-soft-delete-by-move backward-line 'strict-sexp 'beyond 'kill))
;; Reindent this line.
(when (not (puni--line-empty-p))
(save-excursion (indent-according-to-mode))))))