]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix recording keyboard macros when input method is active
authorEli Zaretskii <eliz@gnu.org>
Sat, 21 Jul 2018 09:10:20 +0000 (12:10 +0300)
committerEli Zaretskii <eliz@gnu.org>
Sat, 21 Jul 2018 09:10:20 +0000 (12:10 +0300)
* 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)

lisp/international/quail.el
src/keyboard.c

index eece836354c241eb4b8ab79f63f82706f1b974ea..ec15ccaaf76116707fb6c654bd8b6c16b2e78c8b 100644 (file)
@@ -1394,12 +1394,13 @@ Return the input string."
             (generated-events nil)     ;FIXME: What is this?
             (input-method-function nil)
             (modified-p (buffer-modified-p))
-            last-command-event last-command this-command)
+            last-command-event last-command this-command inhibit-record)
        (setq quail-current-key ""
              quail-current-str ""
              quail-translating t)
        (if key
-           (setq unread-command-events (cons key unread-command-events)))
+           (setq unread-command-events (cons key unread-command-events)
+                  inhibit-record t))
        (while quail-translating
          (set-buffer-modified-p modified-p)
          (quail-show-guidance)
@@ -1408,8 +1409,13 @@ Return the input string."
                                     (or input-method-previous-message "")
                                     quail-current-str
                                     quail-guidance-str)))
+                 ;; We inhibit record_char only for the first key,
+                 ;; because it was already recorded before read_char
+                 ;; called quail-input-method.
+                 (inhibit--record-char inhibit-record)
                 (keyseq (read-key-sequence prompt nil nil t))
                 (cmd (lookup-key (quail-translation-keymap) keyseq)))
+            (setq inhibit-record nil)
            (if (if key
                    (and (commandp cmd) (not (eq cmd 'quail-other-command)))
                  (eq cmd 'quail-self-insert-command))
@@ -1453,14 +1459,15 @@ Return the input string."
             (generated-events nil)     ;FIXME: What is this?
             (input-method-function nil)
             (modified-p (buffer-modified-p))
-            last-command-event last-command this-command)
+            last-command-event last-command this-command inhibit-record)
        (setq quail-current-key ""
              quail-current-str ""
              quail-translating t
              quail-converting t
              quail-conversion-str "")
        (if key
-           (setq unread-command-events (cons key unread-command-events)))
+           (setq unread-command-events (cons key unread-command-events)
+                  inhibit-record t))
        (while quail-converting
          (set-buffer-modified-p modified-p)
          (or quail-translating
@@ -1476,8 +1483,13 @@ Return the input string."
                                     quail-conversion-str
                                     quail-current-str
                                     quail-guidance-str)))
+                 ;; We inhibit record_char only for the first key,
+                 ;; because it was already recorded before read_char
+                 ;; called quail-input-method.
+                 (inhibit--record-char inhibit-record)
                 (keyseq (read-key-sequence prompt nil nil t))
                 (cmd (lookup-key (quail-conversion-keymap) keyseq)))
+            (setq inhibit-record nil)
            (if (if key (commandp cmd) (eq cmd 'quail-self-insert-command))
                (progn
                  (setq last-command-event (aref keyseq (1- (length keyseq)))
index aa58e268435acb3846503a193b51c9841b60638b..01d7ce9d5e02c1e8cb7e430f52b54e14cb7fc314 100644 (file)
@@ -3150,6 +3150,10 @@ help_char_p (Lisp_Object c)
 static void
 record_char (Lisp_Object c)
 {
+  /* quail.el binds this to avoid recording keys twice.  */
+  if (inhibit_record_char)
+    return;
+
   int recorded = 0;
 
   if (CONSP (c) && (EQ (XCAR (c), Qhelp_echo) || EQ (XCAR (c), Qmouse_movement)))
@@ -3256,7 +3260,7 @@ record_char (Lisp_Object c)
   /* Write c to the dribble file.  If c is a lispy event, write
      the event's symbol to the dribble file, in <brackets>.  Bleaugh.
      If you, dear reader, have a better idea, you've got the source.  :-) */
-  if (dribble)
+  if (dribble && NILP (Vexecuting_kbd_macro))
     {
       block_input ();
       if (INTEGERP (c))
@@ -10110,10 +10114,13 @@ DEFUN ("recursion-depth", Frecursion_depth, Srecursion_depth, 0, 0, 0,
 
 DEFUN ("open-dribble-file", Fopen_dribble_file, Sopen_dribble_file, 1, 1,
        "FOpen dribble file: ",
-       doc: /* Start writing all keyboard characters to a dribble file called FILE.
+       doc: /* Start writing input events to a dribble file called FILE.
 If FILE is nil, close any open dribble file.
 The file will be closed when Emacs exits.
 
+The events written to the file include keyboard and mouse input
+events, but not events from executing keyboard macros.
+
 Be aware that this records ALL characters you type!
 This may include sensitive information such as passwords.  */)
   (Lisp_Object file)
@@ -11848,6 +11855,14 @@ signals.  */);
                Vwhile_no_input_ignore_events,
                doc: /* Ignored events from while-no-input.  */);
   Vwhile_no_input_ignore_events = Qnil;
+
+  DEFVAR_BOOL ("inhibit--record-char",
+              inhibit_record_char,
+              doc: /* If non-nil, don't record input events.
+This inhibits recording input events for the purposes of keyboard
+macros, dribble file, and `recent-keys'.
+Internal use only.  */);
+  inhibit_record_char = false;
 }
 
 void