]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix 'C-x C-c' with cua-prefix-override-inhibit-delay nil
authorSiyuan Chen <chansey97@gmail.com>
Mon, 27 May 2024 16:29:50 +0000 (00:29 +0800)
committerEshel Yaron <me@eshelyaron.com>
Wed, 12 Feb 2025 10:53:02 +0000 (11:53 +0100)
* lisp/emulation/cua-base.el (cua-cut-handler, cua-copy-handler): New
functions to fix cut and paste when 'cua-prefix-override-inhibit-delay'
is nil.  (Bug#71230)

Copyright-paperwork-exempt: yes
(cherry picked from commit 1fdfcad924a9dfaf5858624bb86cc34bd050a0de)

lisp/emulation/cua-base.el

index 194bdc6a7c4576c3aaa9169da048c9ded3f74009..1c21a295e127ddfff4d2f45f77700f81c170eda8 100644 (file)
@@ -699,10 +699,25 @@ Repeating prefix key when region is active works as a single prefix key."
   (interactive)
   (cua--prefix-override-replay 0))
 
-;; These aliases are so that we can look up the commands and find the
-;; correct keys when generating menus.
-(defalias 'cua-cut-handler #'cua--prefix-override-handler)
-(defalias 'cua-copy-handler #'cua--prefix-override-handler)
+;; These two functions are so that we can look up the commands and find the
+;; 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)
+  (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)))
+    (cua--prefix-override-handler)))
+
+(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)))
 
 (defun cua--prefix-repeat-handler ()
   "Repeating prefix key when region is active works as a single prefix key."