all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: chris@grierwhite.com (Christopher J. White)
Subject: Re: Emacs regexp/incrementer question
Date: Fri, 17 Jan 2003 08:44:48 -0500	[thread overview]
Message-ID: <m2iswngab3.fsf@bluesteel.grierwhite.com> (raw)
In-Reply-To: 87lm1kue30.fsf@fbigm.here

[-- Attachment #1: Type: text/plain, Size: 687 bytes --]

>>>>> "tim" == Tim Morley \(remove vegetable for email address\) <Tim> writes:

tim> Does anybody know of a way to include an incrementing number in a
tim> regexp search-and-replace in Emacs? What I want to do is search
tim> for a regexp, and the first time I find it, replace it with "case
tim> 1", the second time replace it with "case 2", etc.

Here's a function that I wrote a while ago...almost what you want.
When run interactively, gives something like:

  Replace [n] skip [1] case1 [2] case2 [3] case3?

Press [n] to skip to next match, [1-3] to replace with the
case1-3, [return] to quit.

Could be modified pretty easily to autoincrement
a value in the replace string.

...cj

[-- Attachment #2: query-replace-regexp-select --]
[-- Type: application/emacs-lisp, Size: 2556 bytes --]

[-- Attachment #3: Type: text/plain, Size: 242 bytes --]


-- 
------------------------------------------------------------------------------
 Christopher J. White                                    chris@grierwhite.com
------------------------------------------------------------------------------ 

[-- Attachment #4: Type: text/plain, Size: 151 bytes --]

_______________________________________________
Help-gnu-emacs mailing list
Help-gnu-emacs@gnu.org
http://mail.gnu.org/mailman/listinfo/help-gnu-emacs

  reply	other threads:[~2003-01-17 13:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-16 11:15 Emacs regexp/incrementer question Tim Morley (remove vegetable for email address)
2003-01-16 12:17 ` Friedrich Dominicus
2003-01-17  9:01   ` Tim Morley (remove vegetable for email address)
2003-01-17 12:59     ` Friedrich Dominicus
2003-01-17 13:44       ` Christopher J. White [this message]
2003-01-17 14:12       ` Tim Morley (remove vegetable for email address)
2003-01-16 14:49 ` Peter Boettcher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2iswngab3.fsf@bluesteel.grierwhite.com \
    --to=chris@grierwhite.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.