[Top][All Lists]

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

Re: Deleting chunks of whitespace

From: Richard V. Molen
Subject: Re: Deleting chunks of whitespace
Date: 18 Nov 2002 08:26:55 -0800
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

"Ehud Karni" <> writes:

> On 15 Nov 2002 13:08:48 -0800, (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

Signature under construction, safety glasses required.

reply via email to

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