* Deleting chunks of whitespace
@ 2002-11-15 15:32 Moore, Mathew L
0 siblings, 0 replies; 13+ messages in thread
From: Moore, Mathew L @ 2002-11-15 15:32 UTC (permalink / raw)
Hello,
Is there a quick command sequence that allows me to delete all of the
whitespace between the point and the next non-whitespace character---sort of
like the way M-d deletes from the point to the end of a word?
Thanks for your help.
--Matt
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Deleting chunks of whitespace
[not found] <mailman.1037375498.29003.help-gnu-emacs@gnu.org>
@ 2002-11-15 17:24 ` Richard V. Molen
2002-11-15 17:42 ` Benjamin Rutt
` (2 subsequent siblings)
3 siblings, 0 replies; 13+ messages in thread
From: Richard V. Molen @ 2002-11-15 17:24 UTC (permalink / raw)
"Moore, Mathew L" <MooreML@BATTELLE.ORG> writes:
> Hello,
>
> Is there a quick command sequence that allows me to delete all of the
> whitespace between the point and the next non-whitespace character---sort of
> like the way M-d deletes from the point to the end of a word?
How about fixup-whitespace?
;;suck up excess whitespace
(global-set-key [f12] 'fixup-whitespace)
--
Richard V. Molen
Warning!!
Signature under construction, safety glasses required.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Deleting chunks of whitespace
[not found] <mailman.1037375498.29003.help-gnu-emacs@gnu.org>
2002-11-15 17:24 ` Deleting chunks of whitespace Richard V. Molen
@ 2002-11-15 17:42 ` Benjamin Rutt
2002-11-15 18:22 ` Benjamin Lewis
2002-11-16 18:54 ` Kai Großjohann
3 siblings, 0 replies; 13+ messages in thread
From: Benjamin Rutt @ 2002-11-15 17:42 UTC (permalink / raw)
"Moore, Mathew L" <MooreML@BATTELLE.ORG> writes:
> Is there a quick command sequence that allows me to delete all of the
> whitespace between the point and the next non-whitespace character---sort of
> like the way M-d deletes from the point to the end of a word?
I think 'M-SPC' is what you want.
--
Benjamin
^ permalink raw reply [flat|nested] 13+ messages in thread
* RE: Deleting chunks of whitespace
@ 2002-11-15 17:42 Moore, Mathew L
0 siblings, 0 replies; 13+ messages in thread
From: Moore, Mathew L @ 2002-11-15 17:42 UTC (permalink / raw)
>
> > Is there a quick command sequence that allows me to delete
> all of the
> > whitespace between the point and the next non-whitespace
> character---sort of
> > like the way M-d deletes from the point to the end of a word?
>
> How about fixup-whitespace?
>
> ;;suck up excess whitespace
> (global-set-key [f12] 'fixup-whitespace)
>
Perfect. Thanks for everyone's assistance!
--Matt
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Deleting chunks of whitespace
[not found] <mailman.1037375498.29003.help-gnu-emacs@gnu.org>
2002-11-15 17:24 ` Deleting chunks of whitespace Richard V. Molen
2002-11-15 17:42 ` Benjamin Rutt
@ 2002-11-15 18:22 ` Benjamin Lewis
2002-11-15 19:42 ` Richard V. Molen
2002-11-16 18:54 ` Kai Großjohann
3 siblings, 1 reply; 13+ messages in thread
From: Benjamin Lewis @ 2002-11-15 18:22 UTC (permalink / raw)
On Fri, 15 Nov 2002, Mathew L. Moore wrote:
> Hello,
>
> Is there a quick command sequence that allows me to delete all of the
> whitespace between the point and the next non-whitespace character---sort
> of like the way M-d deletes from the point to the end of a word?
>
> Thanks for your help.
Not quite what you want, but you could check out `delete-horizontal-space'
and 'just-one-space', bound by default to `M-\' and 'M-<SPC>' respectively.
If you can't find what you want, you could possibly grab the code for one
of these from simple.el and modify it...
--
Benjamin Lewis
Although the moon is smaller than the earth, it is farther away.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Deleting chunks of whitespace
2002-11-15 18:22 ` Benjamin Lewis
@ 2002-11-15 19:42 ` Richard V. Molen
2002-11-15 20:02 ` Benjamin Lewis
0 siblings, 1 reply; 13+ messages in thread
From: Richard V. Molen @ 2002-11-15 19:42 UTC (permalink / raw)
Benjamin Lewis <bclewis@cs.sfu.ca> writes:
> Not quite what you want, but you could check out `delete-horizontal-space'
> and 'just-one-space', bound by default to `M-\' and 'M-<SPC>' respectively.
These key bindings are nice since they mesh well with M-d.
On another editor there was a function like that I miss...
if the cursor is at the end of line, pull up the next line (like C-k)
else
if the cursor is on non-whitespace, delete all characters to end of line
that are non-whitespace.
else
if the cursor is on whitespace, delete all characters to the end of line
that are whitespace.
Does anyone have such a function?
--
Richard V. Molen
Warning!!
Signature under construction, safety glasses required.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Deleting chunks of whitespace
2002-11-15 19:42 ` Richard V. Molen
@ 2002-11-15 20:02 ` Benjamin Lewis
2002-11-15 21:08 ` Richard V. Molen
0 siblings, 1 reply; 13+ messages in thread
From: Benjamin Lewis @ 2002-11-15 20:02 UTC (permalink / raw)
On 15 Nov 2002, Richard V. Molen wrote:
> Benjamin Lewis <bclewis@cs.sfu.ca> writes:
>
>> Not quite what you want, but you could check out
>> `delete-horizontal-space' and 'just-one-space', bound by default to
>> `M-\' and 'M-<SPC>' respectively.
>
> These key bindings are nice since they mesh well with M-d.
>
> On another editor there was a function like that I miss...
>
> if the cursor is at the end of line, pull up the next line (like C-k)
> else
> if the cursor is on non-whitespace, delete all characters to end of line
> that are non-whitespace.
> else
> if the cursor is on whitespace, delete all characters to the end of line
> that are whitespace.
>
> Does anyone have such a function?
Not sure I understand. Where would you use this that C-k doesn't do what
you want?
Is the function `delete-trailing-whitespace' helpful?
--
Benjamin Lewis
F u cn rd ths u cnt spl wrth a dm!
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Deleting chunks of whitespace
2002-11-15 20:02 ` Benjamin Lewis
@ 2002-11-15 21:08 ` Richard V. Molen
2002-11-16 15:58 ` Ehud Karni
[not found] ` <mailman.1037463184.24264.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 13+ messages in thread
From: Richard V. Molen @ 2002-11-15 21:08 UTC (permalink / raw)
Benjamin Lewis <bclewis@cs.sfu.ca> writes:
> On 15 Nov 2002, Richard V. Molen wrote:
>
> > Benjamin Lewis <bclewis@cs.sfu.ca> writes:
> >
> >> Not quite what you want, but you could check out
> >> `delete-horizontal-space' and 'just-one-space', bound by default to
> >> `M-\' and 'M-<SPC>' respectively.
> >
> > These key bindings are nice since they mesh well with M-d.
> >
> > On another editor there was a function like that I miss...
> >
> > if the cursor is at the end of line, pull up the next line (like C-k)
> > else
> > if the cursor is on non-whitespace, delete all characters to end of line
> > that are non-whitespace.
> > else
> > if the cursor is on whitespace, delete all characters to the end of line
> > that are whitespace.
> >
> > Does anyone have such a function?
>
> Not sure I understand. Where would you use this that C-k doesn't do what
> you want?
Though I tried, in review, what I said wasn't quite accurate.
Here's an example of what I'm looking for. Given this text and
calling this function repeatedly...
... cursor ...
... v ...
This is some-text on_the_first/line
Second line
... cursor ...
... v ...
This is some-text on_the_first/line
Second line
... cursor ...
... v ...
This is on_the_first/line
Second line
... cursor ...
... v ...
This is
Second line
... cursor ...
... v ...
This is Second line
>
> Is the function `delete-trailing-whitespace' helpful?
assuming the Second line had whitespace (shown as '@')
... cursor ...
... v ...
This is Second line@@@@@@@@
... cursor ...
... v ...
This is
This is behavior is similar to alternating between M-SPC & M-d
and then doing a C-k if at there's no more on the current line.
Two exceptions being the: 1. the cursor doesn't move (not a big
deal) 2. M-d would not cut all non-whitespace characters, but
only alphanumeric strings.
--
Richard V. Molen
Warning!!
Signature under construction, safety glasses required.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Deleting chunks of whitespace
2002-11-15 21:08 ` Richard V. Molen
@ 2002-11-16 15:58 ` Ehud Karni
[not found] ` <mailman.1037463184.24264.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 13+ messages in thread
From: Ehud Karni @ 2002-11-16 15:58 UTC (permalink / raw)
Cc: help-gnu-emacs
On 15 Nov 2002 13:08:48 -0800, rvmolen@bambecksystems.com (Richard V. Molen) wrote:
>
> This is behavior is similar to alternating between M-SPC & M-d
> and then doing a C-k if at there's no more on the current line.
> Two exceptions being the: 1. the cursor doesn't move (not a big
> deal) 2. M-d would not cut all non-whitespace characters, but
> only alphanumeric strings.
I think this command will do what you want:
(defun kill-to-non-blank ()
"kill to 1st non blank (after blank) to right"
(interactive "*")
(kill-region (point) (progn (forward-to-non-blank) (point))))
(defun forward-to-non-blank ()
"go to 1st non blank (after blank) to right"
(interactive)
(if (re-search-forward "[ \t\n][^ \t\n]" (point-max) t)
(backward-char 1)))
I assign it to [C-delete] i.e.
(define-key global-map '[C-delete] 'kill-to-non-blank)
One hint: on some X-terminals the keypad delete is [C-kp-decimal].
Ehud.
--
Ehud Karni Tel: +972-3-7966-561 /"\
Mivtach - Simon Fax: +972-3-7966-667 \ / ASCII Ribbon Campaign
Insurance agencies (USA) voice mail and X Against HTML Mail
http://www.mvs.co.il FAX: 1-815-5509341 / \
mailto:ehud@unix.mvs.co.il Better Safe Than Sorry
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Deleting chunks of whitespace
[not found] <mailman.1037375498.29003.help-gnu-emacs@gnu.org>
` (2 preceding siblings ...)
2002-11-15 18:22 ` Benjamin Lewis
@ 2002-11-16 18:54 ` Kai Großjohann
3 siblings, 0 replies; 13+ messages in thread
From: Kai Großjohann @ 2002-11-16 18:54 UTC (permalink / raw)
"Moore, Mathew L" <MooreML@BATTELLE.ORG> writes:
> Is there a quick command sequence that allows me to delete all of
> the whitespace between the point and the next non-whitespace
> character---sort of like the way M-d deletes from the point to the
> end of a word?
C-o C-f M-\ DEL
DEL means <backspace>.
Maybe RET M-\ DEL will also do the trick, but it sometimes might not
if RET does syntax-driven indentation.
kai
--
~/.signature is: umop ap!sdn (Frank Nobis)
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Deleting chunks of whitespace
[not found] ` <mailman.1037463184.24264.help-gnu-emacs@gnu.org>
@ 2002-11-18 16:26 ` Richard V. Molen
2002-11-18 18:07 ` Ehud Karni
[not found] ` <mailman.1037643734.10691.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 13+ messages in thread
From: Richard V. Molen @ 2002-11-18 16:26 UTC (permalink / raw)
"Ehud Karni" <ehud@unix.mvs.co.il> writes:
> On 15 Nov 2002 13:08:48 -0800, rvmolen@bambecksystems.com (Richard V. Molen) wrote:
> >
> > This is behavior is similar to alternating between M-SPC & M-d
> > and then doing a C-k if at there's no more on the current line.
> > Two exceptions being the: 1. the cursor doesn't move (not a big
> > deal) 2. M-d would not cut all non-whitespace characters, but
> > only alphanumeric strings.
>
> I think this command will do what you want:
>
> (defun kill-to-non-blank ()
> "kill to 1st non blank (after blank) to right"
> (interactive "*")
> (kill-region (point) (progn (forward-to-non-blank) (point))))
>
> (defun forward-to-non-blank ()
> "go to 1st non blank (after blank) to right"
> (interactive)
> (if (re-search-forward "[ \t\n][^ \t\n]" (point-max) t)
> (backward-char 1)))
>
> I assign it to [C-delete] i.e.
> (define-key global-map '[C-delete] 'kill-to-non-blank)
> One hint: on some X-terminals the keypad delete is [C-kp-decimal].
Thank you Ehud, this works nicely and does 95% of what I want. And
it's done with simple, resuable functions.
The remaining 5% occurs at the end of the buffer when there is still a
word and maybe some extra newlines remaining. Of course, this doesn't
occur often and a couple of C-k's would clean it right up.
--
Richard V. Molen
Warning!!
Signature under construction, safety glasses required.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Deleting chunks of whitespace
2002-11-18 16:26 ` Richard V. Molen
@ 2002-11-18 18:07 ` Ehud Karni
[not found] ` <mailman.1037643734.10691.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 13+ messages in thread
From: Ehud Karni @ 2002-11-18 18:07 UTC (permalink / raw)
Cc: help-gnu-emacs
On 18 Nov 2002 08:26:55 -0800, rvmolen@bambecksystems.com (Richard V. Molen) wrote:
>
> Thank you Ehud, this works nicely and does 95% of what I want. And
> it's done with simple, resuable functions.
>
> The remaining 5% occurs at the end of the buffer when there is still a
> word and maybe some extra newlines remaining. Of course, this doesn't
> occur often and a couple of C-k's would clean it right up.
This is very easy to fix (change the `t' to `1' in the 3rd arg to
`re-search-forward', see its help) like this:
(defun forward-to-non-blank ()
"go to 1st non blank (after blank) to right,
if there is none go to end of buffer"
(interactive)
(if (re-search-forward "[ \t\n][^ \t\n]" (point-max) 1)
(backward-char 1)))
Ehud.
--
Ehud Karni Tel: +972-3-7966-561 /"\
Mivtach - Simon Fax: +972-3-7966-667 \ / ASCII Ribbon Campaign
Insurance agencies (USA) voice mail and X Against HTML Mail
http://www.mvs.co.il FAX: 1-815-5509341 / \
mailto:ehud@unix.mvs.co.il Better Safe Than Sorry
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Deleting chunks of whitespace
[not found] ` <mailman.1037643734.10691.help-gnu-emacs@gnu.org>
@ 2002-11-18 18:55 ` Richard V. Molen
0 siblings, 0 replies; 13+ messages in thread
From: Richard V. Molen @ 2002-11-18 18:55 UTC (permalink / raw)
"Ehud Karni" <ehud@unix.mvs.co.il> writes:
> This is very easy to fix (change the `t' to `1' in the 3rd arg to
> `re-search-forward', see its help) like this:
>
> (defun forward-to-non-blank ()
> "go to 1st non blank (after blank) to right,
> if there is none go to end of buffer"
> (interactive)
> (if (re-search-forward "[ \t\n][^ \t\n]" (point-max) 1)
> (backward-char 1)))
Thanks again Ehud, it works great now. :-)
--
Richard V. Molen
Warning!!
Signature under construction, safety glasses required.
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2002-11-18 18:55 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.1037375498.29003.help-gnu-emacs@gnu.org>
2002-11-15 17:24 ` Deleting chunks of whitespace Richard V. Molen
2002-11-15 17:42 ` Benjamin Rutt
2002-11-15 18:22 ` Benjamin Lewis
2002-11-15 19:42 ` Richard V. Molen
2002-11-15 20:02 ` Benjamin Lewis
2002-11-15 21:08 ` Richard V. Molen
2002-11-16 15:58 ` Ehud Karni
[not found] ` <mailman.1037463184.24264.help-gnu-emacs@gnu.org>
2002-11-18 16:26 ` Richard V. Molen
2002-11-18 18:07 ` Ehud Karni
[not found] ` <mailman.1037643734.10691.help-gnu-emacs@gnu.org>
2002-11-18 18:55 ` Richard V. Molen
2002-11-16 18:54 ` Kai Großjohann
2002-11-15 17:42 Moore, Mathew L
-- strict thread matches above, loose matches on Subject: below --
2002-11-15 15:32 Moore, Mathew L
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).