From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Hansen Newsgroups: gmane.emacs.help Subject: Re: remove extra whitespace on a line Date: Sat, 02 Dec 2006 13:55:42 +0100 Organization: disorganized Message-ID: <87wt5asbht.fsf@localhorst.mine.nu> References: <87irgu8pei.fsf@gmx.at> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1165065068 8122 80.91.229.2 (2 Dec 2006 13:11:08 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 2 Dec 2006 13:11:08 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Dec 02 14:11:06 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GqUe1-00081n-KT for geh-help-gnu-emacs@m.gmane.org; Sat, 02 Dec 2006 14:11:05 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GqUe1-0006Dt-1k for geh-help-gnu-emacs@m.gmane.org; Sat, 02 Dec 2006 08:11:05 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GqUbY-0002Aj-IT for help-gnu-emacs@gnu.org; Sat, 02 Dec 2006 08:08:32 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GqUbV-00025j-DY for help-gnu-emacs@gnu.org; Sat, 02 Dec 2006 08:08:30 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GqUbU-00024m-Mc for help-gnu-emacs@gnu.org; Sat, 02 Dec 2006 08:08:29 -0500 Original-Received: from [80.91.229.2] (helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1GqUbU-0007pu-9w for help-gnu-emacs@gnu.org; Sat, 02 Dec 2006 08:08:28 -0500 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1GqUbL-0007Ol-JT for help-gnu-emacs@gnu.org; Sat, 02 Dec 2006 14:08:20 +0100 Original-Received: from e178048182.adsl.alicedsl.de ([85.178.48.182]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 02 Dec 2006 14:08:19 +0100 Original-Received: from david.hansen by e178048182.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 02 Dec 2006 14:08:19 +0100 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: help-gnu-emacs@gnu.org Original-To: help-gnu-emacs@gnu.org Original-Lines: 30 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: e178048182.adsl.alicedsl.de Mail-Copies-To: nobody User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.91 (gnu/linux) Cancel-Lock: sha1:YdMqFmbPuUXEaOSW/fY3JydjQGQ= X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:39200 Archived-At: On Sat, 02 Dec 2006 13:15:33 +0100 Markus Triska wrote: > "Herbert Euler" writes: > >> How about this? >> >> (defun just-one-space-in-current-line (&optional n) >> (interactive "*p") >> (save-excursion >> (save-restriction >> (narrow-to-region (line-beginning-position) >> (line-end-position)) >> (goto-char (point-min)) >> (while (re-search-forward "[ \t]" nil t) >> (just-one-space n))))) > > Or this: > > (defun just-one-space-in-current-line (&optional n) > (interactive "*p") > (save-excursion > (beginning-of-line) > (while (re-search-forward "[ \t]" (line-end-position) t) > (just-one-space n)))) Both will convert two (or more) spaces after the end of a sentence into one space. Narrowing and filling seems to be the right way to me. David