help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: remove extra whitespace on a line


From: David Hansen
Subject: Re: remove extra whitespace on a line
Date: Sat, 02 Dec 2006 13:55:42 +0100
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.91 (gnu/linux)

On Sat, 02 Dec 2006 13:15:33 +0100 Markus Triska wrote:

> "Herbert Euler" <herberteuler@hotmail.com> 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





reply via email to

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