* remove extra whitespace on a line
@ 2006-12-02 6:27 Greg Bognar
2006-12-02 6:46 ` Chris Menzel
` (3 more replies)
0 siblings, 4 replies; 14+ messages in thread
From: Greg Bognar @ 2006-12-02 6:27 UTC (permalink / raw)
Suppose I have a line like this.
How can I remove the extra spaces from the line? So that I end up with
this:
Suppose I have a line like this.
Exactly like fill-paragraph, but I do not want to "fill" the paragraph,
only the current line. Is there an Emacs function to do this?
Thanks,
Greg
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: remove extra whitespace on a line
2006-12-02 6:27 remove extra whitespace on a line Greg Bognar
@ 2006-12-02 6:46 ` Chris Menzel
2006-12-02 7:01 ` Herbert Euler
` (2 subsequent siblings)
3 siblings, 0 replies; 14+ messages in thread
From: Chris Menzel @ 2006-12-02 6:46 UTC (permalink / raw)
On Sat, 02 Dec 2006 01:27:00 -0500, Greg Bognar <bognar@christal.elte.hu> said:
> Suppose I have a line like this.
>
> How can I remove the extra spaces from the line? So that I end up with
> this:
>
> Suppose I have a line like this.
>
> Exactly like fill-paragraph, but I do not want to "fill" the paragraph,
> only the current line. Is there an Emacs function to do this?
You can set the mark at the beginning of the line, Ctrl-E to the end and
use "fill-region".
^ permalink raw reply [flat|nested] 14+ messages in thread
* RE: remove extra whitespace on a line
2006-12-02 6:27 remove extra whitespace on a line Greg Bognar
2006-12-02 6:46 ` Chris Menzel
@ 2006-12-02 7:01 ` Herbert Euler
2006-12-02 7:02 ` Eric Hanchrow
2006-12-02 8:20 ` roodwriter
3 siblings, 0 replies; 14+ messages in thread
From: Herbert Euler @ 2006-12-02 7:01 UTC (permalink / raw)
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)))))
Regards,
Guanpeng Xu
>From: Greg Bognar <bognar@christal.elte.hu>
>To: help-gnu-emacs@gnu.org
>Subject: remove extra whitespace on a line
>Date: Sat, 02 Dec 2006 01:27:00 -0500
>
>Suppose I have a line like this.
>
>How can I remove the extra spaces from the line? So that I end up with
>this:
>
>Suppose I have a line like this.
>
>Exactly like fill-paragraph, but I do not want to "fill" the paragraph,
>only the current line. Is there an Emacs function to do this?
>
>Thanks,
>Greg
>_______________________________________________
>help-gnu-emacs mailing list
>help-gnu-emacs@gnu.org
>http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: remove extra whitespace on a line
2006-12-02 6:27 remove extra whitespace on a line Greg Bognar
2006-12-02 6:46 ` Chris Menzel
2006-12-02 7:01 ` Herbert Euler
@ 2006-12-02 7:02 ` Eric Hanchrow
2006-12-02 8:43 ` Dieter Wilhelm
` (2 more replies)
2006-12-02 8:20 ` roodwriter
3 siblings, 3 replies; 14+ messages in thread
From: Eric Hanchrow @ 2006-12-02 7:02 UTC (permalink / raw)
Suppose I have a line like this.
How can I remove the extra spaces from the line? So that I end up with
this:
Suppose I have a line like this.
Exactly like fill-paragraph, but I do not want to "fill" the paragraph,
only the current line. Is there an Emacs function to do this?
Not that I know of, but it'd be very easy to create one with a macro,
or Emacs Lisp.
Just narrow to the line, then fill paragraph.
--
I shrivel inside each time [Star Wars] is mentioned.
-- Sir Alec Guinness
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: remove extra whitespace on a line
2006-12-02 7:02 ` Eric Hanchrow
@ 2006-12-02 8:43 ` Dieter Wilhelm
2006-12-02 13:50 ` Perry Smith
[not found] ` <mailman.1429.1165067469.2155.help-gnu-emacs@gnu.org>
2 siblings, 0 replies; 14+ messages in thread
From: Dieter Wilhelm @ 2006-12-02 8:43 UTC (permalink / raw)
Cc: help-gnu-emacs
Eric Hanchrow <offby1@blarg.net> writes:
> Suppose I have a line like this.
> How can I remove the extra spaces from the line? So that I end up with
> this:
>
> Suppose I have a line like this.
>
> Exactly like fill-paragraph, but I do not want to "fill" the paragraph,
> only the current line. Is there an Emacs function to do this?
>
> Not that I know of, but it'd be very easy to create one with a macro,
> or Emacs Lisp.
>
> Just narrow to the line, then fill paragraph.
Good idea! Another idea is:
Mark line:
C-a C-SPC C-n
Then replace whitespace:
C-M-% " +" RET " " !
Your idea in comparison (after marking):
C-x n n M-q C-x n w
--
Best wishes
H. Dieter Wilhelm
Darmstadt, Germany
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: remove extra whitespace on a line
2006-12-02 7:02 ` Eric Hanchrow
2006-12-02 8:43 ` Dieter Wilhelm
@ 2006-12-02 13:50 ` Perry Smith
[not found] ` <mailman.1429.1165067469.2155.help-gnu-emacs@gnu.org>
2 siblings, 0 replies; 14+ messages in thread
From: Perry Smith @ 2006-12-02 13:50 UTC (permalink / raw)
Cc: help-gnu-emacs
[-- Attachment #1.1: Type: text/plain, Size: 977 bytes --]
On Dec 2, 2006, at 1:02 AM, Eric Hanchrow wrote:
>
> Suppose I have a line like this.
> How can I remove the extra spaces from the line? So that I end
> up with
> this:
>
> Suppose I have a line like this.
>
> Exactly like fill-paragraph, but I do not want to "fill" the
> paragraph,
> only the current line. Is there an Emacs function to do this?
>
> Not that I know of, but it'd be very easy to create one with a macro,
> or Emacs Lisp.
>
> Just narrow to the line, then fill paragraph.
There is a fill-region-as-paragraph command. check it out. The key
sequence
would be to go to the beginning of the line, mark, go to the end of
the line, then
fill-region-as-paragraph.
Also, its quicker for you to type ^h a fill (apropos fill) and scan
the results.
Perry Smith ( pedz@easesoftware.com )
Ease Software, Inc. ( http://www.easesoftware.com )
Low cost SATA Disk Systems for IBMs p5, pSeries, and RS/6000 AIX systems
[-- Attachment #1.2: Type: text/html, Size: 6822 bytes --]
[-- Attachment #2: Type: text/plain, Size: 152 bytes --]
_______________________________________________
help-gnu-emacs mailing list
help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
^ permalink raw reply [flat|nested] 14+ messages in thread
[parent not found: <mailman.1429.1165067469.2155.help-gnu-emacs@gnu.org>]
* Re: remove extra whitespace on a line
[not found] ` <mailman.1429.1165067469.2155.help-gnu-emacs@gnu.org>
@ 2006-12-02 15:26 ` B. T. Raven
0 siblings, 0 replies; 14+ messages in thread
From: B. T. Raven @ 2006-12-02 15:26 UTC (permalink / raw)
One method not mentioned:
Highlight line
Menu bar > Edit > Fill
"Perry Smith" <pedz@easesoftware.com> wrote in message
news:mailman.1429.1165067469.2155.help-gnu-emacs@gnu.org...
On Dec 2, 2006, at 1:02 AM, Eric Hanchrow wrote:
Suppose I have a line like this.
How can I remove the extra spaces from the line? So that I end up
with
this:
Suppose I have a line like this.
Exactly like fill-paragraph, but I do not want to "fill" the
paragraph,
only the current line. Is there an Emacs function to do this?
Not that I know of, but it'd be very easy to create one with a macro,
or Emacs Lisp.
Just narrow to the line, then fill paragraph.
There is a fill-region-as-paragraph command. check it out. The key
sequence
would be to go to the beginning of the line, mark, go to the end of the
line, then
fill-region-as-paragraph.
Also, its quicker for you to type ^h a fill (apropos fill) and scan the
results.
Perry Smith ( pedz@easesoftware.com )
Ease Software, Inc. ( http://www.easesoftware.com )
Low cost SATA Disk Systems for IBMs p5, pSeries, and RS/6000 AIX systems
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: remove extra whitespace on a line
2006-12-02 6:27 remove extra whitespace on a line Greg Bognar
` (2 preceding siblings ...)
2006-12-02 7:02 ` Eric Hanchrow
@ 2006-12-02 8:20 ` roodwriter
3 siblings, 0 replies; 14+ messages in thread
From: roodwriter @ 2006-12-02 8:20 UTC (permalink / raw)
Greg Bognar <bognar@christal.elte.hu> writes:
> Suppose I have a line like this.
>
> How can I remove the extra spaces from the line? So that I end up with
> this:
>
> Suppose I have a line like this.
>
> Exactly like fill-paragraph, but I do not want to "fill" the paragraph,
> only the current line. Is there an Emacs function to do this?
>
> Thanks,
> Greg
I'm not exactly clear on what you want done, but possibly
M-x canonically-space-region might work.
--Rod
______________________
Author of "Linux for Non-Geeks--Clear-eyed Answers for Practical
Consumers" and "Boring Stories from Uncle Rod." To reply by e-mail
take the second "o" out of the e-mail address.
^ permalink raw reply [flat|nested] 14+ messages in thread
[parent not found: <mailman.1421.1165042886.2155.help-gnu-emacs@gnu.org>]
* Re: remove extra whitespace on a line
[not found] <mailman.1421.1165042886.2155.help-gnu-emacs@gnu.org>
@ 2006-12-02 12:15 ` Markus Triska
2006-12-02 12:55 ` David Hansen
[not found] ` <mailman.1428.1165064915.2155.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 14+ messages in thread
From: Markus Triska @ 2006-12-02 12:15 UTC (permalink / raw)
"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))))
All the best,
Markus Triska
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: remove extra whitespace on a line
2006-12-02 12:15 ` Markus Triska
@ 2006-12-02 12:55 ` David Hansen
[not found] ` <mailman.1428.1165064915.2155.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 14+ messages in thread
From: David Hansen @ 2006-12-02 12:55 UTC (permalink / raw)
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
^ permalink raw reply [flat|nested] 14+ messages in thread
[parent not found: <mailman.1428.1165064915.2155.help-gnu-emacs@gnu.org>]
* Re: remove extra whitespace on a line
[not found] ` <mailman.1428.1165064915.2155.help-gnu-emacs@gnu.org>
@ 2006-12-02 17:40 ` Greg Bognar
2006-12-02 17:58 ` Markus Triska
2006-12-02 19:49 ` David Hansen
0 siblings, 2 replies; 14+ messages in thread
From: Greg Bognar @ 2006-12-02 17:40 UTC (permalink / raw)
On Sat, 02 Dec 2006 13:55:42 +0100, David Hansen wrote:
> 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
So this is what I want, isn't it?
(defun just-one-space-in-current-line ()
(interactive)
(save-excursion
(save-restriction
(narrow-to-region (line-beginning-position)
(line-end-position))
(goto-char (point-min))
(canonically-space-region
(line-beginning-position) (line-end-position)))))
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: remove extra whitespace on a line
2006-12-02 17:40 ` Greg Bognar
@ 2006-12-02 17:58 ` Markus Triska
2006-12-02 19:49 ` David Hansen
1 sibling, 0 replies; 14+ messages in thread
From: Markus Triska @ 2006-12-02 17:58 UTC (permalink / raw)
Greg Bognar <greg.bognar@gmail.com> writes:
>
> So this is what I want, isn't it?
>
> (defun just-one-space-in-current-line ()
> (interactive)
> (save-excursion
> (save-restriction
> (narrow-to-region (line-beginning-position)
> (line-end-position))
> (goto-char (point-min))
> (canonically-space-region
> (line-beginning-position) (line-end-position)))))
I recommend:
(defun just-one-space-in-current-line ()
(interactive)
(save-excursion
(fill-region (line-beginning-position) (line-end-position))))
All the best,
Markus Triska
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: remove extra whitespace on a line
2006-12-02 17:40 ` Greg Bognar
2006-12-02 17:58 ` Markus Triska
@ 2006-12-02 19:49 ` David Hansen
2006-12-02 20:52 ` Dieter Wilhelm
1 sibling, 1 reply; 14+ messages in thread
From: David Hansen @ 2006-12-02 19:49 UTC (permalink / raw)
On Sat, 02 Dec 2006 12:40:43 -0500 Greg Bognar wrote:
> So this is what I want, isn't it?
>
> (defun just-one-space-in-current-line ()
> (interactive)
> (save-excursion
> (save-restriction
> (narrow-to-region (line-beginning-position)
> (line-end-position))
> (goto-char (point-min))
> (canonically-space-region
He, nice to see that there is always something one didn't know
about Emacs.
With this command you can forget about the narrowing. It's
doing all you want (well nearly, you still have to mark the
line):
C-a C-SPC C-e M-x canonically-space-region
> (line-beginning-position) (line-end-position)))))
Or your code a bit compressed:
(defun just-one-space-in-current-line ()
(interactive)
(canonically-space-region (point-at-bol) (point-at-eol)))
David
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: remove extra whitespace on a line
2006-12-02 19:49 ` David Hansen
@ 2006-12-02 20:52 ` Dieter Wilhelm
0 siblings, 0 replies; 14+ messages in thread
From: Dieter Wilhelm @ 2006-12-02 20:52 UTC (permalink / raw)
David Hansen <david.hansen@gmx.net> writes:
> On Sat, 02 Dec 2006 12:40:43 -0500 Greg Bognar wrote:
>
>> So this is what I want, isn't it?
>>
>> (defun just-one-space-in-current-line ()
>> (interactive)
>> (save-excursion
>> (save-restriction
...
>
> C-a C-SPC C-e M-x canonically-space-region
>
>> (line-beginning-position) (line-end-position)))))
>
>
> Or your code a bit compressed:
>
> (defun just-one-space-in-current-line ()
> (interactive)
> (canonically-space-region (point-at-bol) (point-at-eol)))
Thanks for the aliases!
(= (point-at-bol) (line-beginning-position))
--
Best wishes
H. Dieter Wilhelm
Darmstadt, Germany
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2006-12-02 20:52 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-02 6:27 remove extra whitespace on a line Greg Bognar
2006-12-02 6:46 ` Chris Menzel
2006-12-02 7:01 ` Herbert Euler
2006-12-02 7:02 ` Eric Hanchrow
2006-12-02 8:43 ` Dieter Wilhelm
2006-12-02 13:50 ` Perry Smith
[not found] ` <mailman.1429.1165067469.2155.help-gnu-emacs@gnu.org>
2006-12-02 15:26 ` B. T. Raven
2006-12-02 8:20 ` roodwriter
[not found] <mailman.1421.1165042886.2155.help-gnu-emacs@gnu.org>
2006-12-02 12:15 ` Markus Triska
2006-12-02 12:55 ` David Hansen
[not found] ` <mailman.1428.1165064915.2155.help-gnu-emacs@gnu.org>
2006-12-02 17:40 ` Greg Bognar
2006-12-02 17:58 ` Markus Triska
2006-12-02 19:49 ` David Hansen
2006-12-02 20:52 ` Dieter Wilhelm
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.