Created
July 14, 2017 04:31
-
-
Save osmatsuda/4ee45880f6d45404c827f829fe0cfe2c 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
;; kill-word-camelcased | |
(defun kill-word-camelcased (arg) | |
"Kill characters forward until the end of a word even if | |
in a camelcased identifier. ARG is same as `kill-word`." | |
(interactive "p") | |
(let ((case-fold-search nil) | |
(start (point)) | |
(bound (save-excursion (forward-word arg) (point))) | |
(succ (if (> arg 0) 1 -1)) | |
current | |
found) | |
(when (not (= start bound)) | |
(setq current start) | |
(while (not (= arg 0)) | |
(forward-word succ) | |
(while (search-forward-regexp "[A-Z][a-z]" | |
(+ current succ) | |
t | |
(- succ)) | |
(setq found t)) | |
(when (and found (< succ 0)) | |
(forward-char -2)) | |
(setq current (point)) | |
(setq arg (- arg succ))) | |
(kill-region start (point))))) | |
(defun backward-kill-word-camelcased (arg) | |
(interactive "p") | |
(kill-word-camelcased (- arg))) | |
(provide 'kill-word-camelcased) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment