all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Gregory Heytings <gregory@heytings.org>
To: harven@free.fr
Cc: 48042@debbugs.gnu.org
Subject: bug#48042: 26.3; Macros don't work with french-postfix input method
Date: Fri, 14 May 2021 09:29:08 +0000	[thread overview]
Message-ID: <425cd7715bc9fae8b39a@heytings.org> (raw)
In-Reply-To: <86pmyghqf1.fsf@upmc.fr>

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


This was an interesting bug.  Let's first define a recipe to make it more 
apparent:

C-x C-m C-\ french-postfix RET C-x ( pa^te'_a`_l'Unicode RET C-x ) C-x e

This should insert "pâté_à_l'Unicode".  It worked as expected with Emacs 
21-24.

After commit 30a6b1f814, which was the result of the discussion in 
http://lists.gnu.org/archive/html/emacs-devel/2015-08/msg00193.html , and 
before commit 03e3440dbb, it inserts "paâtteé__aà__l'UUnniiccocododee". 
This is what one gets in Emacs 25 and 26.  This is not surprising, as the 
recipe in that discussion and quail.el both use unread-command-events, but 
expect an opposite effect.

After commit 03e3440dbb, which was the result of bug#32108, it inserts 
"pâtté__à__l'Unnicocdode".  This is what one gets in Emacs 27 (and 28 till 
now).

I attach a patch to fix that bug.  I checked that the recipes that led to 
the two above commits still work correctly, and that it does not introduce 
regressions with make check.

Note that the inhibit--record-char variable, which was introduced by 
commit 03e3440dbb, is, after applying that patch, only used once, namely 
in lisp/term/xterm.el, as a result of bug#44908.  It is not used in ELPA 
or MELPA.  I'm not convinced that bug#44908 is a sufficient reason to keep 
that variable.

[-- Attachment #2: Type: text/x-diff, Size: 4616 bytes --]

From 359a644498df85a1b063bfb0aace3df34adac3e0 Mon Sep 17 00:00:00 2001
From: Gregory Heytings <gregory@heytings.org>
Date: Fri, 14 May 2021 09:20:03 +0000
Subject: [PATCH] Fix input method bug when recording keyboard macros

* src/keyboard.c (read_char): Do not record character again when
defining a keyboard macro with an input method activated (Bug#48042).
(record_char): Partly revert 03e3440dbb.

* lisp/international/quail.el (quail-start-translation,
quail-start-conversion): Partly revert 03e3440dbb.
---
 lisp/international/quail.el | 20 ++++----------------
 src/keyboard.c              |  7 +++++--
 2 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/lisp/international/quail.el b/lisp/international/quail.el
index fff06deee8..6c2088a95b 100644
--- a/lisp/international/quail.el
+++ b/lisp/international/quail.el
@@ -1385,13 +1385,12 @@ quail-start-translation
 	     ;; (generated-events nil)     ;FIXME: What is this?
 	     (input-method-function nil)
 	     (modified-p (buffer-modified-p))
-	     last-command-event last-command this-command inhibit-record)
+	     last-command-event last-command this-command)
 	(setq quail-current-key ""
 	      quail-current-str ""
 	      quail-translating t)
 	(if key
-	    (setq unread-command-events (cons key unread-command-events)
-                  inhibit-record t))
+	    (setq unread-command-events (cons key unread-command-events)))
 	(while quail-translating
 	  (set-buffer-modified-p modified-p)
 	  (quail-show-guidance)
@@ -1400,13 +1399,8 @@ quail-start-translation
 				     (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))
@@ -1450,15 +1444,14 @@ quail-start-conversion
 	     ;; (generated-events nil)     ;FIXME: What is this?
 	     (input-method-function nil)
 	     (modified-p (buffer-modified-p))
-	     last-command-event last-command this-command inhibit-record)
+	     last-command-event last-command this-command)
 	(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)
-                  inhibit-record t))
+	    (setq unread-command-events (cons key unread-command-events)))
 	(while quail-converting
 	  (set-buffer-modified-p modified-p)
 	  (or quail-translating
@@ -1474,13 +1467,8 @@ quail-start-conversion
 				     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)))
diff --git a/src/keyboard.c b/src/keyboard.c
index 47b5e59024..f72c0870fe 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -3098,7 +3098,11 @@ read_char (int commandflag, Lisp_Object map,
   /* When we consume events from the various unread-*-events lists, we
      bypass the code that records input, so record these events now if
      they were not recorded already.  */
-  if (!recorded)
+  if (!recorded &&
+      /* However, don't record events when a keyboard macro is being
+         defined and an input method is activated (Bug#48042).  */
+      ! (! NILP (KVAR (current_kboard, defining_kbd_macro)) &&
+         ! NILP (Fsymbol_value (Qcurrent_input_method))))
     {
       record_char (c);
       recorded = true;
@@ -3233,7 +3237,6 @@ 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;
 
-- 
2.30.2


  parent reply	other threads:[~2021-05-14  9:29 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-26 18:05 bug#48042: 26.3; Macros don't work with french-postfix input method harven
2021-04-26 18:22 ` Eli Zaretskii
2021-04-28 18:24 ` harven
2021-05-14  9:29 ` Gregory Heytings [this message]
2021-05-14  9:55   ` Basil L. Contovounesios
2021-05-14 10:03     ` Gregory Heytings
2021-05-14 11:09   ` Eli Zaretskii
2021-05-14 13:38     ` Gregory Heytings
2021-05-14 13:54       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-05-14 14:08         ` Gregory Heytings
2021-05-14 14:12           ` Eli Zaretskii
2021-05-14 14:04       ` Eli Zaretskii
2021-05-14 14:16         ` Gregory Heytings
2021-05-14 14:36           ` Eli Zaretskii
2021-05-14 15:00             ` Gregory Heytings
2021-05-14 15:11               ` Eli Zaretskii
2021-05-14 15:51             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-05-14 15:59               ` Eli Zaretskii
2021-05-14 17:07               ` Gregory Heytings
2021-05-14 17:13                 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-05-15  9:46                   ` Gregory Heytings
2021-05-15 10:21                     ` Eli Zaretskii
2021-05-15 18:47                       ` Gregory Heytings
2021-05-15 18:52                         ` Eli Zaretskii
2021-05-15 20:17                           ` Gregory Heytings
2021-05-29  8:20                             ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=425cd7715bc9fae8b39a@heytings.org \
    --to=gregory@heytings.org \
    --cc=48042@debbugs.gnu.org \
    --cc=harven@free.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.