help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: repeating input with different outputs


From: ishi soichi
Subject: Re: repeating input with different outputs
Date: Sat, 15 Oct 2011 12:07:51 +0900

Thanks all of you.
Emacs is great! There are still many capabilities that I don't know.

soichi

2011/10/15 Ken Goldman <kgold@watson.ibm.com>
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)





reply via email to

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