]> git.eshelyaron.com Git - emacs.git/commitdiff
; Fix up last commit
authorStefan Kangas <stefankangas@gmail.com>
Wed, 12 Feb 2025 08:17:37 +0000 (09:17 +0100)
committerEshel Yaron <me@eshelyaron.com>
Wed, 12 Feb 2025 10:53:05 +0000 (11:53 +0100)
* lisp/emulation/cua-base.el (cua--copy-or-cut-handler): Extract
function from...
(cua-cut-handler, cua-copy-handler): ...here.
(cua-cut-to-global-mark, cua-copy-to-global-mark): Declare.

(cherry picked from commit 2254f7159813c345021896605be177e43c7ccb6d)

lisp/emulation/cua-base.el

index 1c21a295e127ddfff4d2f45f77700f81c170eda8..c3b09b1f62c8f81524ab4b7a2b45cefb9b24d4a1 100644 (file)
@@ -703,21 +703,25 @@ Repeating prefix key when region is active works as a single prefix key."
 ;; correct keys when generating menus.  Also, when cua--prefix-override-handler
 ;; is nil, allow C-x C-c to cut/copy immediately without waiting for
 ;; cua--prefix-override-timer to expire.
-(defun cua-cut-handler ()
-  (interactive)
+(declare-function cua-cut-to-global-mark "cua-gmrk")
+(declare-function cua-copy-to-global-mark "cua-gmrk")
+(defun cua--copy-or-cut-handler (&optional cut)
   (if (or (not (numberp cua-prefix-override-inhibit-delay))
           (<= cua-prefix-override-inhibit-delay 0))
-      (cond (cua--global-mark-active (cua-cut-to-global-mark))
-            (t (call-interactively 'kill-region)))
+      (cond ((and (bound-and-true-p cua--global-mark-active))
+             (funcall (if cut #'cua-cut-to-global-mark
+                        #'cua-copy-to-global-mark)))
+            (t (call-interactively (if cut #'kill-region
+                                     #'copy-region-as-kill))))
     (cua--prefix-override-handler)))
 
+(defun cua-cut-handler ()
+  (interactive)
+  (cua--copy-or-cut-handler t))
+
 (defun cua-copy-handler ()
   (interactive)
-  (if (or (not (numberp cua-prefix-override-inhibit-delay))
-          (<= cua-prefix-override-inhibit-delay 0))
-      (cond (cua--global-mark-active (cua-copy-to-global-mark))
-            (t (call-interactively 'copy-region-as-kill)))
-    (cua--prefix-override-handler)))
+  (cua--copy-or-cut-handler))
 
 (defun cua--prefix-repeat-handler ()
   "Repeating prefix key when region is active works as a single prefix key."