From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Harry Putnam Newsgroups: gmane.emacs.help Subject: Re: function to increase numbers in a buffer Date: Wed, 23 Apr 2003 06:04:01 GMT Organization: Still searching... Sender: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1051078256 27396 80.91.224.249 (23 Apr 2003 06:10:56 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 23 Apr 2003 06:10:56 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Wed Apr 23 08:10:55 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 198DT4-00077k-00 for ; Wed, 23 Apr 2003 08:10:55 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 198DTN-0001SS-05 for gnu-help-gnu-emacs@m.gmane.org; Wed, 23 Apr 2003 02:11:13 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!cyclone.bc.net!sjc70.webusenet.com!news.webusenet.com!pd2nf1so.cg.shawcable.net!residential.shaw.ca!prodigy.com!newsmst01.news.prodigy.com!prodigy.com!postmaster.news.prodigy.com!newssvr21.news.prodigy.com.POSTED!cbca52ab!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.090008 (Oort Gnus v0.08) Emacs/21.3.50 (i686-pc-linux-gnu) Cancel-Lock: sha1:p5aOZle/WyroaQ+hdDDC6KDjrmM= Original-Lines: 44 Original-NNTP-Posting-Host: 63.202.234.251 Original-X-Complaints-To: abuse@prodigy.net Original-X-Trace: newssvr21.news.prodigy.com 1051077841 ST000 63.202.234.251 (Wed, 23 Apr 2003 02:04:01 EDT) Original-NNTP-Posting-Date: Wed, 23 Apr 2003 02:04:01 EDT X-UserInfo1: SCSGGZ[EEB^UCWDYIBHZOWP@YZOZ@GXOXB]T]_MIJQR@EPIB_VUKAH_[MTX\IS[K[NGYJJFNOFZR_G[BUNTAOQLFE^TEHRPI]PZZRP_BMDSFQFL_]CBHXRWCMDCUZAZN@D_AKMNLEI]MWHCSXL^]NNC__CZFGSGHYYXWPFG@SCAVA]\FT\@B\RDGENSUQS^M Original-Xref: shelby.stanford.edu gnu.emacs.help:112197 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:8696 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:8696 Jordi Burguet Castell writes: > Or, easier, I have a file that looks like this: > > 20 1 23523 > 20 2 23874 > 20 3 23898 > ... > > and I want to increase all the numbers in the third column by a certain > amount, say 3, from (point) to (point-max). A Perl script would not help, > because I need to do it several times and from different points. Not a very satisfying answer I'm afraid but shell tools or perl can handle this thru an emacs command `shell-command-on-region' (`M-S-|'), by selecting the region needed and then use the `C-u' preface to make the action change the current buffer. For example, taking this buffer 22 1 2233 22 2 2244 22 3 3355 22 4 4455 Select a region of lines 2 thru 3 in the usual way by pressing C-spc at the beginning of line 2 then moving cursor just below line 3. Then C-u M-S-| awk '{printf "%-4d %-2d %d\n", $1, $2, ($3 + 3)}' Will give you 22 1 2233 22 2 2247 22 3 3358 22 4 4455 Emacs allows one to work on a region employing shell or other tools to do the work. There are probably better ways, but this one is fairly quick if you know basic shell/awk/perl stuff and are on a platform where those tools can be found.