From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Reitter Newsgroups: gmane.emacs.devel Subject: clipboard-kill-ring-save with tmm: avoid when region inactive? Date: Tue, 10 Feb 2015 09:20:21 -0500 Message-ID: <31CAC3F2-2A5B-478F-A618-7DFB708A48FC@gmail.com> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2070.6\)) Content-Type: multipart/alternative; boundary="Apple-Mail=_42546845-9721-4D69-8991-3D90736CD95B" X-Trace: ger.gmane.org 1423578189 18232 80.91.229.3 (10 Feb 2015 14:23:09 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 10 Feb 2015 14:23:09 +0000 (UTC) To: "emacs-devel@gnu.org developers" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Feb 10 15:22:52 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YLBiF-0008Rz-Ni for ged-emacs-devel@m.gmane.org; Tue, 10 Feb 2015 15:22:51 +0100 Original-Received: from localhost ([::1]:40111 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLBiE-0006Jc-KX for ged-emacs-devel@m.gmane.org; Tue, 10 Feb 2015 09:22:50 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59663) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLBfy-0003EH-Pk for emacs-devel@gnu.org; Tue, 10 Feb 2015 09:20:35 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YLBfs-0001RT-O4 for emacs-devel@gnu.org; Tue, 10 Feb 2015 09:20:30 -0500 Original-Received: from mail-qa0-x231.google.com ([2607:f8b0:400d:c00::231]:44502) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLBfs-0001Qr-Ge for emacs-devel@gnu.org; Tue, 10 Feb 2015 09:20:24 -0500 Original-Received: by mail-qa0-f49.google.com with SMTP id v8so26352532qal.8 for ; Tue, 10 Feb 2015 06:20:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:content-type:subject:date:references:to:message-id :mime-version; bh=EPcRPoFaNJCfVfYTp3ZvsGv3G/hKbE6tklWOr48a0dA=; b=GZH4hvVJ8qxD3KHz/TMHIzLVJGcBN+e2INcmTZ0Veq5byjK2/vEVhPe1FLL0IatHEM EKo0O8HXR4vqOTTFmNTt474tFSSNBrix61S4y2t7Z0kx76OQrfFbsyk5HR6w5UjUvWD/ sGZBGq2uwAmj5RqeSA3nDzgZrQDzkzh5rNET2Fr0qhdNxcOdLEulgPBmOZ5uLya+DMpZ Ml9Kt1D1dyEMDK0hveDsPJ0yMxK/D7dBEvKVJNIERRsj6/yMs57Pc96bFBaKhZULk7Ax 5zaPXQc2R8TAOzEghVcKFMMlDV0SPB5pSKPBiB0tkWG9cLbqcqNojEQCa1rIqmBkZ1e6 l6jQ== X-Received: by 10.140.91.201 with SMTP id z67mr51042748qgd.27.1423578023254; Tue, 10 Feb 2015 06:20:23 -0800 (PST) Original-Received: from [10.0.1.15] (c-71-58-212-112.hsd1.pa.comcast.net. [71.58.212.112]) by mx.google.com with ESMTPSA id l7sm15367315qaz.15.2015.02.10.06.20.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Feb 2015 06:20:22 -0800 (PST) X-Mailer: Apple Mail (2.2070.6) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400d:c00::231 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:182801 Archived-At: --Apple-Mail=_42546845-9721-4D69-8991-3D90736CD95B Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Hi, Would the change outlined below (see user message quoted) be reasonable? When transient-mark-mode is on, we should require the region to be = active in order to copy/kill it via the commands. I did not find any programmatic use of these commands in Emacs code, = though one would wonder if this creates package incompatibilities. - DR diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el index cd1a4d0..e6d3b12c 100644 --- a/lisp/menu-bar.el +++ b/lisp/menu-bar.el @@ -536,14 +536,18 @@ (defun clipboard-kill-ring-save (beg end &optional region) "Copy region to kill ring, and save in the GUI's clipboard." (interactive "r\np") - (let ((gui-select-enable-clipboard t)) - (kill-ring-save beg end region))) + (if (or (not transient-mark-mode) (use-region-p)) + (let ((gui-select-enable-clipboard t)) + (kill-ring-save beg end region)) + (error "Region not active."))) =20 (defun clipboard-kill-region (beg end &optional region) "Kill the region, and save it in the GUI's clipboard." (interactive "r\np") - (let ((gui-select-enable-clipboard t)) - (kill-region beg end region))) + (if (or (not transient-mark-mode) (use-region-p)) + (let ((gui-select-enable-clipboard t)) + (kill-region beg end region)) + (error "Region not active."))) =20 (defun menu-bar-enable-clipboard () "Make CUT, PASTE and COPY (keys and menu bar items) use the = clipboard. > Begin forwarded message: >=20 > From: Dagnat Fabien > Date: February 10, 2015 at 3:33:38 AM EST > To: Emacs on Mac OS X Mailing List > Subject: [OS X Emacs] Old behavior of copy > Reply-To: Emacs on Mac OS X Mailing List = >=20 > Hello, > I do not remember exactly when it changed but the behavior of "copy" = changed recently. Before, if nothing was selected copy would do nothing = now it copy something (don=E2=80=99t know exactly what) form the context = of the prompt. Is there any variable to get back the old behavior? Often = I mistake cmd-C for cmd-V and loose the content of the clipboard=E2=80=A6 >=20 > Fabien >=20 --Apple-Mail=_42546845-9721-4D69-8991-3D90736CD95B Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
Hi,

Would the change outlined below (see = user message quoted) be reasonable?

When transient-mark-mode is on, we = should require the region to be active in order to copy/kill it via the = commands.
I did not find any programmatic use of = these commands in Emacs code, though one would wonder if this creates = package incompatibilities.

- DR


diff = --git a/lisp/menu-bar.el b/lisp/menu-bar.el
index = cd1a4d0..e6d3b12c 100644
--- = a/lisp/menu-bar.el
+++ b/lisp/menu-bar.el
@@ -536,14 +536,18 @@
 (defun = clipboard-kill-ring-save (beg end &optional region)
   "Copy region to kill ring, and save in the GUI's = clipboard."
   (interactive = "r\np")
-  (let ((gui-select-enable-clipboard = t))
-    (kill-ring-save beg end = region)))
+  (if (or (not transient-mark-mode) = (use-region-p))
+      (let = ((gui-select-enable-clipboard t))
+ = (kill-ring-save beg end region))
+   =  (error "Region not active.")))
 
 (defun clipboard-kill-region (beg end &optional = region)
   "Kill the region, and save it = in the GUI's clipboard."
   (interactive = "r\np")
-  (let ((gui-select-enable-clipboard = t))
-    (kill-region beg end = region)))
+  (if (or (not transient-mark-mode) = (use-region-p))
+      (let = ((gui-select-enable-clipboard t))
+ = (kill-region beg end region))
+   =  (error "Region not active.")))
 
 (defun menu-bar-enable-clipboard ()
   "Make CUT, PASTE and COPY (keys and menu bar = items) use the clipboard.






Begin forwarded message:

From: = Dagnat Fabien <fabien.dagnat@telecom-bretagne.eu>
Date: = February 10, 2015 at 3:33:38 AM = EST
To: = Emacs on Mac OS X Mailing List = <macosx-emacs@email.esm.psu.edu>
Subject: = [OS X Emacs] Old = behavior of copy
Reply-To: Emacs on Mac OS X Mailing List <macosx-emacs@email.esm.psu.edu>

Hello,
I do not remember exactly when it changed but the behavior of = "copy" changed recently. Before, if nothing was selected copy would do = nothing now it copy something (don=E2=80=99t know exactly what) form the = context of the prompt. Is there any variable to get back the old = behavior? Often I mistake cmd-C for cmd-V and loose the content of the = clipboard=E2=80=A6

Fabien


= --Apple-Mail=_42546845-9721-4D69-8991-3D90736CD95B--