From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Robert Thorpe Newsgroups: gmane.emacs.help Subject: Re: elisp code for replacing every other occurence in a line? Date: Mon, 12 May 2014 21:43:16 +0100 Message-ID: <87oaz24tjv.fsf@robertthorpeconsulting.com> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1399927438 27128 80.91.229.3 (12 May 2014 20:43:58 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 12 May 2014 20:43:58 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Frank Stutzman Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon May 12 22:43:50 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Wjx4g-0006Qc-Jb for geh-help-gnu-emacs@m.gmane.org; Mon, 12 May 2014 22:43:50 +0200 Original-Received: from localhost ([::1]:39764 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wjx4g-0006pm-6T for geh-help-gnu-emacs@m.gmane.org; Mon, 12 May 2014 16:43:50 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53487) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wjx4O-0006ne-7w for help-gnu-emacs@gnu.org; Mon, 12 May 2014 16:43:39 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wjx4G-00032R-Ml for help-gnu-emacs@gnu.org; Mon, 12 May 2014 16:43:32 -0400 Original-Received: from outbound-smtp04.blacknight.com ([81.17.249.35]:41559) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wjx4G-00031V-Ff for help-gnu-emacs@gnu.org; Mon, 12 May 2014 16:43:24 -0400 Original-Received: from mail.blacknight.com (pemlinmail03.blacknight.ie [81.17.254.16]) by outbound-smtp04.blacknight.com (Postfix) with ESMTP id A4DE4F409F for ; Mon, 12 May 2014 20:41:23 +0000 (UTC) Original-Received: (qmail 30464 invoked from network); 12 May 2014 20:43:18 -0000 Original-Received: from unknown (HELO RTLaptop) (rt@robertthorpeconsulting.com@[109.79.179.192]) by 81.17.254.9 with ESMTPSA (DHE-RSA-AES128-SHA encrypted, authenticated); 12 May 2014 20:43:18 -0000 In-Reply-To: (message from Frank Stutzman on Mon, 12 May 2014 19:22:22 +0000 (UTC)) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 81.17.249.35 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:97619 Archived-At: Frank Stutzman writes: > Nevermind.... > > It took quite a while to get my brain into elisp mode. Once that happened I > realized that my solution was write there on the help page for replace-string. > Right there where it says you probably don't want to use replace-string. > Pretty much the only real change I had to do was to use the COUNT option on > search-forward. You don't necessarily have to write any elisp at all for things like this. If you can use replace-string or search-forward then you can use a macro. Start recording with F3, do the search and replaces with something like M-% then finish with F4. Then do M-x insert-kbd-macro and it'll give you a bit of elisp code. You can turn that into a defun and put into your init file if you want to. BR, Robert Thorpe