summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2014-03-21 00:26:51 -0400
committerKyle Meyer <kyle@kyleam.com>2014-03-21 00:26:51 -0400
commit736679834f182d369bd37a16efbc6bd0024d6f0c (patch)
treea232213cd3527814548eb8da3353f98cfcd4ab59 /lisp
parentec3a274842dc0e47589572ea8c51c235f8e792eb (diff)
downloademacs.d-736679834f182d369bd37a16efbc6bd0024d6f0c.tar.gz
Use macro to define kill-thing-at-point functions
Diffstat (limited to 'lisp')
-rw-r--r--lisp/init-editing.el36
1 files changed, 11 insertions, 25 deletions
diff --git a/lisp/init-editing.el b/lisp/init-editing.el
index 272e51f..5b0bcd8 100644
--- a/lisp/init-editing.el
+++ b/lisp/init-editing.el
@@ -135,31 +135,17 @@
(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))
+(defmacro km/make-kill-thing-at-point (name thing kill-func)
+ `(defun ,(intern (concat "km/kill-" name "-at-point")) (arg)
+ (interactive "p")
+ (goto-char (beginning-of-thing ,thing))
+ (funcall ,kill-func arg)))
+
+(km/make-kill-thing-at-point "word" 'word 'kill-word)
+(km/make-kill-thing-at-point "sentence" 'sentence 'kill-sentence)
+(km/make-kill-thing-at-point "paragraph" 'paragraph 'kill-paragraph)
+(km/make-kill-thing-at-point "line" 'line 'kill-line)
+(km/make-kill-thing-at-point "sexp" 'sexp 'kill-sexp)
(define-key kill-map "s" 'km/kill-string-at-point)
(define-key kill-map "." 'km/kill-sentence-at-point)