From: pjb@informatimago.com (Pascal J. Bourguignon)
To: help-gnu-emacs@gnu.org
Subject: Re: Text selection can't be erased by pressing delete
Date: Fri, 20 Aug 2010 14:45:21 +0200 [thread overview]
Message-ID: <87iq353126.fsf@kuiper.lan.informatimago.com> (raw)
In-Reply-To: mailman.1.1282306148.7914.help-gnu-emacs@gnu.org
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/
next parent reply other threads:[~2010-08-20 12:45 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.1.1282306148.7914.help-gnu-emacs@gnu.org>
2010-08-20 12:45 ` Pascal J. Bourguignon [this message]
2010-08-26 22:19 ` Text selection can't be erased by pressing delete Xah Lee
2010-08-26 22:17 ` Xah Lee
2010-08-20 12:08 Gabriel TEIXEIRA
2010-08-20 12:27 ` Eli Zaretskii
2010-08-20 12:57 ` Gabriel TEIXEIRA
2010-08-20 13:15 ` Gabriel TEIXEIRA
2010-08-20 14:02 ` Gabriel TEIXEIRA
[not found] ` <mailman.8.1282310110.29058.help-gnu-emacs@gnu.org>
2010-08-26 20:16 ` Uday Reddy
2010-08-20 16:42 ` Bob Proulx
2010-08-20 17:35 ` Gabriel TEIXEIRA
[not found] ` <mailman.3.1282326790.14034.help-gnu-emacs@gnu.org>
2010-08-20 22:24 ` Pascal J. Bourguignon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87iq353126.fsf@kuiper.lan.informatimago.com \
--to=pjb@informatimago.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).