Last active
December 18, 2015 22:49
-
-
Save ptrv/5857342 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 change-number-at-point (op val) | |
"Change number of at point by applying OP and VAL." | |
(save-excursion | |
(save-match-data | |
(or (looking-at "[0123456789]") | |
(error "No number at point")) | |
(replace-match | |
(number-to-string | |
(mod (funcall (apply-partially op (string-to-number (match-string 0))) val) 10)))))) | |
(defun increment-number-at-point (&optional arg) | |
(interactive "p*") | |
(change-number-at-point '+ (or arg 1))) | |
(defun decrement-number-at-point (&optional arg) | |
(interactive "p*") | |
(change-number-at-point '- (or arg 1))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment