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: Sat, 28 Jan 2023 18:45:07 +0100 Message-ID: <87h6wawo2k.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> 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="17223"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: gregory@heytings.org, 60841@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jan 28 18:46:20 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 1pLpHQ-0004Ke-LO for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 28 Jan 2023 18:46:20 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pLpHA-0001tZ-Ex; Sat, 28 Jan 2023 12:46: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 1pLpH8-0001sp-W7 for bug-gnu-emacs@gnu.org; Sat, 28 Jan 2023 12:46:03 -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 1pLpH8-0002kz-Iz for bug-gnu-emacs@gnu.org; Sat, 28 Jan 2023 12:46:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pLpH8-000683-AG for bug-gnu-emacs@gnu.org; Sat, 28 Jan 2023 12:46: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: Sat, 28 Jan 2023 17:46:02 +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.167492791923483 (code B ref 60841); Sat, 28 Jan 2023 17:46:02 +0000 Original-Received: (at 60841) by debbugs.gnu.org; 28 Jan 2023 17:45:19 +0000 Original-Received: from localhost ([127.0.0.1]:41458 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pLpGQ-00066e-N8 for submit@debbugs.gnu.org; Sat, 28 Jan 2023 12:45:19 -0500 Original-Received: from mail-wr1-f49.google.com ([209.85.221.49]:43878) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pLpGN-00066J-J2 for 60841@debbugs.gnu.org; Sat, 28 Jan 2023 12:45:16 -0500 Original-Received: by mail-wr1-f49.google.com with SMTP id h12so7631220wrv.10 for <60841@debbugs.gnu.org>; Sat, 28 Jan 2023 09:45:15 -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=nVcacDduJHITDbTJ6dV+hdQn/wTWgaRXThLOM7Yeb+8=; b=W3yIfYnVBTBWo0S09D3TGsIDQnVlmvDSSKSRZPX3Q0+WiwtRoQxOZPIYujML0DTuNz KAlsvCEPSLELJCbdMk6SFih1/06G8Ib335iJ6ZvUlrsuyGBl/XhbxVQKNRnjI95MYU2E KAkQxOztTHFsGdLG0pJuVFJmOxEq2jP9Dy56JC1tAyRrKNq1D0nySOzwTI0ERS1z2J4M 4Ntl5dqb326YF3uyY6ZVT8lLR/sc+wa7g9nZW/kITXS2sxleYZ098YnSfjquduMEAuTV RvwMRcq3TzR0BZPrNO50/+4Bkn1jq1yZbCuFV9artgfqqAC2B9JsAkiAzGkqMFBi5iDI wNuQ== 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=nVcacDduJHITDbTJ6dV+hdQn/wTWgaRXThLOM7Yeb+8=; b=CPvqfphKcEYxmmtzY2m01L6mpxYiv3bbnMjYvyIOtzA95whm5eTQTBgU25xXMhEXre uBfIQRQVDxVICAOYgI+ZcHd9eiL8Tg9c1oVTH0UgzZ2f6oaBZl5jAjeVfdksh79SyMKi 6mHOpG54D2TwGKQest6gNHa5YLXwYNrObzM87Ildc5EiNKTfMs6uegzId7Eq4nWVAAhA +aJZtspcaATR5I21w0g5G2iAyzkXUoV66w0qpEP36vkMuNQcYBNFZm3hTMCJKQWl3mB3 k4nzB3hcdNmOj2unCMJLem60n7mnFoL/RFz4CCTud00LLWZH1/gVV2kg3gJTUMTxJ2Qi 3J8Q== X-Gm-Message-State: AO0yUKWuSRB+ZWY3trnjWYFC+3ZeD3+NpM6+aqiSTkQm1YAp7oHuqcEP v+xdOv92aRevl1WOJNd/h48+EAcjcpM= X-Google-Smtp-Source: AK7set/pjcIclwwyF5MQ2OYkKr3iwqgBHKG+PhPpzLAz8gNJIfvvzV0O8k/WXhyxPwSLCQMi0F648Q== X-Received: by 2002:a5d:534c:0:b0:2bf:cfc0:ac71 with SMTP id t12-20020a5d534c000000b002bfcfc0ac71mr7399511wrv.53.1674927909276; Sat, 28 Jan 2023 09:45:09 -0800 (PST) Original-Received: from amdahl30 ([2a01:e0a:253:fe0:2ef0:5dff:fed2:7b49]) by smtp.gmail.com with ESMTPSA id v14-20020adfe4ce000000b002bfafadb22asm7466150wrm.87.2023.01.28.09.45.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Jan 2023 09:45:08 -0800 (PST) In-Reply-To: <83r0vkgj7l.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 24 Jan 2023 15:23:10 +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:254309 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Revised patch attached; intended as "good for master". Answers to open discussion points: > Can you see if any of these changes cause any trouble in our own use > of face-differs-from-default-p? AFAICT, it will actually fix a subtle > problem in diff-mode.el: if diff-changed face doesn't define > non-default colors, it will be still taken as different from > 'default', which I think is contrary to what diff-mode expects. diff-mode.el (re. smerge-mode.el) can indeed be fooled into thinking diff-changed (re. smerge-refined-changed) differs-from-default, if one "shoots their own foot", for example, setting=E2=80=A6 * :extend t: fixed by this patch =E2=9C=94=EF=B8= =8F * :stipple nil: foot blown with or without the patch =F0=9F=A4=B7 * :inherit 'default: foot blown with or without the patch =F0=9F=A4=B7 Problem with :stipple nil and :inherit 'default explained in [1]. indicate-copied-region will become affected if the current patch goes in. replace.el:occur-1 befuddled me for a moment[2], but the tl;dr is that it will be none the worse for wear. > > >> (Hm, and against my better judgement I went ahead and compared > > >> gui_supports_face_attributes_p vs tty_supports_face_attributes_p, an= d I > > >> see that they handle :extend differently and *mashes C-c C-c with > > >> forehead before fingers can type another wall of text*) > > > > > > TTY frames always extend the color, that's the reason for the > > > difference. > >=20 > > (Not sure I get your meaning here; on the Linux TTY I have on hand, > > (set-face-extend 'region nil) does disable color extension) >=20 > I'm sorry, you will have to look up the discussion that led to the > development of the :extend attribute; I cannot afford searching for > it. The differences between TTY and GUI frames were one of the main > reasons why we introduced this attribute. Playing around with more terminals did not yield more insights[3], so it seems I'll need to dig into the archives, indeed. Currently squinting at emacs-devel:<83r2fbg5bq.fsf@gnu.org>, which singles out NS versus X, Windows & TTYs; could this be what you had in mind? > Alternatively, we could add a user option to make the swap > unconditional, because maybe some users would prefer that to splitting > hair in this case. Then we could stop worrying about all those fine > differences. Should I cook up a user option to unconditionally do the swap before we apply the attached? Otherwise we may disgruntle trunk users who actually liked the behaviour I reported in the OP (swapping regardless of whether region stands out). =E2=81=82 footnotes =E2=81=82 [1] (face-differs-from-default-p 'default) =E2=86=A6 :stipple (display-supports-face-attributes-p '(:stipple nil)) =E2=86=A6 t So a face that explicitly inherits from 'default, or sets :stipple to nil (rather than 'unspecified) differs-from-default-p. This seems inappropriate, based on display-supports-face-attributes-p's docstring: > The definition of =E2=80=98supported=E2=80=99 is somewhat heuristic, but = basically means > that a face containing all the attributes in ATTRIBUTES, when merged > with the default face for display, can be represented in a way that=E2=80= =99s >=20 > (1) different in appearance from the default face, and ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > (2) =E2=80=98close in spirit=E2=80=99 to what the attributes specify, if= not exact. I can debug gui_supports_face_attributes_p if we agree that there is something to investigate here? [2] (if (face-differs-from-default-p list-matching-lines-prefix-face) list-matching-lines-prefix-face) > If this face will display the same as the default face, the prefix > column will not be highlighted specially. =E2=80=94 C-h v list-matching-lines-prefix-face Why bother with this `if' then? Isn't this gratuituous complexity? Just passing the face regardless would have the same effect (the prefix column will look like it has the default face). [3] > Maybe what I remember > happens only on some terminals. AFAICT, :extend {nil,t} successfully make the background {stop at,extend past} EOL on these terminals: * Linux TTYs (openSUSE Tumbleweed: Linux 6.1.7-1-default x86_64, Debian 11: Linux 5.10.0-19-amd64 x86_64) * VTE-based pseudo terminals (terminator, xfce4-terminal) * Plasma's konsole * xterm > Or maybe I'm misremembering and it > was because of underline and not the color. * Linux TTYs don't support :underline AFAICT, * all pseudo terminals listed above do, and :extend nil/t both do TRT. > But there is definitely a > difference. ACK. Based on vc-region-history alone it feels like tty_supports_face_attributes_p just got left out of the :extend party, but I'll see what turns up in the lists. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Avoid-spurious-pause-in-kill-ring-save-Bug-60841.patch >From 9ec48654977d7c8b7a26e99fce6693d67d023599 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 (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 a more extensive predicate. * lisp/simple.el (region-stands-out-p): New function to detect "if the region is highlighted", leveraging face-differs-from-default-p. (indicate-copied-region): Use it. * lisp/faces.el (face-differs-from-default-p): Also ignore :extend, since the answers display-supports-face-attributes-p gives for that attribute do not help determine whether FACE is visually distinct from default. --- lisp/faces.el | 11 ++++++++++- lisp/simple.el | 10 ++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) 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 7bda368d85d..ef816949d36 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -5871,6 +5871,13 @@ copy-region-blink-delay :group 'killing :version "28.1") +(defun region-stands-out-p () + "Whether the region can be distinguished visually. +This takes into account whether the region is active, and whether +the `region' face displays differently from the default face." + (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 @@ -5891,8 +5898,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-stands-out-p))) ;; Swap point and mark. (set-marker (mark-marker) (point) (current-buffer)) (goto-char mark) -- 2.39.0 --=-=-=--