here custom function:

(defun increment-number-at-point(number)
  (interactive "nInput increment number:")
  (skip-chars-backward "0-9")
  (or (looking-at "[0-9]+")
      (error "No number at point"))
  (replace-match (number-to-string (+ number (string-to-number (match-string 0))))))

Nice it's work fine. But I want to set default value (1) when user not input any number.


Use read-number directly:

(interactive (list (read-number "Input increment number: " 1)))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.