>From 7bfb6883fb39fe44282a547a4562f9f4d60058ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Le=20Gouguec?= Date: Sun, 15 Jan 2023 19:23:17 +0100 Subject: [PATCH] Avoid spurious pause in kill-ring-save 'indicate-copied-region' checks whether the region is highlighted and if not, briefly moves point to mark to give a visual cue of the extent of text that was saved to the kill ring. The region is assumed to be "highlighted" if (a) it is active and (b) its face specifies a :background. That latter condition does not account for this somewhat adversarial face definition: (custom-set-faces '(region ((t (:foreground "blue" :inverse-video t))))) With this customization, the check will fail and users will experience an (interruptible) pause, despite the region being clearly highlighted. * lisp/simple.el (region-highlighted-p): New function to detect "if the region is highlighted". If :background is nil, double-check :foreground and :inverse-video. (indicate-copied-region): Use it. --- lisp/simple.el | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lisp/simple.el b/lisp/simple.el index 4b09f41de5..2029584a94 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -5853,6 +5853,15 @@ copy-region-blink-delay :group 'killing :version "28.1") +(defun region-highlighted-p () + "Say whether the region is visibly highlighted. +This takes into account whether the region is active, and whether +the `region' face has a colored background." + (and (region-active-p) + (or (face-background 'region nil t) + (and (face-foreground 'region nil t) + (face-inverse-video-p 'region nil t))))) + (defun indicate-copied-region (&optional message-len) "Indicate that the region text has been copied interactively. If the mark is visible in the selected window, blink the cursor between @@ -5873,8 +5882,7 @@ indicate-copied-region ;; was selected. Don't do it if the region is highlighted. (when (and (numberp copy-region-blink-delay) (> copy-region-blink-delay 0) - (or (not (region-active-p)) - (not (face-background 'region nil t)))) + (not (region-highlighted-p))) ;; Swap point and mark. (set-marker (mark-marker) (point) (current-buffer)) (goto-char mark) -- 2.39.0