Skip to content

Instantly share code, notes, and snippets.

@ptrv
Last active December 18, 2015 22:49
Show Gist options
  • Save ptrv/5857342 to your computer and use it in GitHub Desktop.
Save ptrv/5857342 to your computer and use it in GitHub Desktop.
(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