[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: repeating input with different outputs

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: 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)
      (setq val (read (current-buffer)))
      (if (not (numberp val)) (error "Not in front of a number"))
   (insert (int-to-string (+ val n)))))
(global-set-key "\C-c+" 'increment)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]