]> git.eshelyaron.com Git - emacs.git/commitdiff
* emulation/cua-base.el (cua-use-hyper-key): Replaced by ...
authorKim F. Storm <storm@cua.dk>
Thu, 8 Dec 2005 22:24:35 +0000 (22:24 +0000)
committerKim F. Storm <storm@cua.dk>
Thu, 8 Dec 2005 22:24:35 +0000 (22:24 +0000)
(cua-rectangle-modifier-key): ... this.  New defcustom.  Can now
select either meta, hyper, or super modifier for rectangle commands.
(cua--rectangle-modifier-key): New defvar.
(cua--M/H-key): Use it.  Remove special case for 'space.
(cua--init-keymaps): Initialize it from cua-rectangle-modifier-key
on X, to meta otherwise.  Always bind C-return to toggle
rectangle.  Pass ?\s instead of 'space to cua--M/H-key.

* emulation/cua-rect.el (cua-help-for-rectangle): Use
cua--rectangle-modifier-key.  Handle super modifier too.
(cua--init-rectangles): Always bind C-return to toggle rectangle.
Pass ?\s instead of 'space to cua--M/H-key and cua--rect-M/H-key.

lisp/emulation/cua-base.el
lisp/emulation/cua-rect.el

index b36e4158c2f176b15f4c43a55d3f316e8a763bd6..fd5249fed1af3351ca6134d267dc67deda135c6a 100644 (file)
@@ -329,15 +329,6 @@ interpreted as a register number."
   :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
@@ -379,6 +370,15 @@ and after the region marked by the rectangle to search."
                 (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
@@ -1180,11 +1180,13 @@ If ARG is the atom `-', scroll upward by nearly full screen."
 
 ;;; 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
@@ -1266,11 +1268,18 @@ If ARG is the atom `-', scroll upward by nearly full screen."
   (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)
 
@@ -1387,7 +1396,7 @@ CUA bindings, or `cua-prefix-override-inhibit-delay' to change
 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)
index e80a332751b5d9e1e917a84983e9fbec16a185fa..2884a25e597a5c3ee21f014c3cfb1e7b98d79d91 100644 (file)
@@ -1358,7 +1358,9 @@ With prefix arg, indent to that column."
 
 (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"
@@ -1410,12 +1412,11 @@ With prefix arg, indent to that column."
   (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)