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

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

Re: Text selection can't be erased by pressing delete


From: Pascal J. Bourguignon
Subject: Re: Text selection can't be erased by pressing delete
Date: Wed, 08 Dec 2010 15:25:41 -0000
User-agent: Gnus/5.101 (Gnus v5.10.10) Emacs/23.2 (gnu/linux)

Gabriel TEIXEIRA <gabriel_teixeira@sdesigns.eu> writes:

> Hello all,
>
> I've been working with three simultaneous emacs windows, each one
> containing a diferent project, and I noticed that two of those three
> are presenting a weird behaviour. When I select a text in those
> windows (like by pushing Shift and then the arrow keys), and then I
> push the key Delete, I expect that the selected/highlighted text be
> erased, but instead, it erases a single character to the left of the
> cursor (like would happen without the selection) and the selection
> disappears (although the same operation works with Backspace or
> Shift+Delete normally). 

This is the normal emacs behavior.  You've been distorted by the later
"graphical user interfaces".

You see, emacs stays consistent.  There's a command to delete the
previous character, and there's another command to delete a region.
Each one is bound to a different key.  There's no reason why that should
change just because you change the selected region.

So, to delete the previous character, you use delete-backward-char,
which is usually bound to DEL, and to delete the region you use
kill-region, which is usually bound to C-w (like: Control "wipe").


> It seems that the Delete key is not anymore
> aware of the text selection. It is even more weird the fact that this
> doesn't happen with the window that I opened the last and the other
> windows that I opened after to check the behaviour. I seems that emacs
> "wears" after some time opened. Anyone have any idea of what's this?
> Is this a bug or I typed accidentaly any command that triggers this
> behaviour?

There are major modes, and minor modes, and also random code that can
change the key maps.

You could bind your own command globally to DEL, but it will still be
overriden by specific modes.

For example, you could do:

    (defun distorted-gui-delete (start end)
       (interactive "*r")
       (message "%S %S" start end)
       (if (= start end)
          (delete-backward-char 1)
          (delete-region start end)))

    (global-set-key (kbd "DEL") 'distorted-gui-delete)


But some modes will still override this binding with their specific mapping.


So better remember that DEL deletes the previous character(s), and C-w
kills the region.  (Notice that M-w saves it to the kill-ring, so that
you can later yank it with C-y).

Notice also that you can type M-DEL to kill the previous word, so that
you often don't need to select anything to kill what you want.



-- 
__Pascal Bourguignon__                     http://www.informatimago.com/


reply via email to

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