diff options
author | Yuchen Pei <id@ypei.org> | 2023-06-24 16:53:03 +1000 |
---|---|---|
committer | Yuchen Pei <id@ypei.org> | 2023-06-24 17:09:10 +1000 |
commit | ba77033a0c81952f5b9b8e140a17c4d12f4e9d05 (patch) | |
tree | ceb04536bff256d739d949d34634006a2d1bd8f9 /emacs/.emacs.d/lisp/my | |
parent | 1753d0dfa0d6ddb413ac868dfa25011e5bfa8983 (diff) |
make C-k and M-k act like paredit
Diffstat (limited to 'emacs/.emacs.d/lisp/my')
-rw-r--r-- | emacs/.emacs.d/lisp/my/my-editing.el | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/emacs/.emacs.d/lisp/my/my-editing.el b/emacs/.emacs.d/lisp/my/my-editing.el index bd3ca83..a8fe822 100644 --- a/emacs/.emacs.d/lisp/my/my-editing.el +++ b/emacs/.emacs.d/lisp/my/my-editing.el @@ -336,5 +336,41 @@ Basically move the line up (goto-line line) (forward-char col))) +(defun my-kill-forward () + "Kill towards end of line, but not out of sexp." + (interactive) + (if (eolp) + (delete-char 1) + (let ((end) + (eol (save-excursion (end-of-line) (point)))) + (save-excursion + (skip-chars-forward " \t") + (while (not (or (eq end (point)) + (>= (point) eol))) + (setq end (point)) + (ignore-errors (forward-sexp)) + (skip-chars-forward " \t")) + (when (> (point) eol) (skip-chars-backward " \t")) + (setq end (point))) + (kill-region (point) end)))) + +(defun my-kill-backward () + "Kill towards beginning of line, but not out of sexp." + (interactive) + (if (bolp) + (delete-char -1) + (let ((beg) + (bol (save-excursion (beginning-of-line) (point)))) + (save-excursion + (skip-chars-backward " \t") + (while (not (or (eq beg (point)) + (<= (point) bol))) + (setq beg (point)) + (ignore-errors (backward-sexp)) + (skip-chars-backward " \t")) + (when (< (point) bol) (skip-chars-forward " \t")) + (setq beg (point))) + (kill-region beg (point))))) + (provide 'my-editing) ;;; my-editing.el ends here |