help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to automatically increment an index array


From: David Kastrup
Subject: Re: How to automatically increment an index array
Date: Fri, 27 Jun 2008 08:50:35 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

Xah <address@hidden> writes:

> On Jun 26, 12:45 am, "Francis Moreau" <address@hidden> 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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]