GNU bug report logs - #34901
CUA cut/copy no longer work in keyboard macros (emacs25)

Previous Next

Package: emacs;

Reported by: Ben Bridgwater <bbridgwater <at> gmail.com>

Date: Mon, 18 Mar 2019 05:36:01 UTC

Severity: normal

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 34901 in the body.
You can then email your comments to 34901 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#34901; Package emacs. (Mon, 18 Mar 2019 05:36:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ben Bridgwater <bbridgwater <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 18 Mar 2019 05:36:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ben Bridgwater <bbridgwater <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: CUA cut/copy no longer work in keyboard macros (emacs25)
Date: Sun, 17 Mar 2019 21:04:28 -0400
[Message part 1 (text/plain, inline)]
I just upgraded from emacs24 (Ubuntu 16.04) to emacs25 (Ubuntu 18.04), and
have found that the CUA cut/copy (ctrl-x, ctrl-v) bindings no longer work
in keyboard macros. Attempting to use them now results in an "keyboard
macro terminated by a command ringing the bell" error on macro playback.

The issue seems to be the CUA bindings since the underlying cut/copy
functions (kill-region, kill-ring-save) still work correctly in macros when
bound to other keys.

The CUA paste function (ctrl-v) is unaffected by the bug and continues to
work in macros.

Ben
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34901; Package emacs. (Mon, 18 Mar 2019 16:51:02 GMT) Full text and rfc822 format available.

Message #8 received at 34901 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ben Bridgwater <bbridgwater <at> gmail.com>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 34901 <at> debbugs.gnu.org
Subject: Re: bug#34901: CUA cut/copy no longer work in keyboard macros
 (emacs25)
Date: Mon, 18 Mar 2019 18:50:39 +0200
> From: Ben Bridgwater <bbridgwater <at> gmail.com>
> Date: Sun, 17 Mar 2019 21:04:28 -0400
> 
> I just upgraded from emacs24 (Ubuntu 16.04) to emacs25 (Ubuntu 18.04), and have found that the CUA
> cut/copy (ctrl-x, ctrl-v) bindings no longer work in keyboard macros.

I believe you meant C-x and C-c, not C-v.

> The issue seems to be the CUA bindings since the underlying cut/copy functions (kill-region, kill-ring-save)
> still work correctly in macros when bound to other keys.

Yes.  Turns out CUA is another package that relied on undocumented
kludges to avoid recording the same key twice, when keys are pushed
back onto unread-command-events.  Aargh!

Stefan, what do you think about the patch below?  Other that that, I
don't see what we could do with this stuff.

--- lisp/emulation/cua-base.el~0	2019-01-09 11:13:23.000000000 +0200
+++ lisp/emulation/cua-base.el	2019-03-18 15:14:34.349105600 +0200
@@ -710,7 +710,8 @@
     ;; C-x binding after the first C-x C-x was rewritten to just C-x).
     (prefix-command-preserve-state)
     ;; Push the key back on the event queue
-    (setq unread-command-events (cons key unread-command-events))))
+    (setq unread-command-events (cons (cons 'no-record key)
+                                      unread-command-events))))
 
 (defun cua--prefix-override-handler ()
   "Start timer waiting for prefix key to be followed by another key.


--- src/keyboard.c~0	2019-03-03 06:47:29.000000000 +0200
+++ src/keyboard.c	2019-03-18 15:21:16.543163600 +0200
@@ -2360,7 +2360,14 @@ read_char (int commandflag, Lisp_Object 
       if (CONSP (c) && EQ (XCAR (c), Qt))
 	c = XCDR (c);
       else
-	reread = true;
+	{
+	  if (CONSP (c) && EQ (XCAR (c), Qno_record))
+	    {
+	      c = XCDR (c);
+	      recorded = true;
+	    }
+	  reread = true;
+	}
 
       /* Undo what read_char_x_menu_prompt did when it unread
 	 additional keys returned by Fx_popup_menu.  */
@@ -2741,7 +2748,14 @@ read_char (int commandflag, Lisp_Object 
       if (CONSP (c) && EQ (XCAR (c), Qt))
 	c = XCDR (c);
       else
-	reread = true;
+	{
+	  if (CONSP (c) && EQ (XCAR (c), Qno_record))
+	    {
+	      c = XCDR (c);
+	      recorded = true;
+	    }
+	  reread = true;
+	}
     }
 
   /* Read something from current KBOARD's side queue, if possible.  */
@@ -2803,6 +2817,11 @@ read_char (int commandflag, Lisp_Object 
 
       if (CONSP (c) && EQ (XCAR (c), Qt))
 	c = XCDR (c);
+      else if (CONSP (c) && EQ (XCAR (c), Qno_record))
+	{
+	  c = XCDR (c);
+	  recorded = true;
+	}
   }
 
  non_reread:
@@ -11192,6 +11211,7 @@ syms_of_keyboard (void)
 	Fput (var, Qevent_symbol_elements, list1 (var));
       }
   }
+  DEFSYM (Qno_record, "no-record");
 
   button_down_location = make_nil_vector (5);
   staticpro (&button_down_location);




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#34901; Package emacs. (Mon, 18 Mar 2019 17:07:02 GMT) Full text and rfc822 format available.

Message #11 received at 34901 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 34901 <at> debbugs.gnu.org, Ben Bridgwater <bbridgwater <at> gmail.com>
Subject: Re: bug#34901: CUA cut/copy no longer work in keyboard macros
 (emacs25)
Date: Mon, 18 Mar 2019 13:06:45 -0400
> Yes.  Turns out CUA is another package that relied on undocumented
> kludges to avoid recording the same key twice, when keys are pushed
> back onto unread-command-events.  Aargh!
>
> Stefan, what do you think about the patch below?  Other that that, I
> don't see what we could do with this stuff.

I wouldn't say it looks "good", but I can't think of a better
approach, thanks.


        Stefan




Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Wed, 20 Mar 2019 09:26:02 GMT) Full text and rfc822 format available.

Notification sent to Ben Bridgwater <bbridgwater <at> gmail.com>:
bug acknowledged by developer. (Wed, 20 Mar 2019 09:26:02 GMT) Full text and rfc822 format available.

Message #16 received at 34901-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 34901-done <at> debbugs.gnu.org, bbridgwater <at> gmail.com
Subject: Re: bug#34901: CUA cut/copy no longer work in keyboard macros
 (emacs25)
Date: Wed, 20 Mar 2019 11:24:55 +0200
> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
> Cc: Ben Bridgwater <bbridgwater <at> gmail.com>,  34901 <at> debbugs.gnu.org
> Date: Mon, 18 Mar 2019 13:06:45 -0400
> 
> > Yes.  Turns out CUA is another package that relied on undocumented
> > kludges to avoid recording the same key twice, when keys are pushed
> > back onto unread-command-events.  Aargh!
> >
> > Stefan, what do you think about the patch below?  Other that that, I
> > don't see what we could do with this stuff.
> 
> I wouldn't say it looks "good", but I can't think of a better
> approach, thanks.

OK, pushed to the master branch.

Unfortunately, it's too late for getting this into Emacs 26.2, so for
now the solution will have to wait for Emacs 27.  Too bad no one paid
attention to this since Emacs 25.1 was released.

Thanks.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 17 Apr 2019 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 5 years and 9 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.