all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tom <adatgyujto@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: In place (live) editing of matches - is there a package for it?
Date: Fri, 14 Oct 2011 12:43:50 +0000 (UTC)	[thread overview]
Message-ID: <loom.20111014T143752-662@post.gmane.org> (raw)
In-Reply-To: loom.20111014T125114-246@post.gmane.org

Tom <adatgyujto <at> gmail.com> writes:

> 
> It occurred to me it would be more convenient if I could just select
> the word (or a phrase) and use a command which allows me to live edit
> this region, so that all the changes I make within the selected part are
> reflected instantly at all the other places in the file which have
> the same text as the initial selection.
> 

I created this trivial function which does this without the instant visual 
feedback, but at least it spares me copying the text, going back
to the beginning of buffer, pasting it to the replace prompt and when all
instances are replaced then going back to the place where the whole
thing is started:

(defun my-replace-region ()
  (interactive)
  (unless (use-region-p)
    (error "no region"))
  (let ((what (buffer-substring-no-properties
               (region-beginning) (region-end)))
        (replacement (read-string "replace with: ")))
    (save-excursion
      (goto-char (point-min))
      (while (search-forward what nil t)
        (replace-match replacement)))))

The live feedback would be better, because it's more fancy and the
user can see an instant confirmation of the replacements during typing
if more than one of them is visible on the screen. 






  parent reply	other threads:[~2011-10-14 12:43 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-14 10:57 In place (live) editing of matches - is there a package for it? Tom
2011-10-14 11:09 ` mehran khajavi
2011-10-14 11:15   ` Tom
2011-10-14 11:17 ` Jambunathan K
2011-10-14 11:24   ` Tom
2011-10-14 12:43 ` Tom [this message]
2011-10-14 13:08   ` Drew Adams
2011-10-14 13:35     ` Tom

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=loom.20111014T143752-662@post.gmane.org \
    --to=adatgyujto@gmail.com \
    --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.