diff options
-rw-r--r-- | emacs/.emacs.d/init/ycp-editing.el | 4 | ||||
-rw-r--r-- | emacs/.emacs.d/lisp/my/my-editing.el | 36 |
2 files changed, 39 insertions, 1 deletions
diff --git a/emacs/.emacs.d/init/ycp-editing.el b/emacs/.emacs.d/init/ycp-editing.el index e9c7e4c..b9ed48b 100644 --- a/emacs/.emacs.d/init/ycp-editing.el +++ b/emacs/.emacs.d/init/ycp-editing.el @@ -40,7 +40,8 @@ (my-package my-editing (:delay 5) (my-keybind global-map - "M-k" #'my-kill-line-backward + "C-k" #'my-kill-forward + "M-k" #'my-kill-backward "M-w" #'my-copy-line-or-region "C-o" #'my-new-line-above-or-below "C-<" #'my-escape-url-dwim @@ -60,6 +61,7 @@ "C-M-y" #'my-yank-primary "C-a" #'my-beginning-of-line-or-indentation ) + (electric-pair-mode) ) (setq viper-mode nil) 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 |