* Re: Cua-mode makes active region disappear in transient-mark-mode
2008-11-24 9:24 Cua-mode makes active region disappear in transient-mark-mode Teemu Likonen
@ 2008-11-24 13:16 ` Xah Lee
2008-11-24 16:25 ` Allan Gottlieb
2008-11-24 14:54 ` Teemu Likonen
1 sibling, 1 reply; 4+ messages in thread
From: Xah Lee @ 2008-11-24 13:16 UTC (permalink / raw)
To: help-gnu-emacs
On Nov 24, 1:24 am, Teemu Likonen <tliko...@iki.fi> wrote:
> I like cua-selection-mode for its rectangle support. Still, there is a
> serious annoyance to which I haven't found a solution. This affects
> region behavior in transient-mark-mode which I also use.
>
> When I select a paragraph with M-h (mark-paragraph) and move the point
> the region disappears if cua-mode is switched on. Without cua-mode I can
> move the edges of the region and it stays visible. This is the only
> reason why I don't keep cua-(selection-)mode on by default. Can I make
> cua-mode to not make active region disappear?
on my machine, with cua-mode on, arrow keys or any cursor moving
commands don't deactivate the region.
i did spend maybe 30 min answering this post... scratched several
times on what i wrote about the var deactivate-mark and modern UI ...
so i got curious... if i started emacs with -q and then it does. So,
something's in my emacs init file did some magic... but i can't think
of any...
O, ok, i think i found it!
;; prevent cua-mode from going into selection mode when commands with
Shift key is used.
(add-hook 'cua-mode-hook
(lambda ()
(put 'cua-scroll-down 'CUA nil)
(put 'cua-scroll-up 'CUA nil)
(put 'backward-paragraph 'CUA nil)
(put 'forward-paragraph 'CUA nil)
(put 'beginning-of-buffer 'CUA nil)
(put 'end-of-buffer 'CUA nil)
(put 'move-end-of-line 'CUA nil)
)
)
from:
• A Ergonomic Keyboard Shortcut Layout For Emacs
http://xahlee.org/emacs/ergonomic_emacs_keybinding.html
... oh wait but the hook doesn't have any cursor moving commands...
note that i also have
(delete-selection-mode t)
but i don't think this matters.
(Note that delete-selection-mode automatically sets transient-mark-
mode to t, however, cua mode does not actually call transient-mark-
mode, but does emulate its behavior in its own implementation, and
actually set transient-mark-mode to t for display purposes)
OK, now i found it for sure.
Basically, if you remap your cursor moving keys, then it won't
deactivate selection.
For example, do a text selection, then type M-x backward-word, you'll
see that your region remains active. Since i have all my cursor moving
shortcuts different from default, so they don't deactivate region for
me. Perhaps cua mode is checking actual keypresses.
Ok, i try this: set the cursor moving commands's property CUA to nil,
like in the above hook.
cua mode is quite complex with respect to elisp coding ...
--------------
... i didn't know what cua rectangle features do, and did read up. It
is very nice. I wonder if it should be a separate package from cua.
(for those don't want to bother looking up, just turn cua-mode on,
then press Ctrl+Enter, then move arrow keys, then see that a real
rectangular highlighting is done, implemented using overlay.)
i've always been using kill-rectangle and string-rectangle for like 10
years. One thing i missed is how to actually copy and paste a column
of text. Never did bother to read the proper manual... and i suppose
now cua mode does it.
Cua mode does support copying/pasting a column of text right?
is it possible to do this with rectangle* commands?
Xah
∑ http://xahlee.org/
☄
^ permalink raw reply [flat|nested] 4+ messages in thread