From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.emacs.help Subject: Re: How modify numbers in a region by a multiplier? Date: Thu, 01 Jul 2010 22:42:57 +0200 Organization: Organization?!? Message-ID: <878w5vylv1.fsf@lola.goethe.zz> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1291842080 32251 80.91.229.12 (8 Dec 2010 21:01:20 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 8 Dec 2010 21:01:20 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Dec 08 22:01:14 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PQR6X-00028m-6H for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Dec 2010 22:01:13 +0100 Original-Received: from localhost ([127.0.0.1]:36133 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PQR5v-0002Ah-FN for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Dec 2010 15:58:35 -0500 Original-Path: usenet.stanford.edu!newsserver.news.garr.it!kanaga.switch.ch!switch.ch!feeder.news-service.com!eweka.nl!lightspeed.eweka.nl!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help X-Face: 2FEFf>]>q>2iw=B6, xrUubRI>pR&Ml9=ao@P@i)L:\urd*t9M~y1^:+Y]'C0~{mAl`oQuAl \!3KEIp?*w`|bL5qr,H)LFO6Q=qx~iH4DN; i"; /yuIsqbLLCh/!U#X[S~(5eZ41to5f%E@'ELIi$t^ Vc\LWP@J5p^rst0+('>Er0=^1{]M9!p?&:\z]|;&=NP3AhB!B_bi^]Pfkw User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) Cancel-Lock: sha1:2YAgakLG5gzGjR2ugG4ocxfRlUQ= Original-Lines: 22 Original-NNTP-Posting-Date: 01 Jul 2010 22:42:58 CEST Original-NNTP-Posting-Host: 6d8fc53f.newsspool4.arcor-online.net Original-X-Trace: DXC=Oc8iHkK]4X_aoembcbF; DQ4IUK5MOK`al0oRZ`b List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:75997 Archived-At: Seweryn Kokot writes: > Juanma Barranquero gmail.com> writes: > >> Qiang Guo is right, though, in pointing that you're using a fixed >> `end' but the buffer or region length is potentially changing with >> every replace. > > Is there a canonical solution to this problem, since it seems that it should > happen frequently when using the following structure: > (while (re-search-forward "\\([0-9.]+\\)" end t) > (replace-match (format "%.2f" (* (string-to-number (match-string 1)) > multiplier)))) Probably easiest to do (save-restriction (narrow-to-region start end ... -- David Kastrup