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

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

bug#20408: 24.5; How to escape the transient region when C-x TAB'ing?


From: npostavs
Subject: bug#20408: 24.5; How to escape the transient region when C-x TAB'ing?
Date: Sun, 03 Jul 2016 14:31:17 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.93 (gnu/linux)

tags 20408 patch
quit

Sebastien Vauban <sva-news@mygooglest.com> writes:
>
> When using C-x TAB, I can't escape from the transient mode as described
> in the help:
>
[...]
>
> If I type a letter, it replaces the region.
>
> That must come from my setting:
>
>   ┌────
>   │ (delete-selection-mode 1)             ; Overwrite region.
>   └────
>
> Then, how do we escape in such a case?
>
> - C-g does not seem right -- even if it works.

What's wrong with C-g?  It's the standard Emacs way to exit any kind of
state.

But it seems with a tiny patch (see below), we can make this command
work nicely with delete-selection-mode too.

>From 8575af7322ed318cb02c74f64f0d1b488ad9cbaf Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Sun, 3 Jul 2016 14:00:19 -0400
Subject: [PATCH v1] Don't delete selection after indent-rigidly

* lisp/indent.el (indent-rigidly): Pass `deactivate-mark' as the ON-EXIT
function to `set-transient-map', this prevents `delete-selection-mode'
from deleting the text that was just indented.
---
 lisp/indent.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/indent.el b/lisp/indent.el
index 0bbb520..0f6c68d 100644
--- a/lisp/indent.el
+++ b/lisp/indent.el
@@ -218,7 +218,7 @@ indent-rigidly
         (message
         (substitute-command-keys
          "Indent region with \\<indent-rigidly-map>\\[indent-rigidly-left], 
\\[indent-rigidly-right], \\[indent-rigidly-left-to-tab-stop], or 
\\[indent-rigidly-right-to-tab-stop]."))
-        (set-transient-map indent-rigidly-map t))
+        (set-transient-map indent-rigidly-map t #'deactivate-mark))
     (save-excursion
       (goto-char end)
       (setq end (point-marker))
-- 
2.8.0


reply via email to

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