|
From: | ishi soichi |
Subject: | Re: repeating input with different outputs |
Date: | Sat, 15 Oct 2011 12:07:51 +0900 |
Of course.On 10/14/2011 07:20 AM, ishi soichi wrote:
I have a question about typing (or programming, or maybe a macro).
Say, I'm writing a text (which can be in any mode, html-mode, cpp-mode,
or whatever)
I would like to input like
chapter 4.1
chapter 4.2
chapter 4.3
...
chapter 4.46
So, it is very tedious. I would rather set up a program or a command
that can do this job instantaneously.
Could Emacs do this?
I copied this off the group years ago. Incorporate it in a keyboard macro and you're done.
(defun increment (n) (interactive "p")
;; Increment the number after point. With an argument, add that much.
(let (val)
(delete-region
(point)
(progn
(setq val (read (current-buffer)))
(if (not (numberp val)) (error "Not in front of a number"))
(point)))
(insert (int-to-string (+ val n)))))
(global-set-key "\C-c+" 'increment)
[Prev in Thread] | Current Thread | [Next in Thread] |