emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r115461: * lisp/emulation/cua-base.el (cua-paste): A


From: Stefan Monnier
Subject: [Emacs-diffs] trunk r115461: * lisp/emulation/cua-base.el (cua-paste): Add `delete-selection' property
Date: Wed, 11 Dec 2013 14:49:05 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 115461
revision-id: address@hidden
parent: address@hidden
fixes bug: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16098
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Wed 2013-12-11 09:49:01 -0500
message:
  * lisp/emulation/cua-base.el (cua-paste): Add `delete-selection' property
  instead of deleting the selection "by hand".
  Rely on insert-for-yank to yank rectangles.
  (cua-highlight-region-shift-only): Mark obsolete.
  (cua-mode): Don't enable/disable transient-mark-mode,
  shift-select-mode (cua-mode works both with and without them), and
  pc-selection-mode (obsolete).
  * lisp/emulation/cua-rect.el (cua--activate-rectangle): Activate the mark.
  (cua--deactivate-rectangle): Deactivate it.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/emulation/cua-base.el     cuabase.el-20091113204419-o5vbwnq5f7feedwu-2415
  lisp/emulation/cua-rect.el     cuarect.el-20091113204419-o5vbwnq5f7feedwu-2417
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-12-11 14:42:34 +0000
+++ b/lisp/ChangeLog    2013-12-11 14:49:01 +0000
@@ -1,5 +1,15 @@
 2013-12-11  Stefan Monnier  <address@hidden>
 
+       * emulation/cua-base.el (cua-paste): Add `delete-selection' property
+       instead of deleting the selection "by hand" (bug#16098).
+       Rely on insert-for-yank to yank rectangles.
+       (cua-highlight-region-shift-only): Mark obsolete.
+       (cua-mode): Don't enable/disable transient-mark-mode,
+       shift-select-mode (cua-mode works both with and without them), and
+       pc-selection-mode (obsolete).
+       * emulation/cua-rect.el (cua--activate-rectangle): Activate the mark.
+       (cua--deactivate-rectangle): Deactivate it.
+
        * delsel.el (delete-selection-mode): Don't enable transient-mark-mode.
        (delete-selection-helper): Make sure yank starts at the top of the
        deleted region.

=== modified file 'lisp/emulation/cua-base.el'
--- a/lisp/emulation/cua-base.el        2013-12-08 08:11:50 +0000
+++ b/lisp/emulation/cua-base.el        2013-12-11 14:49:01 +0000
@@ -294,6 +294,8 @@
 is not turned on."
   :type 'boolean
   :group 'cua)
+(make-obsolete-variable 'cua-highlight-region-shift-only
+                        'transient-mark-mode "24.4")
 
 (defcustom cua-prefix-override-inhibit-delay 0.2
   "If non-nil, time in seconds to delay before overriding prefix key.
@@ -858,6 +860,7 @@
 
 (declare-function x-clipboard-yank "../term/x-win" ())
 
+(put 'cua-paste 'delete-selection 'yank)
 (defun cua-paste (arg)
   "Paste last cut or copied region or rectangle.
 An active region is deleted before executing the command.
@@ -866,8 +869,7 @@
   (interactive "P")
   (setq arg (cua--prefix-arg arg))
   (let ((regtxt (and cua--register (get-register cua--register)))
-       (count (prefix-numeric-value arg))
-       paste-column paste-lines)
+       (count (prefix-numeric-value arg)))
     (cond
      ((and cua--register (not regtxt))
       (message "Nothing in register %c" cua--register))
@@ -875,30 +877,12 @@
       (if regtxt
          (cua--insert-at-global-mark regtxt)
        (when (not (eobp))
-         (cua--insert-at-global-mark (filter-buffer-substring (point) (+ 
(point) count)))
+         (cua--insert-at-global-mark
+           (filter-buffer-substring (point) (+ (point) count)))
          (forward-char count))))
      (buffer-read-only
       (error "Cannot paste into a read-only buffer"))
      (t
-      ;; Must save register here, since delete may override reg 0.
-      (if mark-active
-         (if cua--rectangle
-             (progn
-               (goto-char (min (mark) (point)))
-               (setq paste-column (cua--rectangle-left))
-               (setq paste-lines (cua--delete-rectangle))
-               (if (= paste-lines 1)
-                   (setq paste-lines nil))) ;; paste all
-           ;; Before a yank command, make sure we don't yank the
-           ;; head of the kill-ring that really comes from the
-           ;; currently active region we are going to delete.
-           ;; That would make yank a no-op.
-           (if (and (string= (filter-buffer-substring (point) (mark))
-                             (car kill-ring))
-                    (fboundp 'mouse-region-match)
-                    (mouse-region-match))
-               (current-kill 1))
-           (cua-delete-region)))
       (cond
        (regtxt
        (cond
@@ -906,16 +890,6 @@
         ((consp regtxt) (cua--insert-rectangle regtxt))
         ((stringp regtxt) (insert-for-yank regtxt))
         (t (message "Unknown data in register %c" cua--register))))
-       ((and cua--last-killed-rectangle
-            (eq (and kill-ring (car kill-ring)) (car 
cua--last-killed-rectangle)))
-       (let ((pt (point)))
-         (when (not (eq buffer-undo-list t))
-           (setq this-command 'cua--paste-rectangle)
-           (undo-boundary)
-           (setq buffer-undo-list (cons pt buffer-undo-list)))
-         (cua--insert-rectangle (cdr cua--last-killed-rectangle)
-                                nil paste-column paste-lines)
-         (if arg (goto-char pt))))
        ((eq this-original-command 'clipboard-yank)
        (clipboard-yank))
        ((eq this-original-command 'x-clipboard-yank)
@@ -1426,9 +1400,7 @@
 
 ;; State prior to enabling cua-mode
 ;; Value is a list with the following elements:
-;;   transient-mark-mode
 ;;   delete-selection-mode
-;;   pc-selection-mode
 
 (defvar cua--saved-state nil)
 
@@ -1488,7 +1460,8 @@
     (remove-hook 'post-command-hook 'cua--post-command-handler))
 
   (if (not cua-mode)
-      (setq emulation-mode-map-alists (delq 'cua--keymap-alist 
emulation-mode-map-alists))
+      (setq emulation-mode-map-alists
+            (delq 'cua--keymap-alist emulation-mode-map-alists))
     (add-to-ordered-list 'emulation-mode-map-alists 'cua--keymap-alist 400)
     (cua--select-keymaps))
 
@@ -1496,34 +1469,21 @@
    (cua-mode
     (setq cua--saved-state
          (list
-          transient-mark-mode
-          (and (boundp 'delete-selection-mode) delete-selection-mode)
-          (and (boundp 'pc-selection-mode) pc-selection-mode)
-          shift-select-mode))
+          (and (boundp 'delete-selection-mode) delete-selection-mode)))
     (if cua-delete-selection
         (delete-selection-mode 1)
       (if (and (boundp 'delete-selection-mode) delete-selection-mode)
           (delete-selection-mode -1)))
-    (if (and (boundp 'pc-selection-mode) pc-selection-mode)
-       (pc-selection-mode -1))
-    (cua--deactivate)
-    (setq shift-select-mode t)
-    (transient-mark-mode (if cua-highlight-region-shift-only -1 1)))
+    (if cua-highlight-region-shift-only (transient-mark-mode -1))
+    (cua--deactivate))
    (cua--saved-state
-    (setq transient-mark-mode (car cua--saved-state))
-    (if (nth 1 cua--saved-state)
+    (if (nth 0 cua--saved-state)
        (delete-selection-mode 1)
       (if (and (boundp 'delete-selection-mode) delete-selection-mode)
           (delete-selection-mode -1)))
-    (if (nth 2 cua--saved-state)
-       (pc-selection-mode 1))
-    (setq shift-select-mode (nth 3 cua--saved-state))
     (if (called-interactively-p 'interactive)
-       (message "CUA mode disabled.%s%s%s%s"
-                (if (nth 1 cua--saved-state) " Delete-Selection" "")
-                (if (and (nth 1 cua--saved-state) (nth 2 cua--saved-state)) " 
and" "")
-                (if (nth 2 cua--saved-state) " PC-Selection" "")
-                (if (or (nth 1 cua--saved-state) (nth 2 cua--saved-state)) " 
enabled" "")))
+       (message "CUA mode disabled.%s"
+                (if (nth 0 cua--saved-state) " Delete-Selection enabled" "")))
     (setq cua--saved-state nil))))
 
 

=== modified file 'lisp/emulation/cua-rect.el'
--- a/lisp/emulation/cua-rect.el        2013-12-08 08:11:50 +0000
+++ b/lisp/emulation/cua-rect.el        2013-12-11 14:49:01 +0000
@@ -718,7 +718,8 @@
             (cdr (cdr cua--last-rectangle))
           (cua--rectangle-get-corners))
         cua--status-string (if (cua--rectangle-virtual-edges) " [R]" "")
-        cua--last-rectangle nil))
+        cua--last-rectangle nil)
+  (activate-mark))
 
 ;; (defvar cua-save-point nil)
 
@@ -731,7 +732,8 @@
         cua--rectangle nil
         cua--rectangle-overlays nil
         cua--status-string nil
-        cua--mouse-last-pos nil))
+        cua--mouse-last-pos nil)
+  (deactivate-mark))
 
 (defun cua--highlight-rectangle ()
   ;; This function is used to highlight the rectangular region.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]