From 19fe6d682e5207c1663ff805a8267bf2e1a28938 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Tue, 2 Jul 2013 15:20:56 -0400 Subject: 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. --- init/km-func.el | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'init/km-func.el') 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) -- cgit v1.2.3