[Top][All Lists]

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

Re: Function to replace spaces with underscores

From: Barry Margolin
Subject: Re: Function to replace spaces with underscores
Date: Tue, 17 Sep 2013 15:27:53 -0400
User-agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X)

In article <address@hidden>,
 "Pascal J. Bourguignon" <address@hidden> wrote:

> pico77 <address@hidden> writes:
> > Dear all, 
> >
> >
> > at the end of this post there is a function that I load in my .emacs file.
> > The main goal is to take a selected line and remove all spaces with
> > underscore. This is very useful to produce file-names from copy/past
> > consistently without spaces. But there is a problem with that. 
> >
> >
> > 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. 
> >
> > I am not a lisp/emacs expert and the function was passed by a friend who is
> > now not able to solve the problem. I hope somebody out there can help to
> > find the bug!
> Indeed, as Eli said, the specifications of this command are strange, and
> rather impractical.  What if you make a different selection? You won't
> be able to easily replace spaces to underscore on two different regions.

Usually commands that operate like this also check whether the last 
command was this one, or if the region is the same as it was the last 
time. If not, they reset themselves to the initial behavior.

Although since this command just rotates among 3 different behaviors, 
none of them can really be considered "initial". It seems like you're 
just supposed to repeat the command until it does the substitution you 
want this time. You should bind it to a key, so repeating it is easy.

Barry Margolin, address@hidden
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***

reply via email to

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