Emacs: Disable shift-selection in CUA-mode

1.6k views Asked by At

I managed to disable the built-in shift-selection via (set-variable 'shift-select-mode nil). And I like the C-Ret-column-selection of CUA-mode. But CUA automatically enables shift-selection (but seemingly not via the variable shift-select-mode).

  • So, is there a possibility to disable shift-selection within CUA-mode?
  • Or: Is there a way to use the column-selection-feature of CUA-mode exclusively, i.e. without any other CUA-things?
3

There are 3 answers

0
phils On BEST ANSWER

This isn't a solution, but FYI...

I noticed this variable mentioned in the help for cua-mode

cua-highlight-region-shift-only is a variable defined in `cua-base.el'.

*If non-nil, only highlight region if marked with S-<move>.
When this is non-nil, CUA toggles `transient-mark-mode' on when the region
is marked using shifted movement keys, and off when the mark is cleared.
But when the mark was set using M-x cua-set-mark, Transient Mark mode
is not turned on.

cua-mode does this:

(setq shift-select-mode nil)
(setq transient-mark-mode (and cua-mode
               (if cua-highlight-region-shift-only
                   (not cua--explicit-region-start)
                 t))))
0
mattc On

Specifically, to disable the shift-selection for cua-mode, add the following to your init file (e.g. .emacs) prior to turning on cua-mode:

(setq cua-enable-cua-keys nil)
(setq cua-highlight-region-shift-only t) ;; no transient mark mode
(setq cua-toggle-set-mark nil) ;; original set-mark behavior, i.e. no transient-mark-mode

...
(cua-mode)

Originally answered https://superuser.com/a/77453/223457

0
Jonathan Leech-Pepin On

To only enable rectangle (column) editing from Cua you can use the following (from emacs-fu)

(setq cua-enable-cua-keys nil) ;; only for rectangles (cua-mode t)