Created
January 5, 2014 01:32
-
-
Save Philonous/8263168 to your computer and use it in GitHub Desktop.
This file contains 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 zap-up-to-char (arg char) | |
"Kill up to, but not including ARGth occurrence of CHAR. | |
Case is ignored if `case-fold-search' is non-nil in the current buffer. | |
Goes backward if ARG is negative; error if CHAR not found. | |
Ignores CHAR at point." | |
(interactive "p\ncZap up to char: ") | |
(let ((direction (if (>= arg 0) 1 -1))) | |
(kill-region (point) | |
(progn | |
(forward-char direction) | |
(unwind-protect | |
(search-forward (char-to-string char) nil nil arg) | |
(backward-char direction)) | |
(point))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment