diff options
| author | Eli Zaretskii | 2018-07-21 12:10:20 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2018-07-21 12:10:20 +0300 |
| commit | 03e3440dbbfea40b449a9f6f23a3630664275d11 (patch) | |
| tree | 37ab03786de0ca04d0a8bfc7a74546f68a2c61fd | |
| parent | 1780502da6b9ac8d3063dfd56f675318568283dc (diff) | |
| download | emacs-03e3440dbbfea40b449a9f6f23a3630664275d11.tar.gz emacs-03e3440dbbfea40b449a9f6f23a3630664275d11.zip | |
Fix recording keyboard macros when input method is active
* lisp/international/quail.el (quail-start-translation)
(quail-start-conversion): Bind inhibit--record-char to t for
the first character of a translated sequence.
* src/keyboard.c (record_char): Don't record events from
macros to dribble file, per documentation.
(Fopen_dribble_file): Doc fix.
(syms_of_keyboard) <inhibit--record-char>: New variable.
(record_char): Don't record input event if
inhibit--record-char is non-nil. (Bug#32108)
| -rw-r--r-- | lisp/international/quail.el | 20 | ||||
| -rw-r--r-- | src/keyboard.c | 19 |
2 files changed, 33 insertions, 6 deletions
diff --git a/lisp/international/quail.el b/lisp/international/quail.el index eece836354c..ec15ccaaf76 100644 --- a/lisp/international/quail.el +++ b/lisp/international/quail.el | |||
| @@ -1394,12 +1394,13 @@ Return the input string." | |||
| 1394 | (generated-events nil) ;FIXME: What is this? | 1394 | (generated-events nil) ;FIXME: What is this? |
| 1395 | (input-method-function nil) | 1395 | (input-method-function nil) |
| 1396 | (modified-p (buffer-modified-p)) | 1396 | (modified-p (buffer-modified-p)) |
| 1397 | last-command-event last-command this-command) | 1397 | last-command-event last-command this-command inhibit-record) |
| 1398 | (setq quail-current-key "" | 1398 | (setq quail-current-key "" |
| 1399 | quail-current-str "" | 1399 | quail-current-str "" |
| 1400 | quail-translating t) | 1400 | quail-translating t) |
| 1401 | (if key | 1401 | (if key |
| 1402 | (setq unread-command-events (cons key unread-command-events))) | 1402 | (setq unread-command-events (cons key unread-command-events) |
| 1403 | inhibit-record t)) | ||
| 1403 | (while quail-translating | 1404 | (while quail-translating |
| 1404 | (set-buffer-modified-p modified-p) | 1405 | (set-buffer-modified-p modified-p) |
| 1405 | (quail-show-guidance) | 1406 | (quail-show-guidance) |
| @@ -1408,8 +1409,13 @@ Return the input string." | |||
| 1408 | (or input-method-previous-message "") | 1409 | (or input-method-previous-message "") |
| 1409 | quail-current-str | 1410 | quail-current-str |
| 1410 | quail-guidance-str))) | 1411 | quail-guidance-str))) |
| 1412 | ;; We inhibit record_char only for the first key, | ||
| 1413 | ;; because it was already recorded before read_char | ||
| 1414 | ;; called quail-input-method. | ||
| 1415 | (inhibit--record-char inhibit-record) | ||
| 1411 | (keyseq (read-key-sequence prompt nil nil t)) | 1416 | (keyseq (read-key-sequence prompt nil nil t)) |
| 1412 | (cmd (lookup-key (quail-translation-keymap) keyseq))) | 1417 | (cmd (lookup-key (quail-translation-keymap) keyseq))) |
| 1418 | (setq inhibit-record nil) | ||
| 1413 | (if (if key | 1419 | (if (if key |
| 1414 | (and (commandp cmd) (not (eq cmd 'quail-other-command))) | 1420 | (and (commandp cmd) (not (eq cmd 'quail-other-command))) |
| 1415 | (eq cmd 'quail-self-insert-command)) | 1421 | (eq cmd 'quail-self-insert-command)) |
| @@ -1453,14 +1459,15 @@ Return the input string." | |||
| 1453 | (generated-events nil) ;FIXME: What is this? | 1459 | (generated-events nil) ;FIXME: What is this? |
| 1454 | (input-method-function nil) | 1460 | (input-method-function nil) |
| 1455 | (modified-p (buffer-modified-p)) | 1461 | (modified-p (buffer-modified-p)) |
| 1456 | last-command-event last-command this-command) | 1462 | last-command-event last-command this-command inhibit-record) |
| 1457 | (setq quail-current-key "" | 1463 | (setq quail-current-key "" |
| 1458 | quail-current-str "" | 1464 | quail-current-str "" |
| 1459 | quail-translating t | 1465 | quail-translating t |
| 1460 | quail-converting t | 1466 | quail-converting t |
| 1461 | quail-conversion-str "") | 1467 | quail-conversion-str "") |
| 1462 | (if key | 1468 | (if key |
| 1463 | (setq unread-command-events (cons key unread-command-events))) | 1469 | (setq unread-command-events (cons key unread-command-events) |
| 1470 | inhibit-record t)) | ||
| 1464 | (while quail-converting | 1471 | (while quail-converting |
| 1465 | (set-buffer-modified-p modified-p) | 1472 | (set-buffer-modified-p modified-p) |
| 1466 | (or quail-translating | 1473 | (or quail-translating |
| @@ -1476,8 +1483,13 @@ Return the input string." | |||
| 1476 | quail-conversion-str | 1483 | quail-conversion-str |
| 1477 | quail-current-str | 1484 | quail-current-str |
| 1478 | quail-guidance-str))) | 1485 | quail-guidance-str))) |
| 1486 | ;; We inhibit record_char only for the first key, | ||
| 1487 | ;; because it was already recorded before read_char | ||
| 1488 | ;; called quail-input-method. | ||
| 1489 | (inhibit--record-char inhibit-record) | ||
| 1479 | (keyseq (read-key-sequence prompt nil nil t)) | 1490 | (keyseq (read-key-sequence prompt nil nil t)) |
| 1480 | (cmd (lookup-key (quail-conversion-keymap) keyseq))) | 1491 | (cmd (lookup-key (quail-conversion-keymap) keyseq))) |
| 1492 | (setq inhibit-record nil) | ||
| 1481 | (if (if key (commandp cmd) (eq cmd 'quail-self-insert-command)) | 1493 | (if (if key (commandp cmd) (eq cmd 'quail-self-insert-command)) |
| 1482 | (progn | 1494 | (progn |
| 1483 | (setq last-command-event (aref keyseq (1- (length keyseq))) | 1495 | (setq last-command-event (aref keyseq (1- (length keyseq))) |
diff --git a/src/keyboard.c b/src/keyboard.c index aa58e268435..01d7ce9d5e0 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -3150,6 +3150,10 @@ help_char_p (Lisp_Object c) | |||
| 3150 | static void | 3150 | static void |
| 3151 | record_char (Lisp_Object c) | 3151 | record_char (Lisp_Object c) |
| 3152 | { | 3152 | { |
| 3153 | /* quail.el binds this to avoid recording keys twice. */ | ||
| 3154 | if (inhibit_record_char) | ||
| 3155 | return; | ||
| 3156 | |||
| 3153 | int recorded = 0; | 3157 | int recorded = 0; |
| 3154 | 3158 | ||
| 3155 | if (CONSP (c) && (EQ (XCAR (c), Qhelp_echo) || EQ (XCAR (c), Qmouse_movement))) | 3159 | if (CONSP (c) && (EQ (XCAR (c), Qhelp_echo) || EQ (XCAR (c), Qmouse_movement))) |
| @@ -3256,7 +3260,7 @@ record_char (Lisp_Object c) | |||
| 3256 | /* Write c to the dribble file. If c is a lispy event, write | 3260 | /* Write c to the dribble file. If c is a lispy event, write |
| 3257 | the event's symbol to the dribble file, in <brackets>. Bleaugh. | 3261 | the event's symbol to the dribble file, in <brackets>. Bleaugh. |
| 3258 | If you, dear reader, have a better idea, you've got the source. :-) */ | 3262 | If you, dear reader, have a better idea, you've got the source. :-) */ |
| 3259 | if (dribble) | 3263 | if (dribble && NILP (Vexecuting_kbd_macro)) |
| 3260 | { | 3264 | { |
| 3261 | block_input (); | 3265 | block_input (); |
| 3262 | if (INTEGERP (c)) | 3266 | if (INTEGERP (c)) |
| @@ -10110,10 +10114,13 @@ DEFUN ("recursion-depth", Frecursion_depth, Srecursion_depth, 0, 0, 0, | |||
| 10110 | 10114 | ||
| 10111 | DEFUN ("open-dribble-file", Fopen_dribble_file, Sopen_dribble_file, 1, 1, | 10115 | DEFUN ("open-dribble-file", Fopen_dribble_file, Sopen_dribble_file, 1, 1, |
| 10112 | "FOpen dribble file: ", | 10116 | "FOpen dribble file: ", |
| 10113 | doc: /* Start writing all keyboard characters to a dribble file called FILE. | 10117 | doc: /* Start writing input events to a dribble file called FILE. |
| 10114 | If FILE is nil, close any open dribble file. | 10118 | If FILE is nil, close any open dribble file. |
| 10115 | The file will be closed when Emacs exits. | 10119 | The file will be closed when Emacs exits. |
| 10116 | 10120 | ||
| 10121 | The events written to the file include keyboard and mouse input | ||
| 10122 | events, but not events from executing keyboard macros. | ||
| 10123 | |||
| 10117 | Be aware that this records ALL characters you type! | 10124 | Be aware that this records ALL characters you type! |
| 10118 | This may include sensitive information such as passwords. */) | 10125 | This may include sensitive information such as passwords. */) |
| 10119 | (Lisp_Object file) | 10126 | (Lisp_Object file) |
| @@ -11848,6 +11855,14 @@ signals. */); | |||
| 11848 | Vwhile_no_input_ignore_events, | 11855 | Vwhile_no_input_ignore_events, |
| 11849 | doc: /* Ignored events from while-no-input. */); | 11856 | doc: /* Ignored events from while-no-input. */); |
| 11850 | Vwhile_no_input_ignore_events = Qnil; | 11857 | Vwhile_no_input_ignore_events = Qnil; |
| 11858 | |||
| 11859 | DEFVAR_BOOL ("inhibit--record-char", | ||
| 11860 | inhibit_record_char, | ||
| 11861 | doc: /* If non-nil, don't record input events. | ||
| 11862 | This inhibits recording input events for the purposes of keyboard | ||
| 11863 | macros, dribble file, and `recent-keys'. | ||
| 11864 | Internal use only. */); | ||
| 11865 | inhibit_record_char = false; | ||
| 11851 | } | 11866 | } |
| 11852 | 11867 | ||
| 11853 | void | 11868 | void |