unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* clipboard-kill-ring-save with tmm: avoid when region inactive?
       [not found] <D24A6F8B-CCC4-4923-B51A-5529D4239678@telecom-bretagne.eu>
@ 2015-02-10 14:20 ` David Reitter
  0 siblings, 0 replies; only message in thread
From: David Reitter @ 2015-02-10 14:20 UTC (permalink / raw)
  To: emacs-devel@gnu.org developers

[-- Attachment #1: Type: text/plain, Size: 2151 bytes --]

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’t 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…
> 
> Fabien
> 


[-- Attachment #2: Type: text/html, Size: 6003 bytes --]

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-02-10 14:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <D24A6F8B-CCC4-4923-B51A-5529D4239678@telecom-bretagne.eu>
2015-02-10 14:20 ` clipboard-kill-ring-save with tmm: avoid when region inactive? David Reitter

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).