diff options
author | Kyle Meyer <meyerkya@gmail.com> | 2013-07-02 15:20:56 -0400 |
---|---|---|
committer | Kyle Meyer <meyerkya@gmail.com> | 2013-07-02 18:35:30 -0400 |
commit | 19fe6d682e5207c1663ff805a8267bf2e1a28938 (patch) | |
tree | 97b4acd22fdeaa57a9ea17c15218cf39953464df | |
parent | a86d7c415f780e1cd1bb8802da2c2d789c8097f9 (diff) | |
download | emacs.d-19fe6d682e5207c1663ff805a8267bf2e1a28938.tar.gz |
kill at point functions
Functions to grab thing at point and then delete the whole thing (as
opposed to the part of the thing after the point).
Add functions and bindings for string, sentence, word, paragraph, and
line. Put bindings under common "C-c k" prefix.
-rw-r--r-- | init/km-func.el | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/init/km-func.el b/init/km-func.el index 1f2c809..5c36208 100644 --- a/init/km-func.el +++ b/init/km-func.el @@ -73,3 +73,43 @@ user." (setq beg (line-beginning-position) end (line-end-position))) (comment-or-uncomment-region beg end)) (forward-line)) + +;; kill functions + +(defun km/kill-string-at-point () + (interactive) + (let ((string-start (nth 8 (syntax-ppss)))) + (goto-char string-start) + (kill-sexp))) + +(defun km/kill-thing-at-point (thing killthing killarg) + "Go to the beginning of THING and call KILLTHING with +KILLARG." + (goto-char (beginning-of-thing thing)) + (funcall killthing killarg)) + +(defun km/kill-sentence-at-point (arg) + (interactive "P") + (km/kill-thing-at-point 'sentence 'kill-sentence arg)) + +(defun km/kill-word-at-point (arg) + (interactive "P") + (km/kill-thing-at-point 'word 'kill-word arg)) + +(defun km/kill-paragraph-at-point (arg) + (interactive "P") + (km/kill-thing-at-point 'paragraph 'kill-paragraph arg)) + +(defun km/kill-line-at-point (arg) + (interactive "P") + (km/kill-thing-at-point 'line 'kill-line arg)) + +(defun km/kill-sexp-at-point (arg) + (interactive "P") + (km/kill-thing-at-point 'sexp 'kill-sexp arg)) + +(global-set-key (kbd "C-c k s") 'km/kill-string-at-point) +(global-set-key (kbd "C-c k .") 'km/kill-sentence-at-point) +(global-set-key (kbd "C-c k w") 'km/kill-word-at-point) +(global-set-key (kbd "C-c k p") 'km/kill-paragraph-at-point) +(global-set-key (kbd "C-c k l") 'km/kill-line-at-point) |