[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Deleting a word using keybinding
From: |
Christopher Dimech |
Subject: |
Re: Deleting a word using keybinding |
Date: |
Thu, 15 Oct 2020 20:44:02 +0200 |
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.
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.
(defun kill-spacword ()
(interactive)
(if (looking-at "[ \t\n]")
(let ((p (point)))
( re-search-forward "[^ \t\n]" nil :no-error )
( backward-char )
( kill-region p (point) )
)
( progn
(backward-char)
(if (looking-at "[ \t\n]")
(kill-word 1)
( progn
(backward-word)
(kill-word 1)
)
)
)
)
)
Sent: Thursday, October 15, 2020 at 1:20 PM
From: "Harald Jörg" <haj@posteo.de>
To: "Christopher Dimech" <dimech@gmx.com>, "Help Gnu Emacs"
<help-gnu-emacs@gnu.org>
Subject: Re: Deleting a word using keybinding
On 10/15/20 12:26 PM, Christopher Dimech wrote:
>
> I am trying to delete a word using keybinding string "C-<tab>" but
the
> Chord is still showing as undefined.
>
> I would like to delete a word even if I happen to be in the middle of
> it., so I move backward.
>
> Here is the function
>
> ( global-set-key (kbd "C-<tab>" )
> ( lambda () (interactive)
> ( (backward-word)
> (kill-word 1)
> )
> )
> )
If I get rid of one pair of parens, it works for me.
( global-set-key (kbd "C-<tab>" )
( lambda () (interactive)
(backward-word)
(kill-word 1)
)
)
With the extra parens in your code, I get 'Invalid function:
(backward-word)'. Maybe this is why you don't see any effect?
Also note that if your point happens to be on the first character of a
word, this function deletes the _previous_ word.
--
Cheers,
haj
- Deleting a word using keybinding, Christopher Dimech, 2020/10/15
- Re: Deleting a word using keybinding, Jeremie Juste, 2020/10/15
- Re: Deleting a word using keybinding, Harald Jörg, 2020/10/15
- Re: Deleting a word using keybinding, Christopher Dimech, 2020/10/15
- Re: Deleting a word using keybinding,
Christopher Dimech <=
- Re: Deleting a word using keybinding, Harald Jörg, 2020/10/15
- Re: Deleting a word using keybinding, Christopher Dimech, 2020/10/15
- Re: Deleting a word using keybinding, Thien-Thi Nguyen, 2020/10/15
- Re: Deleting a word using keybinding, Christopher Dimech, 2020/10/15
- Re: Deleting a word using keybinding, Christopher Dimech, 2020/10/15
- RE: Deleting a word using keybinding, Drew Adams, 2020/10/15
- Re: RE: Deleting a word using keybinding, Christopher Dimech, 2020/10/15
- Re: Deleting a word using keybinding, Stephen Berman, 2020/10/15
Re: Deleting a word using keybinding, Stephen Berman, 2020/10/15
Re: Deleting a word using keybinding, Stefan Monnier, 2020/10/15