Subject: bug#71230: closed (Re: bug#71230: [PATCH] Fix C-x C-c do not work in CUA-mode when cua-prefix-override-handler is ni)

From: [email-masked] (GNU bug Tracking System)
Date: Wed, 12 Feb 2025 08:28:03 +0000

Your bug report

#71230: [PATCH] Fix C-x C-c do not work in CUA-mode when cua-prefix-override-handler is ni

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
71230: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=71230
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#71230: [PATCH] Fix C-x C-c do not work in CUA-mode when cua-prefix-override-handler is ni
From: Stefan Kangas <[email-masked]>
To: Siyuan Chen <[email-masked]>
Cc: [email-masked]
Date: Wed, 12 Feb 2025 00:26:57 -0800
List-Id: <debbugs-submit.debbugs.gnu.org>

Version: 31.1

Siyuan Chen <[email-masked]> writes:

> Currently, cua-mode has a bug i.e. when `(setq
> cua-prefix-override-inhibit-delay nil)`, cut and copy do not work.
>
> Also we have to`(setq cua-prefix-override-inhibit-delay nil)`,
> otherwise cua-mode will not be able to support fast copy/cut & paste.
>
> More detail information, see emacs-devel
> https://lists.gnu.org/archive/html/emacs-devel/2024-05/msg01033.html

Yeah, this looks like a bug.  Your patch LGTM, so I installed it on
master as commit 1fdfcad924a.  I also installed a followup commit
2254f715981 to avoid byte-compiler warnings, and reduce code
duplication.

Thanks!

> P.s. This patch based on the mirror repo https://github.com/emacs-mirror/emacs
> and Tested in Emacs 29.3.

Note that this is just a mirror maintained by some unknown third party.
The correct URL can be found here:

    https://savannah.gnu.org/p/emacs

Subject: [PATCH] Fix C-x C-c do not work in CUA-mode when cua-prefix-override-handler is ni
From: Siyuan Chen <[email-masked]>
To: [email-masked]
Date: Tue, 28 May 2024 01:00:40 +0800
List-Id: <debbugs-submit.debbugs.gnu.org>

Currently, cua-mode has a bug i.e. when `(setq
cua-prefix-override-inhibit-delay nil)`, cut and copy do not work.

Also we have to`(setq cua-prefix-override-inhibit-delay nil)`,
otherwise cua-mode will not be able to support fast copy/cut & paste.

More detail information, see emacs-devel
https://lists.gnu.org/archive/html/emacs-devel/2024-05/msg01033.html

P.s. This patch based on the mirror repo
https://github.com/emacs-mirror/emacs
and Tested in Emacs 29.3.

Best regards,
Siyuan Chen
From 006de6c527c02566185ca4f0e5f5e41175882d68 Mon Sep 17 00:00:00 2001
From: Siyuan Chen <[email-masked]>
Date: Tue, 28 May 2024 00:29:50 +0800
Subject: [PATCH] Fix the issue when cua--prefix-override-handler is nil C-x
 C-c doesn't work.

Detail see https://lists.gnu.org/archive/html/emacs-devel/2024-05/msg01033.html
---
 lisp/emulation/cua-base.el | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/lisp/emulation/cua-base.el b/lisp/emulation/cua-base.el
index fb6a8515d9e..cacd348c315 100644
--- a/lisp/emulation/cua-base.el
+++ b/lisp/emulation/cua-base.el
@@ -699,10 +699,27 @@ 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."
-- 
2.32.0.windows.2