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

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

Re: problem with elisp


From: Seweryn Kokot
Subject: Re: problem with elisp
Date: Wed, 08 Oct 2008 22:04:33 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux)

Nikolaj Schumacher <me@nschum.de> writes:

> Seweryn Kokot <sewkokot@gmail.com> wrote:
>
>> Could you explain to me why the following function doesn't work in the first
>> version and when swapping line
>>      (let ((string-temp (make-temp-name "")))
>> with
>>     (let ((string-temp "@temp@"))
>> it works correctly?
>
> Could you specify what's not working?  It seems to work for me.
>
> `make-temp-name' is not a good idea for what you're doing, though.
> While the same string will never be returned twice, there is no
> guarantee that the string doesn't exist in your buffer.  So make sure
> you use a very unique prefix.  On the other hand, there's no added
> benefit from using `make-temp-name' instead of just the prefix.

I see the problem in this function.

First I tested it with for example a buffer containing
--- start of buffer
1
2
--- end of buffer

so swapping 1 with 2 gives

--- start of buffer
5816MHs
1
--- end of buffer

string-temp was 5826MHs and with these 3 lines 

          (goto-char (point-min))
          (while (search-forward string-b nil t) ; string-b=2
                (replace-match string-a))            ; string-a=1

string-temp is changed to 5816MHs and in the end, the last 3 lines do
nothing. 

Any idea how to solve the problem?

-- 
regards,
Seweryn





reply via email to

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