From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Sean Whitton Newsgroups: gmane.emacs.bugs Subject: bug#42865: 28.0.50; Add new 'copy-region-quietly' defcustom Date: Fri, 14 Aug 2020 10:38:02 -0700 Message-ID: <87lfihi0w5.fsf@iris.silentflame.com> 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="15328"; mail-complaints-to="usenet@ciao.gmane.io" To: 42865@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Aug 14 19:39:11 2020 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 1k6dfa-0003pz-M0 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 14 Aug 2020 19:39:11 +0200 Original-Received: from localhost ([::1]:54586 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k6dfZ-000318-Ck for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 14 Aug 2020 13:39:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60196) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k6dfS-00030s-7j for bug-gnu-emacs@gnu.org; Fri, 14 Aug 2020 13:39:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42241) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k6dfR-0001Bm-TX for bug-gnu-emacs@gnu.org; Fri, 14 Aug 2020 13:39:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1k6dfR-0004RN-R2 for bug-gnu-emacs@gnu.org; Fri, 14 Aug 2020 13:39:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Sean Whitton Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 14 Aug 2020 17:39:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 42865 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.159742669117009 (code B ref -1); Fri, 14 Aug 2020 17:39:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 14 Aug 2020 17:38:11 +0000 Original-Received: from localhost ([127.0.0.1]:53787 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k6ded-0004QG-Fx for submit@debbugs.gnu.org; Fri, 14 Aug 2020 13:38:11 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:56998) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k6deb-0004Q8-R1 for submit@debbugs.gnu.org; Fri, 14 Aug 2020 13:38:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60092) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k6deb-0002xP-K9 for bug-gnu-emacs@gnu.org; Fri, 14 Aug 2020 13:38:09 -0400 Original-Received: from out4-smtp.messagingengine.com ([66.111.4.28]:44415) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k6deZ-00017i-Ha for bug-gnu-emacs@gnu.org; Fri, 14 Aug 2020 13:38:09 -0400 Original-Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id B54C35C018B for ; Fri, 14 Aug 2020 13:38:05 -0400 (EDT) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Fri, 14 Aug 2020 13:38:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=spwhitton.name; h=from:to:subject:date:message-id:mime-version:content-type; s= fm3; bh=h9ylz3JZ2u9dKC2o4rLQnIZdWOy0U2kliwBJcWrC6b8=; b=GXOdPwPr Tb0w4pUQrR3ZtauS5v+JkmuxDdQl1eWE89lAjivvwrh1ZaW9GI1jKEecsNn3Yhpr u/BcCC8tXwzdutQZk7sG8USy9POO+z0zGTRJ1uJEHDvXYbGys14GIm6FBlkNT/JQ Y3JmTaNG91KardUd1LBsKaYzGuPViQNEiBdZiUCgpiyJDl5VD/vxQsECMeKLAC7p /bJFwmm4tTyzeMzAWvXnE+BU7VUXO35OVo+8NHKea6QG3QmdEef4DufEoIauKMC7 S3lD8ihQMc0KD5ADMfBcdWbaT4cl0yyQH63Ro9c7kfKVaauwQNAa+VcSYNSKh/tJ 5ZNc7jL3IZ2q5g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; bh=h9ylz3JZ2u9dKC2o4rLQnIZdWOy0U 2kliwBJcWrC6b8=; b=jSZxd5P80J1IK89RdqYeE2SBwicKyJonXLyt82NZrrrn2 K6298C6XMBDSj9zTyfHiWyLb1ISJlhMklM4FiIleBCn/Wo7jAdMYYV7CpmuOiEoR yIUMJkJKzw9HuZ+/9zoacnNT7Tm5t0JDa7Oy+c1wIBBn+oEhUd2zw0pyvQdmlOY8 pRmnX3+gkcK4uA3XOX+g7KYcnkY/9o6vtJJUokxp6Ipx4wLENRmXnyZUtMUMkp0X KTK/ap1nXsMU4TXC2sEOvJfFIjn4M3f6JfY/PY6Z7lSQ6wX2L60K87ESQyzonVWz 8J9gFQS6jf9RS87C1uCe8uJkl33MCQcLPQL5L2ZrA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrleejgdduuddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkgggtsehmtderredttd dtnecuhfhrohhmpefuvggrnhcuhghhihhtthhonhcuoehsphifhhhithhtohhnsehsphif hhhithhtohhnrdhnrghmvgeqnecuggftrfgrthhtvghrnhepteegtdejheejvdehgeettd dvjeffudetuedutdegkefhtdetteeuueetkeefkeegnecuvehluhhsthgvrhfuihiivgep tdenucfrrghrrghmpehmrghilhhfrhhomhepshhpfihhihhtthhonhesshhpfihhihhtth honhdrnhgrmhgv X-ME-Proxy: Received-SPF: pass client-ip=66.111.4.28; envelope-from=spwhitton@spwhitton.name; helo=out4-smtp.messagingengine.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/14 13:38:05 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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" Xref: news.gmane.io gmane.emacs.bugs:185147 Archived-At: --=-=-= Content-Type: text/plain Tags: patch Hello, I want to have a way to suppress swapping point and mark when copying an inactive region, as I find that distracting. Here is a patch adding a new defcustom to achieve that. -- Sean Whitton --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-new-defcustom-copy-region-quietly.patch >From ffcf36626d75b1f421fef36a79542ac8cacb5991 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Fri, 14 Aug 2020 10:33:54 -0700 Subject: [PATCH] Add new defcustom 'copy-region-quietly' * lisp/simple.el (copy-region-quietly): Add new defcustom. * lisp/simple.el (indicate-copied-region): Don't swap point and mark if copy-region-quietly is no-swap or t. Don't display a message if copy-region-quietly is no-message or t. Document the change. * etc/NEWS: Document the change. --- etc/NEWS | 4 ++++ lisp/simple.el | 47 ++++++++++++++++++++++++++++++++++++----------- 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 2be9743a45..5bd495fd43 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -145,6 +145,10 @@ setting the variable 'auto-save-visited-mode' buffer-locally to nil. description of the properties. Likewise 'button-describe' does the same for a button. +** Whether and how the copying of an inactive region is indicated +visually can now be controlled by customizing the variable +'copy-region-quietly'. + * Changes in Specialized Modes and Packages in Emacs 28.1 diff --git a/lisp/simple.el b/lisp/simple.el index 6f72c3b81b..cd1c773f43 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -4871,6 +4871,22 @@ kill-read-only-ok :type 'boolean :group 'killing) +(defcustom copy-region-quietly nil + "Whether the copying of an inactive region is indicated visually. +If nil, behave as per the documentation of `indicate-copied-region'. +`no-swap' means inhibit briefly swapping point and mark. +`no-message' means inhibit displaying a message. +Any other value means inhibit both swapping and message-displaying." + :type '(choice :tag "Copy region quietly" + (const :tag "Default behavior" nil) + (const :tag "Don't swap point and mark" no-swap) + (const :tag "Don't display a message" no-message) + (const + :tag + "Don't swap point and mark or display a message" + t)) + :group 'killing) + (defun kill-region (beg end &optional region) "Kill (\"cut\") text between point and mark. This deletes the text from the buffer and saves it in the kill ring. @@ -5005,7 +5021,10 @@ indicate-copied-region If the mark lies outside the selected window, display an informative message containing a sample of the copied text. The optional argument MESSAGE-LEN, if non-nil, specifies the length -of this sample text; it defaults to 40." +of this sample text; it defaults to 40. + +Both these behaviors can be inhibited by setting `copy-region-quietly', +which see." (let ((mark (mark t)) (point (point)) ;; Inhibit quitting so we can make a quit here @@ -5014,8 +5033,9 @@ indicate-copied-region (if (pos-visible-in-window-p mark (selected-window)) ;; Swap point-and-mark quickly so as to show the region that ;; was selected. Don't do it if the region is highlighted. - (unless (and (region-active-p) - (face-background 'region nil t)) + (unless (or (memq copy-region-quietly '(t no-swap)) + (and (region-active-p) + (face-background 'region nil t))) ;; Swap point and mark. (set-marker (mark-marker) (point) (current-buffer)) (goto-char mark) @@ -5027,14 +5047,19 @@ indicate-copied-region ;; as C-g would as a command. (and quit-flag (region-active-p) (deactivate-mark))) - (let ((len (min (abs (- mark point)) - (or message-len 40)))) - (if (< point mark) - ;; Don't say "killed"; that is misleading. - (message "Saved text until \"%s\"" - (buffer-substring-no-properties (- mark len) mark)) - (message "Saved text from \"%s\"" - (buffer-substring-no-properties mark (+ mark len)))))))) + (unless (memq copy-region-quietly '(t no-message)) + (let ((len (min (abs (- mark point)) + (or message-len 40)))) + (if (< point mark) + ;; Don't say "killed"; that is misleading. + (message "Saved text until \"%s\"" + (buffer-substring-no-properties + (- mark len) + mark)) + (message "Saved text from \"%s\"" + (buffer-substring-no-properties + mark + (+ mark len))))))))) (defun append-next-kill (&optional interactive) "Cause following command, if it kills, to add to previous kill. -- 2.27.0 --=-=-=--