From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tom Newsgroups: gmane.emacs.help Subject: Re: In place (live) editing of matches - is there a package for it? Date: Fri, 14 Oct 2011 12:43:50 +0000 (UTC) Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1318596261 26027 80.91.229.12 (14 Oct 2011 12:44:21 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 14 Oct 2011 12:44:21 +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 14:44:18 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 1REh7Z-00036y-Mx for geh-help-gnu-emacs@m.gmane.org; Fri, 14 Oct 2011 14:44:17 +0200 Original-Received: from localhost ([::1]:47502 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1REh7Z-00074Z-0F for geh-help-gnu-emacs@m.gmane.org; Fri, 14 Oct 2011 08:44:17 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:35341) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1REh7V-00074H-AD for help-gnu-emacs@gnu.org; Fri, 14 Oct 2011 08:44:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1REh7U-00049i-5l for help-gnu-emacs@gnu.org; Fri, 14 Oct 2011 08:44:13 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:41310) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1REh7T-00049G-RE for help-gnu-emacs@gnu.org; Fri, 14 Oct 2011 08:44:12 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1REh7J-0002zY-Nv for help-gnu-emacs@gnu.org; Fri, 14 Oct 2011 14:44:03 +0200 Original-Received: from 94-21-170-9.pool.digikabel.hu ([94.21.170.9]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 14 Oct 2011 14:44:01 +0200 Original-Received: from adatgyujto by 94-21-170-9.pool.digikabel.hu with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 14 Oct 2011 14:44:01 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 33 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: sea.gmane.org User-Agent: Loom/3.14 (http://gmane.org/) X-Loom-IP: 94.21.170.9 (Opera/9.80 (Windows NT 6.1; U; en) Presto/2.9.168 Version/11.51) 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:82556 Archived-At: Tom 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.