|
From: | Ken Goldman |
Subject: | Re: repeating input with different outputs |
Date: | Fri, 14 Oct 2011 13:43:14 -0400 |
User-agent: | Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.23) Gecko/20110927 Red Hat/3.1.15-1.el6_1 Thunderbird/3.1.15 |
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?
Of course.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] |