From 006de6c527c02566185ca4f0e5f5e41175882d68 Mon Sep 17 00:00:00 2001 From: Siyuan Chen 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