changeset 67405:f8d3bd39d0a1

* emulation/cua-base.el (cua-use-hyper-key): Replaced by ... (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.
author Kim F. Storm <storm@cua.dk>
date Thu, 08 Dec 2005 22:24:35 +0000
parents 9d14391845f1
children e493ff9c436d
files lisp/emulation/cua-base.el lisp/emulation/cua-rect.el
diffstat 2 files changed, 34 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/emulation/cua-base.el	Thu Dec 08 22:23:59 2005 +0000
+++ b/lisp/emulation/cua-base.el	Thu Dec 08 22:24:35 2005 +0000
@@ -329,15 +329,6 @@
   :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 @@
 		 (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 @@
 
 ;;; 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 @@
   (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 @@
 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)
--- a/lisp/emulation/cua-rect.el	Thu Dec 08 22:23:59 2005 +0000
+++ b/lisp/emulation/cua-rect.el	Thu Dec 08 22:24:35 2005 +0000
@@ -1358,7 +1358,9 @@
 
 (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 @@
   (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)