Mercurial > emacs
comparison lisp/emulation/cua-base.el @ 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 | 15ed3778b098 |
children | bbaecffc7697 39bb10ce301a 7beb78bc1f8e |
comparison
equal
deleted
inserted
replaced
67404:9d14391845f1 | 67405:f8d3bd39d0a1 |
---|---|
327 (defcustom cua-delete-copy-to-register-0 t | 327 (defcustom cua-delete-copy-to-register-0 t |
328 "*If non-nil, save last deleted region or rectangle to register 0." | 328 "*If non-nil, save last deleted region or rectangle to register 0." |
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-.... | |
334 If set to `also', toggle region command is also on C-return. | |
335 Must 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 |
344 :group 'cua) | 335 :group 'cua) |
345 | 336 |
375 present. The number specifies then number of characters before | 366 present. The number specifies then number of characters before |
376 and after the region marked by the rectangle to search." | 367 and after the region marked by the rectangle to search." |
377 :type '(choice (number :tag "Auto detect (limit)") | 368 :type '(choice (number :tag "Auto detect (limit)") |
378 (const :tag "Disabled" nil) | 369 (const :tag "Disabled" nil) |
379 (other :tag "Enabled" t)) | 370 (other :tag "Enabled" t)) |
371 :group 'cua) | |
372 | |
373 (defcustom cua-rectangle-modifier-key 'meta | |
374 "*Modifier key used for rectangle commands bindings. | |
375 On non-window systems, always use the meta modifier. | |
376 Must 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) | 380 :group 'cua) |
381 | 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 |
1178 (error nil)))) | 1178 (error nil)))) |
1179 | 1179 |
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 |
1191 ;; global-map. | 1193 ;; global-map. |
1192 (if (memq (global-key-binding (this-single-command-keys)) | 1194 (if (memq (global-key-binding (this-single-command-keys)) |
1264 (defun cua--shift-control-x-prefix (arg) | 1266 (defun cua--shift-control-x-prefix (arg) |
1265 (interactive "P") | 1267 (interactive "P") |
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 |
1277 ;; replace region with rectangle or element on kill ring | 1286 ;; replace region with rectangle or element on kill ring |
1278 (define-key cua-global-keymap [remap yank] 'cua-paste) | 1287 (define-key cua-global-keymap [remap yank] 'cua-paste) |
1385 You can customize `cua-enable-cua-keys' to completely disable the | 1394 You can customize `cua-enable-cua-keys' to completely disable the |
1386 CUA bindings, or `cua-prefix-override-inhibit-delay' to change | 1395 CUA bindings, or `cua-prefix-override-inhibit-delay' to change |
1387 the prefix fallback behavior." | 1396 the 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) |
1394 (setq highlight-nonselected-windows nil) | 1403 (setq highlight-nonselected-windows nil) |
1395 | 1404 |