Created
August 22, 2009 23:39
-
-
Save randrews/173046 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun matching-char (find other delta &optional start level) | |
(save-excursion | |
(let ((level (if level level 0)) | |
(start (if start start (point)))) | |
(if (and | |
start | |
(>= start (point-min)) | |
(<= start (point-max))) | |
(goto-char start) | |
(error "Not within block")) | |
(cond | |
((looking-at find) | |
(if (= level 0) | |
(point) | |
(matching-char find other delta (+ start delta) (- level 1))) | |
) | |
((looking-at other) | |
(matching-char find other delta (+ start delta) (+ level 1))) | |
(t | |
(matching-char find other delta (+ start delta) level) | |
) | |
)))) | |
(defun kill-block () | |
"Kills the brace-delimited block which the point is currently within." | |
(interactive) | |
(kill-region (matching-char "{" "}" -1) | |
(+ 1 (matching-char "}" "{" 1)))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment