From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Barry Margolin Newsgroups: gmane.emacs.help Subject: Re: Function to replace spaces with underscores Date: Tue, 17 Sep 2013 15:27:53 -0400 Organization: A noiseless patient Spider Message-ID: References: <87ob7r729w.fsf@informatimago.com> NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1379446213 13161 80.91.229.3 (17 Sep 2013 19:30:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 17 Sep 2013 19:30:13 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Sep 17 21:30:17 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VM0yX-0007PP-6A for geh-help-gnu-emacs@m.gmane.org; Tue, 17 Sep 2013 21:30:17 +0200 Original-Received: from localhost ([::1]:43149 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VM0yW-0002Ew-OQ for geh-help-gnu-emacs@m.gmane.org; Tue, 17 Sep 2013 15:30:16 -0400 Original-Path: usenet.stanford.edu!news.kjsl.com!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!barmar.motzarella.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 41 Injection-Info: barmar.motzarella.org; posting-host="2be9e9f5dd9af768b8861af71b85fc28"; logging-data="18259"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX185m95dQ91iWFDyEAsZbBxS" User-Agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) Cancel-Lock: sha1:V7ACLYHxkncciwmQibeyDvFftWk= Original-Xref: usenet.stanford.edu gnu.emacs.help:201155 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:93424 Archived-At: In article <87ob7r729w.fsf@informatimago.com>, "Pascal J. Bourguignon" wrote: > pico77 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 ***