emacs-devel
[Top][All Lists]
Advanced

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

keyboard-escape-quit (was: delete-selection-mode)


From: Juri Linkov
Subject: keyboard-escape-quit (was: delete-selection-mode)
Date: Sun, 21 Mar 2010 01:54:35 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (x86_64-pc-linux-gnu)

> Interesting, but I think we need a key that doesn't have any meaning in the
> context where a region might be active. Maybe that means we need a key that
> isn't yet bound; dunno.

I use `keyboard-escape-quit' all the time to deactivate the region
without any problem.  Actually I rebound it to the single ESC (because ESC
as a prefix is not needed when Meta M- is available on X and xterm).
And this single ESC to deactivate the region is very convenient.

> Imagine that you want to use the key for one of the uses described above (e.g.
> clear the region or exit the minibuffer or a recursive edit). If the region is
> active in the current buffer (e.g. the minibuffer in the latter cases), then
> would you be doing ESC ESC ESC ESC ESC ESC? And what if you wanted one of 
> those
> behaviors but did not also want to deactivate the region?

I think in `keyboard-escape-quit' deselecting the region should have
a higher priority than deactivating the minibuffer because it's possible
to select the region in the minibuffer, and when the minibuffer is gone
then there is no region to deselect anymore.  IOW, the current behavior
breaks the logic of `keyboard-escape-quit' that should cancel one active
feature per invocation.

=== modified file 'lisp/simple.el'
--- lisp/simple.el      2010-03-05 12:01:10 +0000
+++ lisp/simple.el      2010-03-20 23:52:09 +0000
@@ -5591,13 +5603,13 @@ (defun keyboard-escape-quit ()
 cancel the use of the current buffer (for special-purpose buffers),
 or go back to just one window (by deleting all but the selected window)."
   (interactive)
-  (cond ((eq last-command 'mode-exited) nil)
+  (cond ((region-active-p)
+        (deactivate-mark))
+       ((eq last-command 'mode-exited) nil)
        ((> (minibuffer-depth) 0)
         (abort-recursive-edit))
        (current-prefix-arg
         nil)
-       ((region-active-p)
-        (deactivate-mark))
        ((> (recursion-depth) 0)
         (exit-recursive-edit))
        (buffer-quit-function

PS: Or maybe we should handle two cases in `keyboard-escape-quit':
deselecting the region in the minibuffer (with a priority higher than
deactivating the minibuffer) and deselecting the region in normal buffers
(with a priority lower than deactivating the minibuffer)?

-- 
Juri Linkov
http://www.jurta.org/emacs/




reply via email to

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