aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim F. Storm2005-12-08 22:24:35 +0000
committerKim F. Storm2005-12-08 22:24:35 +0000
commit1638bf546dca08ea15153c70c5e4df20ee6477c6 (patch)
tree5251472295d8a27000f29f6df3edad20334dc5f8
parent3d5968919cb5b4ecf56a91aa244e0e16094efa24 (diff)
downloademacs-1638bf546dca08ea15153c70c5e4df20ee6477c6.tar.gz
emacs-1638bf546dca08ea15153c70c5e4df20ee6477c6.zip
* 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.
-rw-r--r--lisp/emulation/cua-base.el43
-rw-r--r--lisp/emulation/cua-rect.el15
2 files changed, 34 insertions, 24 deletions
diff --git a/lisp/emulation/cua-base.el b/lisp/emulation/cua-base.el
index b36e4158c2f..fd5249fed1a 100644
--- a/lisp/emulation/cua-base.el
+++ b/lisp/emulation/cua-base.el
@@ -329,15 +329,6 @@ interpreted as a register number."
329 :type 'boolean 329 :type 'boolean
330 :group 'cua) 330 :group 'cua)
331 331
332(defcustom cua-use-hyper-key nil
333 "*If non-nil, bind rectangle commands to H-... instead of M-....
334If set to `also', toggle region command is also on C-return.
335Must be set prior to enabling CUA."
336 :type '(choice (const :tag "Meta key and C-return" nil)
337 (const :tag "Hyper key only" only)
338 (const :tag "Hyper key and C-return" also))
339 :group 'cua)
340
341(defcustom cua-enable-region-auto-help nil 332(defcustom cua-enable-region-auto-help nil
342 "*If non-nil, automatically show help for active region." 333 "*If non-nil, automatically show help for active region."
343 :type 'boolean 334 :type 'boolean
@@ -379,6 +370,15 @@ and after the region marked by the rectangle to search."
379 (other :tag "Enabled" t)) 370 (other :tag "Enabled" t))
380 :group 'cua) 371 :group 'cua)
381 372
373(defcustom cua-rectangle-modifier-key 'meta
374 "*Modifier key used for rectangle commands bindings.
375On non-window systems, always use the meta modifier.
376Must be set prior to enabling CUA."
377 :type '(choice (const :tag "Meta key" meta)
378 (const :tag "Hyper key" hyper )
379 (const :tag "Super key" super))
380 :group 'cua)
381
382(defcustom cua-enable-rectangle-auto-help t 382(defcustom cua-enable-rectangle-auto-help t
383 "*If non-nil, automatically show help for region, rectangle and global mark." 383 "*If non-nil, automatically show help for region, rectangle and global mark."
384 :type 'boolean 384 :type 'boolean
@@ -1180,11 +1180,13 @@ If ARG is the atom `-', scroll upward by nearly full screen."
1180 1180
1181;;; Keymaps 1181;;; Keymaps
1182 1182
1183;; Cached value of actual cua-rectangle-modifier-key
1184(defvar cua--rectangle-modifier-key 'meta)
1185
1183(defun cua--M/H-key (map key fct) 1186(defun cua--M/H-key (map key fct)
1184 ;; bind H-KEY or M-KEY to FCT in MAP 1187 ;; bind H-KEY or M-KEY to FCT in MAP
1185 (if (eq key 'space) (setq key ?\s))
1186 (unless (listp key) (setq key (list key))) 1188 (unless (listp key) (setq key (list key)))
1187 (define-key map (vector (cons (if cua-use-hyper-key 'hyper 'meta) key)) fct)) 1189 (define-key map (vector (cons cua--rectangle-modifier-key key)) fct))
1188 1190
1189(defun cua--self-insert-char-p (def) 1191(defun cua--self-insert-char-p (def)
1190 ;; Return DEF if current key sequence is self-inserting in 1192 ;; 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."
1266 (cua--shift-control-prefix ?\C-x arg)) 1268 (cua--shift-control-prefix ?\C-x arg))
1267 1269
1268(defun cua--init-keymaps () 1270(defun cua--init-keymaps ()
1269 (unless (eq cua-use-hyper-key 'only) 1271 ;; Cache actual rectangle modifier key.
1270 (define-key cua-global-keymap [(control return)] 'cua-set-rectangle-mark)) 1272 (setq cua--rectangle-modifier-key
1271 (when cua-use-hyper-key 1273 (if (and cua-rectangle-modifier-key
1272 (cua--M/H-key cua-global-keymap 'space 'cua-set-rectangle-mark) 1274 (memq window-system '(x)))
1273 (define-key cua-global-keymap [(hyper mouse-1)] 'cua-mouse-set-rectangle-mark)) 1275 cua-rectangle-modifier-key
1276 'meta))
1277 ;; C-return always toggles rectangle mark
1278 (define-key cua-global-keymap [(control return)] 'cua-set-rectangle-mark)
1279 (unless (eq cua--rectangle-modifier-key 'meta)
1280 (cua--M/H-key cua-global-keymap ?\s 'cua-set-rectangle-mark)
1281 (define-key cua-global-keymap
1282 (vector (list cua--rectangle-modifier-key 'mouse-1)) 'cua-mouse-set-rectangle-mark))
1274 1283
1275 (define-key cua-global-keymap [(shift control ?\s)] 'cua-toggle-global-mark) 1284 (define-key cua-global-keymap [(shift control ?\s)] 'cua-toggle-global-mark)
1276 1285
@@ -1387,7 +1396,7 @@ CUA bindings, or `cua-prefix-override-inhibit-delay' to change
1387the prefix fallback behavior." 1396the prefix fallback behavior."
1388 :global t 1397 :global t
1389 :group 'cua 1398 :group 'cua
1390 :set-after '(cua-enable-modeline-indications cua-use-hyper-key) 1399 :set-after '(cua-enable-modeline-indications cua-rectangle-modifier-key)
1391 :require 'cua-base 1400 :require 'cua-base
1392 :link '(emacs-commentary-link "cua-base.el") 1401 :link '(emacs-commentary-link "cua-base.el")
1393 (setq mark-even-if-inactive t) 1402 (setq mark-even-if-inactive t)
diff --git a/lisp/emulation/cua-rect.el b/lisp/emulation/cua-rect.el
index e80a332751b..2884a25e597 100644
--- a/lisp/emulation/cua-rect.el
+++ b/lisp/emulation/cua-rect.el
@@ -1358,7 +1358,9 @@ With prefix arg, indent to that column."
1358 1358
1359(defun cua-help-for-rectangle (&optional help) 1359(defun cua-help-for-rectangle (&optional help)
1360 (interactive) 1360 (interactive)
1361 (let ((M (if cua-use-hyper-key " H-" " M-"))) 1361 (let ((M (cond ((eq cua--rectangle-modifier-key 'hyper) " H-")
1362 ((eq cua--rectangle-modifier-key 'super) " s-")
1363 (t " M-"))))
1362 (message 1364 (message
1363 (concat (if help "C-?:help" "") 1365 (concat (if help "C-?:help" "")
1364 M "p:pad" M "o:open" M "c:close" M "b:blank" 1366 M "p:pad" M "o:open" M "c:close" M "b:blank"
@@ -1410,12 +1412,11 @@ With prefix arg, indent to that column."
1410 (cua--M/H-key cua--rectangle-keymap key cmd)) 1412 (cua--M/H-key cua--rectangle-keymap key cmd))
1411 1413
1412(defun cua--init-rectangles () 1414(defun cua--init-rectangles ()
1413 (unless (eq cua-use-hyper-key 'only) 1415 (define-key cua--rectangle-keymap [(control return)] 'cua-clear-rectangle-mark)
1414 (define-key cua--rectangle-keymap [(control return)] 'cua-clear-rectangle-mark) 1416 (define-key cua--region-keymap [(control return)] 'cua-toggle-rectangle-mark)
1415 (define-key cua--region-keymap [(control return)] 'cua-toggle-rectangle-mark)) 1417 (unless (eq cua--rectangle-modifier-key 'meta)
1416 (when cua-use-hyper-key 1418 (cua--rect-M/H-key ?\s 'cua-clear-rectangle-mark)
1417 (cua--rect-M/H-key 'space 'cua-clear-rectangle-mark) 1419 (cua--M/H-key cua--region-keymap ?\s 'cua-toggle-rectangle-mark))
1418 (cua--M/H-key cua--region-keymap 'space 'cua-toggle-rectangle-mark))
1419 1420
1420 (define-key cua--rectangle-keymap [remap copy-region-as-kill] 'cua-copy-rectangle) 1421 (define-key cua--rectangle-keymap [remap copy-region-as-kill] 'cua-copy-rectangle)
1421 (define-key cua--rectangle-keymap [remap kill-ring-save] 'cua-copy-rectangle) 1422 (define-key cua--rectangle-keymap [remap kill-ring-save] 'cua-copy-rectangle)