/[emacs]/emacs/lisp/emulation/cua-base.el
ViewVC logotype

Diff of /emacs/lisp/emulation/cua-base.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.16 by kfstorm, Sat Jan 25 11:41:43 2003 UTC revision 1.17 by lektu, Tue Feb 4 12:56:02 2003 UTC
# Line 54  Line 54 
54  ;; This probably sounds strange and difficult to get used to - but  ;; This probably sounds strange and difficult to get used to - but
55  ;; based on my own experience and the feedback from many users of  ;; based on my own experience and the feedback from many users of
56  ;; this package, it actually works very well and users adapt to it  ;; this package, it actually works very well and users adapt to it
57  ;; instantly - or at least very quickly.  So give it a try!    ;; instantly - or at least very quickly.  So give it a try!
58  ;; ... and in the few cases where you make a mistake and accidentally  ;; ... and in the few cases where you make a mistake and accidentally
59  ;; delete the region - you just undo the mistake (with C-z).  ;; delete the region - you just undo the mistake (with C-z).
60  ;;  ;;
# Line 120  Line 120 
120  ;; --------------------  ;; --------------------
121  ;; Emacs' standard register support is also based on a separate set of  ;; Emacs' standard register support is also based on a separate set of
122  ;; "register commands".  ;; "register commands".
123  ;;  ;;
124  ;; CUA's register support is activated by providing a numeric  ;; CUA's register support is activated by providing a numeric
125  ;; prefix argument to the C-x, C-c, and C-v commands. For example,  ;; prefix argument to the C-x, C-c, and C-v commands. For example,
126  ;; to copy the selected region to register 2, enter [M-2 C-c].  ;; to copy the selected region to register 2, enter [M-2 C-c].
127  ;; Or if you have activated the keypad prefix mode, enter [kp-2 C-c].  ;; Or if you have activated the keypad prefix mode, enter [kp-2 C-c].
128  ;;  ;;
129  ;; And CUA will copy and paste normal region as well as rectangles  ;; And CUA will copy and paste normal region as well as rectangles
130  ;; into the registers, i.e. you use exactly the same command for both.  ;; into the registers, i.e. you use exactly the same command for both.
131  ;;  ;;
132  ;; In addition, the last highlighted text that is deleted (not  ;; In addition, the last highlighted text that is deleted (not
133  ;; copied), e.g. by [delete] or by typing text over a highlighted  ;; copied), e.g. by [delete] or by typing text over a highlighted
134  ;; region, is automatically saved in register 0, so you can insert it  ;; region, is automatically saved in register 0, so you can insert it
# Line 140  Line 140 
140  ;; between the mark and point as a "virtual rectangle", and using a  ;; between the mark and point as a "virtual rectangle", and using a
141  ;; completely separate set of "rectangle commands" [C-x r ...] on the  ;; completely separate set of "rectangle commands" [C-x r ...] on the
142  ;; region to copy, kill, fill a.s.o. the virtual rectangle.  ;; region to copy, kill, fill a.s.o. the virtual rectangle.
143  ;;  ;;
144  ;; cua-mode's superior rectangle support is based on using a true visual  ;; cua-mode's superior rectangle support is based on using a true visual
145  ;; representation of the selected rectangle. To start a rectangle, use  ;; representation of the selected rectangle. To start a rectangle, use
146  ;; [S-return] and extend it using the normal movement keys (up, down,  ;; [S-return] and extend it using the normal movement keys (up, down,
# Line 154  Line 154 
154  ;; the rectangle is inserted into the existing lines in the buffer.  ;; the rectangle is inserted into the existing lines in the buffer.
155  ;; If overwrite-mode is active when you paste a rectangle, it is  ;; If overwrite-mode is active when you paste a rectangle, it is
156  ;; inserted as normal (multi-line) text.  ;; inserted as normal (multi-line) text.
157  ;;  ;;
158  ;; Furthermore, cua-mode's rectangles are not limited to the actual  ;; Furthermore, cua-mode's rectangles are not limited to the actual
159  ;; contents of the buffer, so if the cursor is currently at the end of a  ;; contents of the buffer, so if the cursor is currently at the end of a
160  ;; short line, you can still extend the rectangle to include more columns  ;; short line, you can still extend the rectangle to include more columns
161  ;; of longer lines in the same rectangle.  Sounds strange? Try it!  ;; of longer lines in the same rectangle.  Sounds strange? Try it!
162  ;;  ;;
163  ;; You can enable padding for just this rectangle by pressing [M-p];  ;; You can enable padding for just this rectangle by pressing [M-p];
164  ;; this works like entering `picture-mode' where the tabs and spaces  ;; this works like entering `picture-mode' where the tabs and spaces
165  ;; are automatically converted/inserted to make the rectangle truly  ;; are automatically converted/inserted to make the rectangle truly
# Line 185  Line 185 
185  ;; paragraph like this one, just place the cursor on the first character  ;; paragraph like this one, just place the cursor on the first character
186  ;; of the first line, and enter the following:  ;; of the first line, and enter the following:
187  ;;     S-return M-} ; ; <space>  S-return  ;;     S-return M-} ; ; <space>  S-return
188    
189  ;; cua-mode's rectangle support also includes all the normal rectangle  ;; cua-mode's rectangle support also includes all the normal rectangle
190  ;; functions with easy access:  ;; functions with easy access:
191  ;;  ;;
# Line 202  Line 202 
202  ;; [M-m] copies the rectangle as normal multi-line text (for paste)  ;; [M-m] copies the rectangle as normal multi-line text (for paste)
203  ;; [M-n] fills each line of the rectangle with increasing numbers using  ;; [M-n] fills each line of the rectangle with increasing numbers using
204  ;;       a supplied format string (prompt)  ;;       a supplied format string (prompt)
205  ;; [M-o] opens the rectangle by moving the highlighted text to the  ;; [M-o] opens the rectangle by moving the highlighted text to the
206  ;;       right of the rectangle and filling the rectangle with blanks.  ;;       right of the rectangle and filling the rectangle with blanks.
207  ;; [M-p] toggles rectangle padding, i.e. insert tabs and spaces to  ;; [M-p] toggles rectangle padding, i.e. insert tabs and spaces to
208  ;;       make rectangles truly rectangular  ;;       make rectangles truly rectangular
# Line 222  Line 222 
222  ;; are lost, but can be recovered using [C-z].  ;; are lost, but can be recovered using [C-z].
223    
224  ;; CUA Global Mark  ;; CUA Global Mark
225  ;; ---------------  ;; ---------------
226  ;; The final feature provided by CUA is the "global mark", which  ;; The final feature provided by CUA is the "global mark", which
227  ;; makes it very easy to copy bits and pieces from the same and other  ;; makes it very easy to copy bits and pieces from the same and other
228  ;; files into the current text.  To enable and cancel the global mark,  ;; files into the current text.  To enable and cancel the global mark,
229  ;; use [S-C-space].  The cursor will blink when the global mark  ;; use [S-C-space].  The cursor will blink when the global mark
230  ;; is active.  The following commands behave differently when the global  ;; is active.  The following commands behave differently when the global
231  ;; mark is set:  ;; mark is set:
232  ;; <ch>  All characters (including newlines) you type are inserted  ;; <ch>  All characters (including newlines) you type are inserted
233  ;;       at the global mark!  ;;       at the global mark!
234  ;; [C-x] If you cut a region or rectangle, it is automatically inserted  ;; [C-x] If you cut a region or rectangle, it is automatically inserted
235  ;;       at the global mark, and the global mark is advanced.  ;;       at the global mark, and the global mark is advanced.
# Line 289  If the value is t, these mappings are al Line 289  If the value is t, these mappings are al
289  'shift, these keys are only enabled if the last region was marked with  'shift, these keys are only enabled if the last region was marked with
290  a shifted movement key.  If the value is nil, these keys are never  a shifted movement key.  If the value is nil, these keys are never
291  enabled."  enabled."
292    :type '(choice (const :tag "Disabled" nil)    :type '(choice (const :tag "Disabled" nil)
293                   (const :tag "Shift region only" shift)                   (const :tag "Shift region only" shift)
294                   (other :tag "Enabled" t))                   (other :tag "Enabled" t))
295    :group 'cua)    :group 'cua)
# Line 303  is not turned on." Line 303  is not turned on."
303    :type 'boolean    :type 'boolean
304    :group 'cua)    :group 'cua)
305    
306  (defcustom cua-prefix-override-inhibit-delay  (defcustom cua-prefix-override-inhibit-delay
307    (if (featurep 'lisp-float-type) (/ (float 1) (float 5)) nil)    (if (featurep 'lisp-float-type) (/ (float 1) (float 5)) nil)
308    "*If non-nil, time in seconds to delay before overriding prefix key.    "*If non-nil, time in seconds to delay before overriding prefix key.
309  If there is additional input within this time, the prefix key is  If there is additional input within this time, the prefix key is
# Line 325  If the value is nil, use a shifted prefi Line 325  If the value is nil, use a shifted prefi
325  (defcustom cua-enable-register-prefix 'not-ctrl-u  (defcustom cua-enable-register-prefix 'not-ctrl-u
326    "*If non-nil, registers are supported via numeric prefix arg.    "*If non-nil, registers are supported via numeric prefix arg.
327  If the value is t, any numeric prefix arg in the range 0 to 9 will be  If the value is t, any numeric prefix arg in the range 0 to 9 will be
328  interpreted as a register number.  interpreted as a register number.
329  If the value is not-ctrl-u, using C-u to enter a numeric prefix is not  If the value is not-ctrl-u, using C-u to enter a numeric prefix is not
330  interpreted as a register number.  interpreted as a register number.
331  If the value is ctrl-u-only, only numeric prefix entered with C-u is  If the value is ctrl-u-only, only numeric prefix entered with C-u is
332  interpreted as a register number."  interpreted as a register number."
333    :type '(choice (const :tag "Disabled" nil)    :type '(choice (const :tag "Disabled" nil)
334                   (const :tag "Enabled, but C-u arg is not a register" not-ctrl-u)                   (const :tag "Enabled, but C-u arg is not a register" not-ctrl-u)
335                   (const :tag "Enabled, but only for C-u arg" ctrl-u-only)                   (const :tag "Enabled, but only for C-u arg" ctrl-u-only)
336                   (other :tag "Enabled" t))                   (other :tag "Enabled" t))
# Line 404  Can be toggled by [M-p] while the rectan Line 404  Can be toggled by [M-p] while the rectan
404    :type 'boolean    :type 'boolean
405    :group 'cua)    :group 'cua)
406    
407  (defface cua-global-mark-face '((((class color))  (defface cua-global-mark-face '((((class color))
408                                    (:foreground "black")                                    (:foreground "black")
409                                    (:background "yellow"))                                    (:background "yellow"))
410                                   (t (:bold t)))                                   (t (:bold t)))
# Line 576  Will change cursor color to specified co Line 576  Will change cursor color to specified co
576             (not (numberp cua-prefix-override-inhibit-delay))             (not (numberp cua-prefix-override-inhibit-delay))
577             (<= cua-prefix-override-inhibit-delay 0)             (<= cua-prefix-override-inhibit-delay 0)
578             ;; In state [1], start [T] and change to state [2]             ;; In state [1], start [T] and change to state [2]
579             (run-with-timer cua-prefix-override-inhibit-delay nil             (run-with-timer cua-prefix-override-inhibit-delay nil
580                             'cua--prefix-override-timeout)))                             'cua--prefix-override-timeout)))
581      ;; Don't record this command      ;; Don't record this command
582      (setq this-command last-command)      (setq this-command last-command)
# Line 604  Repeating prefix key when region is acti Line 604  Repeating prefix key when region is acti
604        (cua-copy-rectangle arg)        (cua-copy-rectangle arg)
605      (cua-copy-region arg))      (cua-copy-region arg))
606    (let ((keys (this-single-command-keys)))    (let ((keys (this-single-command-keys)))
607      (setq unread-command-events      (setq unread-command-events
608            (cons (aref keys (1- (length keys))) unread-command-events))))            (cons (aref keys (1- (length keys))) unread-command-events))))
609    
610  (defun cua--prefix-cut-handler (arg)  (defun cua--prefix-cut-handler (arg)
# Line 614  Repeating prefix key when region is acti Line 614  Repeating prefix key when region is acti
614        (cua-cut-rectangle arg)        (cua-cut-rectangle arg)
615      (cua-cut-region arg))      (cua-cut-region arg))
616    (let ((keys (this-single-command-keys)))    (let ((keys (this-single-command-keys)))
617      (setq unread-command-events      (setq unread-command-events
618            (cons (aref keys (1- (length keys))) unread-command-events))))            (cons (aref keys (1- (length keys))) unread-command-events))))
619    
620  (defun cua--prefix-override-timeout ()  (defun cua--prefix-override-timeout ()
# Line 633  Repeating prefix key when region is acti Line 633  Repeating prefix key when region is acti
633    ;; Execute original command    ;; Execute original command
634    (setq this-command this-original-command)    (setq this-command this-original-command)
635    (call-interactively this-command))    (call-interactively this-command))
636      
637  (defun cua--keep-active ()  (defun cua--keep-active ()
638    (setq mark-active t    (setq mark-active t
639          deactivate-mark nil))          deactivate-mark nil))
# Line 650  Repeating prefix key when region is acti Line 650  Repeating prefix key when region is acti
650  (defvar cua--register nil)  (defvar cua--register nil)
651    
652  (defun cua--prefix-arg (arg)  (defun cua--prefix-arg (arg)
653    (setq cua--register      (setq cua--register
654          (and cua-enable-register-prefix          (and cua-enable-register-prefix
655               (integerp arg) (>= arg 0) (< arg 10)               (integerp arg) (>= arg 0) (< arg 10)
656               (let* ((prefix (aref (this-command-keys) 0))               (let* ((prefix (aref (this-command-keys) 0))
657                      (ctrl-u-prefix (and (integerp prefix)                      (ctrl-u-prefix (and (integerp prefix)
658                                          (= prefix ?\C-u))))                                          (= prefix ?\C-u))))
659                 (cond                 (cond
660                  ((eq cua-enable-register-prefix 'not-ctrl-u)                  ((eq cua-enable-register-prefix 'not-ctrl-u)
661                   (not ctrl-u-prefix))                   (not ctrl-u-prefix))
662                  ((eq cua-enable-register-prefix 'ctrl-u-only)                  ((eq cua-enable-register-prefix 'ctrl-u-only)
# Line 691  Save a copy in register 0 if `cua-delete Line 691  Save a copy in register 0 if `cua-delete
691      (if cua-delete-copy-to-register-0      (if cua-delete-copy-to-register-0
692          (set-register ?0 cua--last-deleted-region-text))          (set-register ?0 cua--last-deleted-region-text))
693      (delete-region start end)      (delete-region start end)
694      (setq cua--last-deleted-region-pos      (setq cua--last-deleted-region-pos
695            (cons (current-buffer)            (cons (current-buffer)
696                  (and (consp buffer-undo-list)                  (and (consp buffer-undo-list)
697                       (car buffer-undo-list))))                       (car buffer-undo-list))))
# Line 861  of text." Line 861  of text."
861  (defun cua-help-for-region (&optional help)  (defun cua-help-for-region (&optional help)
862    "Show region specific help in echo area."    "Show region specific help in echo area."
863    (interactive)    (interactive)
864    (message    (message
865     (concat (if help "C-?:help " "")     (concat (if help "C-?:help " "")
866             "C-z:undo C-x:cut C-c:copy C-v:paste S-ret:rect")))             "C-z:undo C-x:cut C-c:copy C-v:paste S-ret:rect")))
867    
# Line 959  Extra commands should be added to `cua-u Line 959  Extra commands should be added to `cua-u
959                (unless mark-active                (unless mark-active
960                  (push-mark-command nil nil)))                  (push-mark-command nil nil)))
961               (t               (t
962                ;; If we set mark-active to nil here, the region highlight will not be                ;; If we set mark-active to nil here, the region highlight will not be
963                ;; removed by the direct_output_ commands.                ;; removed by the direct_output_ commands.
964                (setq deactivate-mark t)))                (setq deactivate-mark t)))
965    
# Line 969  Extra commands should be added to `cua-u Line 969  Extra commands should be added to `cua-u
969                               (get this-command 'pending-delete)))                               (get this-command 'pending-delete)))
970                       (nc (cond                       (nc (cond
971                            ((not ds) nil)                            ((not ds) nil)
972                            ((eq ds 'yank)                            ((eq ds 'yank)
973                             'cua-paste)                             'cua-paste)
974                            ((eq ds 'kill)                            ((eq ds 'kill)
975                             (if cua--rectangle                             (if cua--rectangle
# Line 986  Extra commands should be added to `cua-u Line 986  Extra commands should be added to `cua-u
986                  (if nc                  (if nc
987                      (setq this-original-command this-command                      (setq this-original-command this-command
988                            this-command nc)))))                            this-command nc)))))
989              
990          ;; Detect extension of rectangles by mouse or other movement          ;; Detect extension of rectangles by mouse or other movement
991          (setq cua--buffer-and-point-before-command          (setq cua--buffer-and-point-before-command
992                (if cua--rectangle (cons (current-buffer) (point))))                (if cua--rectangle (cons (current-buffer) (point))))
993          )          )
994      (error nil)))      (error nil)))
# Line 1008  Extra commands should be added to `cua-u Line 1008  Extra commands should be added to `cua-u
1008    
1009          ;; Debugging          ;; Debugging
1010          (if cua--debug          (if cua--debug
1011              (cond              (cond
1012               (cua--rectangle (cua--rectangle-assert))               (cua--rectangle (cua--rectangle-assert))
1013               (mark-active (message "Mark=%d Point=%d Expl=%s"               (mark-active (message "Mark=%d Point=%d Expl=%s"
1014                                     (mark t) (point) cua--explicit-region-start))))                                     (mark t) (point) cua--explicit-region-start))))
# Line 1123  Extra commands should be added to `cua-u Line 1123  Extra commands should be added to `cua-u
1123    
1124    (define-key cua--prefix-override-keymap [(control x)] 'cua--prefix-override-handler)    (define-key cua--prefix-override-keymap [(control x)] 'cua--prefix-override-handler)
1125    (define-key cua--prefix-override-keymap [(control c)] 'cua--prefix-override-handler)    (define-key cua--prefix-override-keymap [(control c)] 'cua--prefix-override-handler)
1126      
1127    (define-key cua--prefix-repeat-keymap [(control x) (control x)] 'cua--prefix-repeat-handler)    (define-key cua--prefix-repeat-keymap [(control x) (control x)] 'cua--prefix-repeat-handler)
1128    (define-key cua--prefix-repeat-keymap [(control x) up]    'cua--prefix-cut-handler)    (define-key cua--prefix-repeat-keymap [(control x) up]    'cua--prefix-cut-handler)
1129    (define-key cua--prefix-repeat-keymap [(control x) down]  'cua--prefix-cut-handler)    (define-key cua--prefix-repeat-keymap [(control x) down]  'cua--prefix-cut-handler)
# Line 1135  Extra commands should be added to `cua-u Line 1135  Extra commands should be added to `cua-u
1135    (define-key cua--prefix-repeat-keymap [(control c) left]  'cua--prefix-copy-handler)    (define-key cua--prefix-repeat-keymap [(control c) left]  'cua--prefix-copy-handler)
1136    (define-key cua--prefix-repeat-keymap [(control c) right] 'cua--prefix-copy-handler)    (define-key cua--prefix-repeat-keymap [(control c) right] 'cua--prefix-copy-handler)
1137    
1138    ;; Enable shifted fallbacks for C-x and C-c when region is active    ;; Enable shifted fallbacks for C-x and C-c when region is active
1139    (define-key cua--region-keymap [(shift control x)] 'Control-X-prefix)    (define-key cua--region-keymap [(shift control x)] 'Control-X-prefix)
1140    (define-key cua--region-keymap [(shift control c)] 'mode-specific-command-prefix)    (define-key cua--region-keymap [(shift control c)] 'mode-specific-command-prefix)
1141    ;; replace current region    ;; replace current region

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.17

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26