From: Siyuan Chen Date: Mon, 27 May 2024 16:29:50 +0000 (+0800) Subject: Fix 'C-x C-c' with cua-prefix-override-inhibit-delay nil X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=bc9181d390e51421f8354fdfaa812be797908547;p=emacs.git Fix 'C-x C-c' with cua-prefix-override-inhibit-delay nil * 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) --- diff --git a/lisp/emulation/cua-base.el b/lisp/emulation/cua-base.el index 194bdc6a7c4..1c21a295e12 100644 --- a/lisp/emulation/cua-base.el +++ b/lisp/emulation/cua-base.el @@ -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."