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 to automatically increment an index array Date: Fri, 27 Jun 2008 08:50:35 +0200 Organization: Organization?!? Message-ID: <858wwrfk1w.fsf@lola.goethe.zz> References: <9a68abc5-f2c8-4b83-a661-af134cf1519a@h1g2000prh.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1214552444 26652 80.91.229.12 (27 Jun 2008 07:40:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 27 Jun 2008 07:40:44 +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 Jun 27 09:41:30 2008 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.50) id 1KC8aG-0003wD-IL for geh-help-gnu-emacs@m.gmane.org; Fri, 27 Jun 2008 09:41:29 +0200 Original-Received: from localhost ([127.0.0.1]:46108 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KC8ZQ-00020E-1H for geh-help-gnu-emacs@m.gmane.org; Fri, 27 Jun 2008 03:40:36 -0400 Original-Path: news.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!newsfeed00.sul.t-online.de!t-online.de!news.buerger.net!uucp.gnuu.de!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/23.0.60 (gnu/linux) Cancel-Lock: sha1:299fJZA5zgTEd/XoywS/+z1jwg8= Original-Lines: 44 Original-NNTP-Posting-Date: 27 Jun 2008 08:50:36 CEST Original-NNTP-Posting-Host: 00bfec5a.newsspool2.arcor-online.net Original-X-Trace: DXC=VhVYMGYV93>U`5g[@c]@J1A9EHlD; 3Yc24Fo<]lROoR18kF5MOK`; S:bhJ<=00C; ab0]388; ; hGK0UoD< Original-X-Complaints-To: usenet-abuse@arcor.de Original-Xref: news.stanford.edu gnu.emacs.help:159752 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor 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:55107 Archived-At: Xah writes: > On Jun 26, 12:45 am, "Francis Moreau" wrote: >> Hello >> >> I have this problem: in a buffer, *scratch* for example I have: >> >> [8735b450] = xxx, >> [0x15] = xxx, >> [0x16] = xxx, >> [0x17] = xxx, >> [0x18] = xxx, >> [0x19] = xxx, >> [0x1a] = xxx, >> [0x1b] = xxx, >> >> After running a 'magic' command I'd like to calculate the new array indexes >> as follow: >> >> [8735b450] = xxx, >> [8735b454] = xxx, >> [8735b458] = xxx, >> [8735b45c] = xxx, >> [8735b460] = xxx, >> [8735b464] = xxx, >> [8735b468] = xxx, >> [8735b46c] = xxx, > > If i understand you correctly, you want to insert increment numbers > into a column. I needed this every few weeks. Not often, but when > needed is rather tedious to do manually, so i've written a elisp to do > it once for all. Well, one could write something like C-M-% \[0x\([0-9a-f]+\)\] RET \,(format "[%08x]" (+ (* 4 (string-to-number \1 16)) #X8745b400)) RET It is not all too pretty, but not all too bad either. If the pattern of the numbers is regular, you might use \# in the replacement rather than an explicit conversion. -- David Kastrup, Kriemhildstr. 15, 44793 Bochum