:type 'boolean
:group 'cua)
-(defcustom cua-use-hyper-key nil
- "*If non-nil, bind rectangle commands to H-... instead of M-....
-If set to `also', toggle region command is also on C-return.
-Must be set prior to enabling CUA."
- :type '(choice (const :tag "Meta key and C-return" nil)
- (const :tag "Hyper key only" only)
- (const :tag "Hyper key and C-return" also))
- :group 'cua)
-
(defcustom cua-enable-region-auto-help nil
"*If non-nil, automatically show help for active region."
:type 'boolean
(other :tag "Enabled" t))
:group 'cua)
+(defcustom cua-rectangle-modifier-key 'meta
+ "*Modifier key used for rectangle commands bindings.
+On non-window systems, always use the meta modifier.
+Must be set prior to enabling CUA."
+ :type '(choice (const :tag "Meta key" meta)
+ (const :tag "Hyper key" hyper )
+ (const :tag "Super key" super))
+ :group 'cua)
+
(defcustom cua-enable-rectangle-auto-help t
"*If non-nil, automatically show help for region, rectangle and global mark."
:type 'boolean
;;; Keymaps
+;; Cached value of actual cua-rectangle-modifier-key
+(defvar cua--rectangle-modifier-key 'meta)
+
(defun cua--M/H-key (map key fct)
;; bind H-KEY or M-KEY to FCT in MAP
- (if (eq key 'space) (setq key ?\s))
(unless (listp key) (setq key (list key)))
- (define-key map (vector (cons (if cua-use-hyper-key 'hyper 'meta) key)) fct))
+ (define-key map (vector (cons cua--rectangle-modifier-key key)) fct))
(defun cua--self-insert-char-p (def)
;; Return DEF if current key sequence is self-inserting in
(cua--shift-control-prefix ?\C-x arg))
(defun cua--init-keymaps ()
- (unless (eq cua-use-hyper-key 'only)
- (define-key cua-global-keymap [(control return)] 'cua-set-rectangle-mark))
- (when cua-use-hyper-key
- (cua--M/H-key cua-global-keymap 'space 'cua-set-rectangle-mark)
- (define-key cua-global-keymap [(hyper mouse-1)] 'cua-mouse-set-rectangle-mark))
+ ;; Cache actual rectangle modifier key.
+ (setq cua--rectangle-modifier-key
+ (if (and cua-rectangle-modifier-key
+ (memq window-system '(x)))
+ cua-rectangle-modifier-key
+ 'meta))
+ ;; C-return always toggles rectangle mark
+ (define-key cua-global-keymap [(control return)] 'cua-set-rectangle-mark)
+ (unless (eq cua--rectangle-modifier-key 'meta)
+ (cua--M/H-key cua-global-keymap ?\s 'cua-set-rectangle-mark)
+ (define-key cua-global-keymap
+ (vector (list cua--rectangle-modifier-key 'mouse-1)) 'cua-mouse-set-rectangle-mark))
(define-key cua-global-keymap [(shift control ?\s)] 'cua-toggle-global-mark)
the prefix fallback behavior."
:global t
:group 'cua
- :set-after '(cua-enable-modeline-indications cua-use-hyper-key)
+ :set-after '(cua-enable-modeline-indications cua-rectangle-modifier-key)
:require 'cua-base
:link '(emacs-commentary-link "cua-base.el")
(setq mark-even-if-inactive t)
(defun cua-help-for-rectangle (&optional help)
(interactive)
- (let ((M (if cua-use-hyper-key " H-" " M-")))
+ (let ((M (cond ((eq cua--rectangle-modifier-key 'hyper) " H-")
+ ((eq cua--rectangle-modifier-key 'super) " s-")
+ (t " M-"))))
(message
(concat (if help "C-?:help" "")
M "p:pad" M "o:open" M "c:close" M "b:blank"
(cua--M/H-key cua--rectangle-keymap key cmd))
(defun cua--init-rectangles ()
- (unless (eq cua-use-hyper-key 'only)
- (define-key cua--rectangle-keymap [(control return)] 'cua-clear-rectangle-mark)
- (define-key cua--region-keymap [(control return)] 'cua-toggle-rectangle-mark))
- (when cua-use-hyper-key
- (cua--rect-M/H-key 'space 'cua-clear-rectangle-mark)
- (cua--M/H-key cua--region-keymap 'space 'cua-toggle-rectangle-mark))
+ (define-key cua--rectangle-keymap [(control return)] 'cua-clear-rectangle-mark)
+ (define-key cua--region-keymap [(control return)] 'cua-toggle-rectangle-mark)
+ (unless (eq cua--rectangle-modifier-key 'meta)
+ (cua--rect-M/H-key ?\s 'cua-clear-rectangle-mark)
+ (cua--M/H-key cua--region-keymap ?\s 'cua-toggle-rectangle-mark))
(define-key cua--rectangle-keymap [remap copy-region-as-kill] 'cua-copy-rectangle)
(define-key cua--rectangle-keymap [remap kill-ring-save] 'cua-copy-rectangle)