From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Markus Triska Newsgroups: gmane.emacs.help Subject: Re: remove extra whitespace on a line Date: Sat, 02 Dec 2006 13:15:33 +0100 Message-ID: <87irgu8pei.fsf@gmx.at> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1165063236 1854 80.91.229.2 (2 Dec 2006 12:40:36 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 2 Dec 2006 12:40:36 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Dec 02 13:40:34 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 1GqUAS-0001xE-MS for geh-help-gnu-emacs@m.gmane.org; Sat, 02 Dec 2006 13:40:32 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GqUAS-00014L-CB for geh-help-gnu-emacs@m.gmane.org; Sat, 02 Dec 2006 07:40:32 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!news-fra1.dfn.de!newscore.univie.ac.at!aconews-feed.univie.ac.at!aconews.univie.ac.at!not-for-mail Original-Newsgroups: gnu.emacs.help Cancel-Lock: sha1:xGOZcUgIEO0Ut2O/xgc5sbRtDsg= Original-Lines: 27 Original-NNTP-Posting-Host: news-access-from.tuwien.ac.at Original-X-Trace: 1165061658 tunews.univie.ac.at 10578 192.35.241.118 Original-X-Complaints-To: abuse@tuwien.ac.at Original-Xref: shelby.stanford.edu gnu.emacs.help:143597 Original-To: help-gnu-emacs@gnu.org 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:39199 Archived-At: "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)))) All the best, Markus Triska