From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?K=C3=A9vin?= Le Gouguec Newsgroups: gmane.emacs.bugs Subject: bug#60841: 30.0.50; kill-ring-save pauses despite region being highlighted Date: Mon, 30 Jan 2023 23:38:24 +0100 Message-ID: <87fsbrfy1r.fsf@gmail.com> References: <87h6wrs71h.fsf@gmail.com> <83zgai4peg.fsf@gnu.org> <5583fd58387746ce7ddc@heytings.org> <87cz7dbns0.fsf@gmail.com> <4c2c6cf44ad37e405b06@heytings.org> <878ri0g6ob.fsf@gmail.com> <83pmbc0yxo.fsf@gnu.org> <87y1pzo5dp.fsf@gmail.com> <834jskmhs8.fsf@gnu.org> <87fsc2qjcs.fsf@gmail.com> <833581jtff.fsf@gnu.org> <87lelsga1f.fsf@gmail.com> <83r0vkgj7l.fsf@gnu.org> <87h6wawo2k.fsf@gmail.com> <831qnea5ye.fsf@gnu.org> <87357t2xyh.fsf@gmail.com> <83k01573hz.fsf@gnu.org> <87v8kpj6ea.fsf@gmail.com> <83mt605h4f.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6744"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: gregory@heytings.org, 60841@debbugs.gnu.org, juri@linkov.net To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jan 30 23:39:27 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pMcoB-0001c4-35 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 30 Jan 2023 23:39:27 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMcno-0007MZ-KN; Mon, 30 Jan 2023 17:39:04 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMcnm-0007Dt-F2 for bug-gnu-emacs@gnu.org; Mon, 30 Jan 2023 17:39:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pMcnm-000789-45 for bug-gnu-emacs@gnu.org; Mon, 30 Jan 2023 17:39:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pMcnl-0000zF-WA for bug-gnu-emacs@gnu.org; Mon, 30 Jan 2023 17:39:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?K=C3=A9vin?= Le Gouguec Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 30 Jan 2023 22:39:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60841 X-GNU-PR-Package: emacs Original-Received: via spool by 60841-submit@debbugs.gnu.org id=B60841.16751183143758 (code B ref 60841); Mon, 30 Jan 2023 22:39:01 +0000 Original-Received: (at 60841) by debbugs.gnu.org; 30 Jan 2023 22:38:34 +0000 Original-Received: from localhost ([127.0.0.1]:50825 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pMcnJ-0000yX-GY for submit@debbugs.gnu.org; Mon, 30 Jan 2023 17:38:34 -0500 Original-Received: from mail-wm1-f54.google.com ([209.85.128.54]:40896) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pMcnI-0000yH-9o for 60841@debbugs.gnu.org; Mon, 30 Jan 2023 17:38:32 -0500 Original-Received: by mail-wm1-f54.google.com with SMTP id j32-20020a05600c1c2000b003dc4fd6e61dso4315505wms.5 for <60841@debbugs.gnu.org>; Mon, 30 Jan 2023 14:38:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=+KENGRCnG9psf88qOMlHKdVEc17gw4dUna2uL6qfAHg=; b=FnwXp6w8ekg2X+oFGKon//Loy98wb8RAO0T/OHMEdpynmj4csEF51xMJaEtGv926Sn ArU740MB1Y5XcYFbkbfhFkDeupDDOlXhY+ntu0RKq0fw7jhRQQmnPcsakPpRgJ0A6Dlo 4lvS4CCZEUrhj4sBT4GZbGoYdOmJ3lE+Tf6hkBgERsjjCpFTqCEGeVaZttMYQx+c9HS/ UoQ/ANX2e0AbZ0vwrCj/Y7LB70ODHEmvgb60x532lgfbvaBhemyfklKkb6u6vECQdcPp zO1j2XiBPHA2PcgG27M3kb3NlcEXD4+Psio3KKGFZ7ecDP+RNWOlMO29VJyzFWvD52Wt O5DQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=+KENGRCnG9psf88qOMlHKdVEc17gw4dUna2uL6qfAHg=; b=DAs5XQy+8tNq0zFpLEi6OXRFueTlSebPIgkB/fddOzlwLD5KS89sXb1Vfw/o6qWJOC 9uzvZlclCbWd9hnvp0zJMVP94xQynvxmCS3oKQgYOvHnj36mkVKFkMsJWPM67CrYewM5 ZMGZpHZDUMcSoPqYK7AHxfPnYfopVsnOZLvyT7f1ua+d2YYrN0mtHOANaWbRf/yaizRn itRSmBO+j26Hj6R6QJesRU4/3p/1zdx4og8CFpCtoOuvgY+6Yg4/faED+qYje6fmzc7z pr4z0rGQPvCGG39wRFgkyPKfftUKgdIHUwcX62pedegrHaUmLeujnNcRDUBFsT3lz1Kk kIQQ== X-Gm-Message-State: AO0yUKXKzLZd5Uxt1srcq3poZ7GKWoQySJsL5hmoFlJ++Qh3ieTTCH6l k6TZkl3MRBQ5g5YMmZ5Awo0= X-Google-Smtp-Source: AK7set+6rYzQTiO7O8vUp2B9h4gwsZ8VxwZwIAjEV0eTS5/mhw8QVrBs9QI90jCBOdTx0wPf1jChSw== X-Received: by 2002:a05:600c:358d:b0:3da:282b:e774 with SMTP id p13-20020a05600c358d00b003da282be774mr1045464wmq.38.1675118306175; Mon, 30 Jan 2023 14:38:26 -0800 (PST) Original-Received: from amdahl30 ([2a01:e0a:253:fe0:2ef0:5dff:fed2:7b49]) by smtp.gmail.com with ESMTPSA id y21-20020a05600c17d500b003dc46242c4csm8826881wmo.10.2023.01.30.14.38.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 14:38:25 -0800 (PST) In-Reply-To: <83mt605h4f.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 30 Jan 2023 14:41:52 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:254489 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: > Please add the xfaces.c change, and then this can go in (to the > emacs-29 branch). Done; see attached. * lightly amended the commit message (added a third paragraph); * tried to find an appropriate spot in NEWS; * de-bumped the defcustom :version; * ran a couple of sanity checks in *scratch* after applying this on top of 2023-01-30 "Update to Transient v0.3.7-196-gb91f509" (1684e254a3b). (face-differs-from-default-p 'default) nil (face-differs-from-default-p 'region) :background (set-face-attribute 'region nil :background 'unspecified) nil (face-differs-from-default-p 'region) nil ;; Tested all 3 function-item values of copy-region-blink-predicate. (set-face-attribute 'region nil :inverse-video t) nil (face-differs-from-default-p 'region) :inverse-video ;; Tested all 3 function-item values of copy-region-blink-predicate. Let me know if anything is amiss. --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-Avoid-spurious-pause-in-kill-ring-save-Bug-60841.patch Content-Transfer-Encoding: quoted-printable >From fa7426224d5c5dbccd22d19720acbbd620dc8723 Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?K=3DC3=3DA9vin=3D20Le=3D20Gouguec?=3D Date: Sun, 29 Jan 2023 11:23:01 +0100 Subject: [PATCH] Avoid spurious pause in kill-ring-save (Bug#60841) '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 considered "highlighted" if (a) it is active and (b) its face specifies a :background. That latter condition does not account for the multiple ways in which the face can make the region "visually distinct" from the default face, so switch to the more extensive predicate face-differs-from-default-p. The patch also fixes a couple of issues with the predicate's implementation, and introduces a new user option in case anyone happened to enjoy unconditional blinking. * lisp/faces.el (face-differs-from-default-p): Filter out :extend; add rationale for the attributes we ignore. * lisp/simple.el (copy-region-blink-predicate): Add option to let users explicitly opt into or out of blinking point and mark. (region-indistinguishable-p): New function to detect "if there is currently no active region highlighting", leveraging face-differs-from-default-p. (indicate-copied-region): Use it. * src/xfaces.c (merge_face_ref): Allow :stipple to be nil, since it is a documented valid value for that attribute. * etc/NEWS: Announce user option. --- etc/NEWS | 12 ++++++++++++ lisp/faces.el | 11 ++++++++++- lisp/simple.el | 22 ++++++++++++++++++++-- src/xfaces.c | 3 +-- 4 files changed, 43 insertions(+), 5 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index fb211f9b7d0..13472de9e6e 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1339,6 +1339,18 @@ dragged. Customize this option to limit the number of entries in the menu "Edit =E2=86=92 Paste from Kill Menu". The default is 60. =20 +--- +** New user option 'copy-region-blink-predicate'. +By default, when copying a region with 'kill-ring-save', Emacs only +blinks point and mark when the region is not denoted visually, that +is, when either the region is inactive, or the 'region' face is +indistinguishable from the 'default' face. + +Users who would rather enable blinking unconditionally can now set +this user option to 'always'. To disable blinking unconditionally, +either set this option to 'ignore', or set 'copy-region-blink-delay' +to 0. + +++ ** Performing a pinch gesture on a touchpad now increases the text scale. =20 diff --git a/lisp/faces.el b/lisp/faces.el index 3323eab205a..4933b495a6c 100644 --- a/lisp/faces.el +++ b/lisp/faces.el @@ -304,7 +304,16 @@ face-differs-from-default-p If FRAME is t, report on the defaults for face FACE (for new frames). If FRAME is omitted or nil, use the selected frame." (let ((attrs - (delq :inherit (mapcar 'car face-attribute-name-alist))) + ;; The _value_ of :inherit teaches us nothing about how FACE + ;; looks compared to the default face. Instead, we will ask + ;; `face-attribute' to take inheritance into account when + ;; examining other attributes. + (delq :inherit + ;; A difference in extension past EOL only matters when + ;; relevant attributes (such as :background) also + ;; differ from the default; otherwise this difference + ;; is a false positive. + (delq :extend (mapcar 'car face-attribute-name-alist)))) (differs nil)) (while (and attrs (not differs)) (let* ((attr (pop attrs)) diff --git a/lisp/simple.el b/lisp/simple.el index 861fe193fb8..c58acfe3adc 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -5852,6 +5852,25 @@ copy-region-blink-delay :group 'killing :version "28.1") =20 +(defcustom copy-region-blink-predicate #'region-indistinguishable-p + "Whether the cursor must be blinked after a copy. +When this condition holds, and the copied region fits in the +current window, `kill-ring-save' will blink the cursor between +point and mark for `copy-region-blink-delay' seconds." + :type '(radio (function-item region-indistinguishable-p) + (function-item :doc "Always blink point and mark." always) + (function-item :doc "Never blink point and mark." ignore) + (function :tag "Other predicate function")) + :group 'killing + :version "29.1") + +(defun region-indistinguishable-p () + "Whether the current region is not denoted visually. +This holds when the region is inactive, or when the `region' face +cannot be distinguished from the `default' face." + (not (and (region-active-p) + (face-differs-from-default-p 'region)))) + (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 @@ -5872,8 +5891,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)))) + (funcall copy-region-blink-predicate)) ;; Swap point and mark. (set-marker (mark-marker) (point) (current-buffer)) (goto-char mark) diff --git a/src/xfaces.c b/src/xfaces.c index 35b79154805..62d7823f308 100644 --- a/src/xfaces.c +++ b/src/xfaces.c @@ -2780,8 +2780,7 @@ merge_face_ref (struct window *w, else if (EQ (keyword, QCstipple)) { #if defined (HAVE_WINDOW_SYSTEM) - Lisp_Object pixmap_p =3D Fbitmap_spec_p (value); - if (!NILP (pixmap_p)) + if (NILP (value) || !NILP (Fbitmap_spec_p (value))) to[LFACE_STIPPLE_INDEX] =3D value; else err =3D true; --=20 2.39.0 --=-=-=--