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

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

Re: Deleting a word using keybinding


From: Harald Jörg
Subject: Re: Deleting a word using keybinding
Date: Thu, 15 Oct 2020 22:25:23 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.3.1

On 10/15/20 8:44 PM, Christopher Dimech wrote:

> I have updated my function to kill words forward so that even if I am
> in the middle of a word that word will be killed. I also consider that
> if there are multiple spaces, I delete just the spaces spaces but not
> next word.

This isn't exactly what the function does: If there are two or more
spaces between words, then only spaces to the right of point are
deleted.

Also, when you delete _all_ spaces, you merge two words into one.  This
is the cause for your observation:

> I am finding a problem however when deleting part of a sentence by
> contiuing to press C--<delete> because when the point happens to be
> between two words, I end up with the two words stuck together (the
> previous and thn forward), which deletes the two words when I hit
> C-<delete> again.

It really pays off when you spend the effort to write down how you
want the function to behave in all relevant situations.  It is good
practice to have a docstring for your command anyway, and you might
detect contradictory requirements before you start writing the
function.

If point is before a whitespace character, you could either do
nothing, or delete the previous, or delete the following word, all of
them make some sense.  Deleting whitespace seems somewhat unrelated.

There still are cases where your function does not what you seem to
expect: If the text in the buffer is "foo bar", and point is before
the "a" in "bar", then executing M-x kill-spacword kills "foo".
--
Cheers,
haj



reply via email to

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