From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ken Goldman Newsgroups: gmane.emacs.help Subject: Re: repeating input with different outputs Date: Fri, 14 Oct 2011 13:43:14 -0400 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1318614222 1251 80.91.229.12 (14 Oct 2011 17:43:42 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 14 Oct 2011 17:43:42 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Oct 14 19:43:38 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RElnF-0002av-7f for geh-help-gnu-emacs@m.gmane.org; Fri, 14 Oct 2011 19:43:37 +0200 Original-Received: from localhost ([::1]:59054 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RElnE-00030o-SD for geh-help-gnu-emacs@m.gmane.org; Fri, 14 Oct 2011 13:43:36 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:34127) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RElnA-0002zx-67 for help-gnu-emacs@gnu.org; Fri, 14 Oct 2011 13:43:33 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1REln9-0005tP-9U for help-gnu-emacs@gnu.org; Fri, 14 Oct 2011 13:43:32 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:56611) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1REln9-0005tB-3C for help-gnu-emacs@gnu.org; Fri, 14 Oct 2011 13:43:31 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1REln7-0002Ws-2y for help-gnu-emacs@gnu.org; Fri, 14 Oct 2011 19:43:29 +0200 Original-Received: from yktgi01e0-s5.watson.ibm.com ([129.34.20.19]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 14 Oct 2011 19:43:28 +0200 Original-Received: from kgold by yktgi01e0-s5.watson.ibm.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 14 Oct 2011 19:43:28 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 37 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: yktgi01e0-s5.watson.ibm.com 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 In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 80.91.229.12 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:82559 Archived-At: 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)