From: Barry Margolin <barmar@alum.mit.edu>
To: help-gnu-emacs@gnu.org
Subject: Re: Function to replace spaces with underscores
Date: Tue, 17 Sep 2013 15:27:53 -0400 [thread overview]
Message-ID: <barmar-EEE17B.15275317092013@news.eternal-september.org> (raw)
In-Reply-To: 87ob7r729w.fsf@informatimago.com
In article <87ob7r729w.fsf@informatimago.com>,
"Pascal J. Bourguignon" <pjb@informatimago.com> wrote:
> pico77 <grammophonia@gmail.com> 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, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
next prev parent reply other threads:[~2013-09-17 19:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.2297.1379403955.10748.help-gnu-emacs@gnu.org>
2013-09-17 18:04 ` Function to replace spaces with underscores Pascal J. Bourguignon
2013-09-17 19:27 ` Barry Margolin [this message]
2013-09-17 7:39 pico77
2013-09-17 8:20 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=barmar-EEE17B.15275317092013@news.eternal-september.org \
--to=barmar@alum.mit.edu \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).