emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

clipboard-kill-ring-save with tmm: avoid when region inactive?


From: David Reitter
Subject: clipboard-kill-ring-save with tmm: avoid when region inactive?
Date: Tue, 10 Feb 2015 09:20:21 -0500

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 <address@hidden>
Date: February 10, 2015 at 3:33:38 AM EST
To: Emacs on Mac OS X Mailing List <address@hidden>
Subject: [OS X Emacs] Old behavior of copy
Reply-To: Emacs on Mac OS X Mailing List <address@hidden>

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]