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

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

Re: Function to replace spaces with underscores


From: Eli Zaretskii
Subject: Re: Function to replace spaces with underscores
Date: Tue, 17 Sep 2013 11:20:50 +0300

> Date: Tue, 17 Sep 2013 00:39:35 -0700 (PDT)
> From: pico77 <address@hidden>
> 
> If I open emacs select a line ad do M-x s2u then it works fine, but if I do
> it further it requires to apply the function 3 times before to get it done.
> So the problem is really that probably the function is programmed in a way
> that after the first applucation of s2u there is something which has to be
> cleaned up before to re-apply the same function. 

As the doc string says, the function _cycles_ through a list of 3
characters, using a state variable.  It records the state variable and
applies it on the next invocation.  So it's a little wonder you need
to invoke the function several times, until it does what you want --
this is how this code was programmed to work.

(I don't really understand the need for such a function, given that
you have the 'replace-regexp' command, which works directly on a
region of the current buffer, instead of -- God forbid! -- extracting
a string from the buffer, changing it, then replacing buffer text with
the modified string.  This code is almost as un-Emacs-Lispy as it
gets.)



reply via email to

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