diff options
| author | Eli Zaretskii | 2019-03-20 11:21:54 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2019-03-20 11:21:54 +0200 |
| commit | f13d97b4de02586cce49909aa2f3f51fcb5daa5f (patch) | |
| tree | a467b0e89bd82d81a1ece2f94b69872b6312c28e | |
| parent | 047c1b19353ff58d8cd45935c7b44c911b70e312 (diff) | |
| download | emacs-f13d97b4de02586cce49909aa2f3f51fcb5daa5f.tar.gz emacs-f13d97b4de02586cce49909aa2f3f51fcb5daa5f.zip | |
Fix defining keyboard macros in CUA mode
* lisp/emulation/cua-base.el (cua--prefix-override-replay):
Push the key to replace wrapped in '(no-record . KEY)', so
that it doesn't get recorded more than once. (Bug#34901)
* src/keyboard.c (read_char): Handle the '(no-record . KEY)'
event by substituting KEY for it.
(syms_of_keyboard) <no-record>: New DEFSYM.
<unread-command-events>: Update the doc string.
* doc/lispref/commands.texi (Event Input Misc): Document the
'(no-record . EVENT)' form.
| -rw-r--r-- | doc/lispref/commands.texi | 8 | ||||
| -rw-r--r-- | lisp/emulation/cua-base.el | 3 | ||||
| -rw-r--r-- | src/keyboard.c | 28 |
3 files changed, 35 insertions, 4 deletions
diff --git a/doc/lispref/commands.texi b/doc/lispref/commands.texi index 1eb580e1e0f..cd44c1c87ef 100644 --- a/doc/lispref/commands.texi +++ b/doc/lispref/commands.texi | |||
| @@ -2880,6 +2880,14 @@ command's key sequence (as returned by, e.g., @code{this-command-keys}), | |||
| 2880 | as the events will already have been added once as they were read for | 2880 | as the events will already have been added once as they were read for |
| 2881 | the first time. An element of the form @w{@code{(t . @var{event})}} | 2881 | the first time. An element of the form @w{@code{(t . @var{event})}} |
| 2882 | forces @var{event} to be added to the current command's key sequence. | 2882 | forces @var{event} to be added to the current command's key sequence. |
| 2883 | |||
| 2884 | @cindex not recording input events | ||
| 2885 | @cindex input events, prevent recording | ||
| 2886 | Elements read from this list are normally recorded by the | ||
| 2887 | record-keeping features (@pxref{Recording Input}) and while defining a | ||
| 2888 | keyboard macro (@pxref{Keyboard Macros}). However, an element of the | ||
| 2889 | form @w{@code{(no-record . @var{event})}} causes @var{event} to be | ||
| 2890 | processed normally without recording it. | ||
| 2883 | @end defvar | 2891 | @end defvar |
| 2884 | 2892 | ||
| 2885 | @defun listify-key-sequence key | 2893 | @defun listify-key-sequence key |
diff --git a/lisp/emulation/cua-base.el b/lisp/emulation/cua-base.el index 43e0956ea83..302ef123865 100644 --- a/lisp/emulation/cua-base.el +++ b/lisp/emulation/cua-base.el | |||
| @@ -710,7 +710,8 @@ a cons (TYPE . COLOR), then both properties are affected." | |||
| 710 | ;; C-x binding after the first C-x C-x was rewritten to just C-x). | 710 | ;; C-x binding after the first C-x C-x was rewritten to just C-x). |
| 711 | (prefix-command-preserve-state) | 711 | (prefix-command-preserve-state) |
| 712 | ;; Push the key back on the event queue | 712 | ;; Push the key back on the event queue |
| 713 | (setq unread-command-events (cons key unread-command-events)))) | 713 | (setq unread-command-events (cons (cons 'no-record key) |
| 714 | unread-command-events)))) | ||
| 714 | 715 | ||
| 715 | (defun cua--prefix-override-handler () | 716 | (defun cua--prefix-override-handler () |
| 716 | "Start timer waiting for prefix key to be followed by another key. | 717 | "Start timer waiting for prefix key to be followed by another key. |
diff --git a/src/keyboard.c b/src/keyboard.c index 22e4377ee86..362bd663878 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -2364,7 +2364,14 @@ read_char (int commandflag, Lisp_Object map, | |||
| 2364 | if (CONSP (c) && EQ (XCAR (c), Qt)) | 2364 | if (CONSP (c) && EQ (XCAR (c), Qt)) |
| 2365 | c = XCDR (c); | 2365 | c = XCDR (c); |
| 2366 | else | 2366 | else |
| 2367 | reread = true; | 2367 | { |
| 2368 | if (CONSP (c) && EQ (XCAR (c), Qno_record)) | ||
| 2369 | { | ||
| 2370 | c = XCDR (c); | ||
| 2371 | recorded = true; | ||
| 2372 | } | ||
| 2373 | reread = true; | ||
| 2374 | } | ||
| 2368 | 2375 | ||
| 2369 | /* Undo what read_char_x_menu_prompt did when it unread | 2376 | /* Undo what read_char_x_menu_prompt did when it unread |
| 2370 | additional keys returned by Fx_popup_menu. */ | 2377 | additional keys returned by Fx_popup_menu. */ |
| @@ -2745,7 +2752,14 @@ read_char (int commandflag, Lisp_Object map, | |||
| 2745 | if (CONSP (c) && EQ (XCAR (c), Qt)) | 2752 | if (CONSP (c) && EQ (XCAR (c), Qt)) |
| 2746 | c = XCDR (c); | 2753 | c = XCDR (c); |
| 2747 | else | 2754 | else |
| 2748 | reread = true; | 2755 | { |
| 2756 | if (CONSP (c) && EQ (XCAR (c), Qno_record)) | ||
| 2757 | { | ||
| 2758 | c = XCDR (c); | ||
| 2759 | recorded = true; | ||
| 2760 | } | ||
| 2761 | reread = true; | ||
| 2762 | } | ||
| 2749 | } | 2763 | } |
| 2750 | 2764 | ||
| 2751 | /* Read something from current KBOARD's side queue, if possible. */ | 2765 | /* Read something from current KBOARD's side queue, if possible. */ |
| @@ -2807,6 +2821,11 @@ read_char (int commandflag, Lisp_Object map, | |||
| 2807 | 2821 | ||
| 2808 | if (CONSP (c) && EQ (XCAR (c), Qt)) | 2822 | if (CONSP (c) && EQ (XCAR (c), Qt)) |
| 2809 | c = XCDR (c); | 2823 | c = XCDR (c); |
| 2824 | else if (CONSP (c) && EQ (XCAR (c), Qno_record)) | ||
| 2825 | { | ||
| 2826 | c = XCDR (c); | ||
| 2827 | recorded = true; | ||
| 2828 | } | ||
| 2810 | } | 2829 | } |
| 2811 | 2830 | ||
| 2812 | non_reread: | 2831 | non_reread: |
| @@ -11193,6 +11212,7 @@ syms_of_keyboard (void) | |||
| 11193 | Fput (var, Qevent_symbol_elements, list1 (var)); | 11212 | Fput (var, Qevent_symbol_elements, list1 (var)); |
| 11194 | } | 11213 | } |
| 11195 | } | 11214 | } |
| 11215 | DEFSYM (Qno_record, "no-record"); | ||
| 11196 | 11216 | ||
| 11197 | button_down_location = make_nil_vector (5); | 11217 | button_down_location = make_nil_vector (5); |
| 11198 | staticpro (&button_down_location); | 11218 | staticpro (&button_down_location); |
| @@ -11303,7 +11323,9 @@ so that you can determine whether the command was run by mouse or not. */); | |||
| 11303 | These events are processed first, before actual keyboard input. | 11323 | These events are processed first, before actual keyboard input. |
| 11304 | Events read from this list are not normally added to `this-command-keys', | 11324 | Events read from this list are not normally added to `this-command-keys', |
| 11305 | as they will already have been added once as they were read for the first time. | 11325 | as they will already have been added once as they were read for the first time. |
| 11306 | An element of the form (t . EVENT) forces EVENT to be added to that list. */); | 11326 | An element of the form (t . EVENT) forces EVENT to be added to that list. |
| 11327 | An element of the form (no-record . EVENT) means process EVENT, but do not | ||
| 11328 | record it in the keyboard macros, recent-keys, and the dribble file. */); | ||
| 11307 | Vunread_command_events = Qnil; | 11329 | Vunread_command_events = Qnil; |
| 11308 | 11330 | ||
| 11309 | DEFVAR_LISP ("unread-post-input-method-events", Vunread_post_input_method_events, | 11331 | DEFVAR_LISP ("unread-post-input-method-events", Vunread_post_input_method_events, |