unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Xah Lee <xahlee@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Cua-mode makes active region disappear in transient-mark-mode
Date: Mon, 24 Nov 2008 05:16:02 -0800 (PST)	[thread overview]
Message-ID: <7e703639-ea41-4d64-b73c-e0f93e415d89@v39g2000pro.googlegroups.com> (raw)
In-Reply-To: 871vx1o4sh.fsf@iki.fi

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/

  reply	other threads:[~2008-11-24 13:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-24  9:24 Cua-mode makes active region disappear in transient-mark-mode Teemu Likonen
2008-11-24 13:16 ` Xah Lee [this message]
2008-11-24 16:25   ` Allan Gottlieb
2008-11-24 14:54 ` Teemu Likonen

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=7e703639-ea41-4d64-b73c-e0f93e415d89@v39g2000pro.googlegroups.com \
    --to=xahlee@gmail.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).