unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#34901: CUA cut/copy no longer work in keyboard macros (emacs25)
@ 2019-03-18  1:04 Ben Bridgwater
  2019-03-18 16:50 ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Ben Bridgwater @ 2019-03-18  1:04 UTC (permalink / raw)
  To: 34901

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

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

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#34901: CUA cut/copy no longer work in keyboard macros (emacs25)
  2019-03-18  1:04 bug#34901: CUA cut/copy no longer work in keyboard macros (emacs25) Ben Bridgwater
@ 2019-03-18 16:50 ` Eli Zaretskii
  2019-03-18 17:06   ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2019-03-18 16:50 UTC (permalink / raw)
  To: Ben Bridgwater, Stefan Monnier; +Cc: 34901

> From: Ben Bridgwater <bbridgwater@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);





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#34901: CUA cut/copy no longer work in keyboard macros (emacs25)
  2019-03-18 16:50 ` Eli Zaretskii
@ 2019-03-18 17:06   ` Stefan Monnier
  2019-03-20  9:24     ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2019-03-18 17:06 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 34901, Ben Bridgwater

> 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





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#34901: CUA cut/copy no longer work in keyboard macros (emacs25)
  2019-03-18 17:06   ` Stefan Monnier
@ 2019-03-20  9:24     ` Eli Zaretskii
  0 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2019-03-20  9:24 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 34901-done, bbridgwater

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: Ben Bridgwater <bbridgwater@gmail.com>,  34901@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.





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-03-20  9:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-18  1:04 bug#34901: CUA cut/copy no longer work in keyboard macros (emacs25) Ben Bridgwater
2019-03-18 16:50 ` Eli Zaretskii
2019-03-18 17:06   ` Stefan Monnier
2019-03-20  9:24     ` Eli Zaretskii

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).