
(defun ++ ()
  "Increment the number (in base 10 representation) at point."
  (interactive)
  (if (looking-at "[-0-9]+")
      (progn
	(let ((num (car (read-from-string (buffer-substring (match-beginning 0) (match-end 0))))))
	  (delete-region (match-beginning 0) (match-end 0))
	  (insert (format "%d" (1+ num)))))))


(defun input (arg)
  "Get input from the user during a keyboard macro.
The input is read from the minibuffer and inserted
at the point.  The mark is set at the beginning of
the input, unless a (non-nil) prefix argument is passed.   
The point is left at the end of the input."
  (interactive "P")
  (or arg (push-mark (point)))
  (insert
   (if executing-kbd-macro 
       (let ((executing-kbd-macro nil))
	 (read-from-minibuffer "Keyboard-macro input: "))
     (if defining-kbd-macro
	 "<user-input>"
      (error "You're neither defining nor executing a keyboard macro!")))))

(defun goto-10 ()
  "End the current keyboard macro and make it loop back on itself
endlessly.  Note: this only works with the `last' keyboard macro;
it will fail after you name the keyboard macro."
  (interactive)
  (if defining-kbd-macro
      (progn
	(end-kbd-macro)
	(message "Repeating keyboard macro defined."))
    (if executing-kbd-macro
	(progn
	  (sit-for 0)			;Refresh, so the user can see how much has happened
	  (call-last-kbd-macro)
      (error "You're neither defining nor executing a keyboard macro!")))))

