all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tim Landscheidt <tim@tim-landscheidt.de>
To: help-gnu-emacs@gnu.org
Subject: Re: How can I enter query-replace in GNU Emacs using a repeatable function based on values in the line currently at point. - Super User
Date: Mon, 21 Jun 2010 15:00:19 +0000	[thread overview]
Message-ID: <m3631c4eik.fsf@passepartout.tim-landscheidt.de> (raw)
In-Reply-To: AANLkTik0Ewu3GgD-IhwK88OJ2KPsWeO0J7kQ1nyQMlJi@mail.gmail.com

Tim Visher <tim.visher@gmail.com> wrote:

> I'd like to take the following data and query-replace occurences of
> each word identifier with the corresponding numeric identifier using
> some sort of repeatable function.

>     -1 ACT/CNS
>     -2 AG NFC
>     -3 AID
>     -4 BBG
>     -5 BIA
>     -6 BLM
>     -7 BOC
>     -8 BPD
>     -9 CCC
>     -10 CDC
>     -11 Census

> In other words, with point at

>     -1 ACT/CNS
>     ^

> I'd like to be able to hit a key and launch into the following command

>     query-replace RET ACT/CNS RET -1 RET
> [...]

From my experience, the easiest way to do that is to copy
the lines to a temporary buffer, hack up a small lisplet:

| (dolist (line '(("-1"  "ACT/CNS")
|                 ("-2"  "AG NFC")
|                 ("-3"  "AID")
|                 ("-4"  "BBG")
|                 ("-5"  "BIA")
|                 ("-6"  "BLM")
|                 ("-7"  "BOC")
|                 ("-8"  "BPD")
|                 ("-9"  "CCC")
|                 ("-10" "CDC")
|                 ("-11" "Census")))
|   (query-replace (car line) (cdr line) nil (point-min) (point-max)))

and then evaluate that in the original buffer with M-x :.

  While it is possible to create a proper "one-key command"
as you intended, chances are that it is very cumbersome and
that you will have to change it soon afterwards when your
requirements shift just a little bit. Directly programming
in Emacs Lisp is much easier and more flexible.

Tim




  reply	other threads:[~2010-06-21 15:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-21 14:35 How can I enter query-replace in GNU Emacs using a repeatable function based on values in the line currently at point. - Super User Tim Visher
2010-06-21 15:00 ` Tim Landscheidt [this message]
2010-06-21 16:18   ` Tim Visher
     [not found]   ` <mailman.0.1277137734.5294.help-gnu-emacs@gnu.org>
2010-06-24  7:38     ` bolega
2010-06-28  7:32       ` Fren Zeee

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=m3631c4eik.fsf@passepartout.tim-landscheidt.de \
    --to=tim@tim-landscheidt.de \
    --cc=help-gnu-emacs@gnu.org \
    /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.