GNU bug report logs - #45292
28.0.50; first key typed ignores current input method (in magit commit buffer)

Previous Next

Package: emacs;

Reported by: Platon Pronko <platon7pronko <at> gmail.com>

Date: Thu, 17 Dec 2020 12:53:01 UTC

Severity: normal

Found in version 28.0.50

Done: Stefan Kangas <stefan <at> marxist.se>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 45292 in the body.
You can then email your comments to 45292 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#45292; Package emacs. (Thu, 17 Dec 2020 12:53:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Platon Pronko <platon7pronko <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 17 Dec 2020 12:53:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Platon Pronko <platon7pronko <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Cc: monnier <at> iro.umontreal.ca
Subject: 28.0.50; first key typed ignores current input method (in magit
 commit buffer)
Date: Thu, 17 Dec 2020 15:52:41 +0300
Minimal init.el for problem reproduction:

(define-minor-mode dvorak-minor-mode "Use english-dvorak input method." :lighter nil
  (if dvorak-minor-mode (activate-input-method "english-dvorak")))
(define-global-minor-mode global-dvorak-mode dvorak-minor-mode dvorak-minor-mode)
(global-dvorak-mode t)

(require 'magit)
(global-set-key (kbd "C-x g") 'magit-status)

I do not know how to make elpa packages load under -Q, unfortunately.

Steps to reproduce:
1. Set up a git repository with a staged change (mkdir test-repo; cd test-repo; git init; touch a; git add a);
2. Launch emacs (GUI) in this directory;
3. Type "C-x g" (or execute magit-status);
4. Type "c c" to open commit buffer;
5. Type "j j" (or any two characters that are different between english and english-dvorak input methods);
6. Observe that inserted characters are different - first one uses the default input method ("j") and second one uses the configured one ("h").

I bisected the problem and found that it was introduced in commit adbb4eacc (on 2020-12-12, by Stefan Monnier).

I'll try looking into the cause now, but will appreciate any pointers (it seems to be touching keyboard.c, and I remember it to be very complex).



In GNU Emacs 28.0.50 (build 14, x86_64-pc-linux-gnu, GTK+ Version 3.24.24, cairo version 1.17.4)
 of 2020-12-17 built on the-big-maker
Repository revision: adbb4eacc2a984c0fc0b65ec761368fd9067d6c5
Repository branch: HEAD
Windowing system distributor 'The X.Org Foundation', version 11.0.12010000
System Description: Arch Linux

Configured using:
 'configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
 --localstatedir=/var --mandir=/usr/share/man --with-gameuser=:games
 --with-sound=alsa --with-modules --without-gconf --without-gsettings
 --with-x-toolkit=gtk3 --without-xaw3d'

Configured features:
XPM JPEG TIFF GIF PNG RSVG CAIRO SOUND GPM DBUS GLIB NOTIFY INOTIFY ACL
GNUTLS LIBXML2 FREETYPE HARFBUZZ M17N_FLT LIBOTF ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS LIBSYSTEMD JSON
PDUMPER LCMS2

Important settings:
  value of $LC_TIME: en_SE.UTF-8
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: SQL[ANSI]

Minor modes in effect:
  magit-auto-revert-mode: t
  auto-revert-mode: t
  global-git-commit-mode: t
  async-bytecomp-package-mode: t
  shell-dirtrack-mode: t
  global-dvorak-mode: t
  dvorak-minor-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
/home/platon/.emacs.d/elpa/lispy-20201109.1728/elpa hides /home/platon/.emacs.d/elpa/ivy-20201214.2049/elpa
/home/platon/.emacs.d/elpa/cider-20201210.1748/cider-ns hides /usr/share/emacs/site-lisp/cider-ns
/home/platon/.emacs.d/elpa/cider-20201210.1748/cider-classpath hides /usr/share/emacs/site-lisp/cider-classpath
/home/platon/.emacs.d/elpa/cider-20201210.1748/cider-stacktrace hides /usr/share/emacs/site-lisp/cider-stacktrace
/home/platon/.emacs.d/elpa/cider-20201210.1748/cider-clojuredocs hides /usr/share/emacs/site-lisp/cider-clojuredocs
/home/platon/.emacs.d/elpa/cider-20201210.1748/cider-doc hides /usr/share/emacs/site-lisp/cider-doc
/home/platon/.emacs.d/elpa/cider-20201210.1748/cider hides /usr/share/emacs/site-lisp/cider
/home/platon/.emacs.d/elpa/parseclj-20201012.712/parseclj-ast hides /usr/share/emacs/site-lisp/parseclj-ast
/home/platon/.emacs.d/elpa/cider-20201210.1748/cider-connection hides /usr/share/emacs/site-lisp/cider-connection
/home/platon/.emacs.d/elpa/cider-20201210.1748/nrepl-client hides /usr/share/emacs/site-lisp/nrepl-client
/home/platon/.emacs.d/elpa/cider-20201210.1748/cider-popup hides /usr/share/emacs/site-lisp/cider-popup
/home/platon/.emacs.d/elpa/parseedn-20200419.1124/parseedn hides /usr/share/emacs/site-lisp/parseedn
/home/platon/.emacs.d/elpa/cider-20201210.1748/cider-cheatsheet hides /usr/share/emacs/site-lisp/cider-cheatsheet
/home/platon/.emacs.d/elpa/cider-20201210.1748/cider-debug hides /usr/share/emacs/site-lisp/cider-debug
/home/platon/.emacs.d/elpa/cider-20201210.1748/cider-completion hides /usr/share/emacs/site-lisp/cider-completion
/home/platon/.emacs.d/elpa/cider-20201210.1748/cider-eval hides /usr/share/emacs/site-lisp/cider-eval
/home/platon/.emacs.d/elpa/cider-20201210.1748/cider-repl hides /usr/share/emacs/site-lisp/cider-repl
/home/platon/.emacs.d/elpa/cider-20201210.1748/cider-inspector hides /usr/share/emacs/site-lisp/cider-inspector
/home/platon/.emacs.d/elpa/parseclj-20201012.712/parseclj hides /usr/share/emacs/site-lisp/parseclj
/home/platon/.emacs.d/elpa/cider-20201210.1748/cider-util hides /usr/share/emacs/site-lisp/cider-util
/home/platon/.emacs.d/elpa/cider-20201210.1748/cider-eldoc hides /usr/share/emacs/site-lisp/cider-eldoc
/home/platon/.emacs.d/elpa/parseclj-20201012.712/parseclj-parser hides /usr/share/emacs/site-lisp/parseclj-parser
/home/platon/.emacs.d/elpa/cider-20201210.1748/cider-browse-ns hides /usr/share/emacs/site-lisp/cider-browse-ns
/home/platon/.emacs.d/elpa/cider-20201210.1748/cider-macroexpansion hides /usr/share/emacs/site-lisp/cider-macroexpansion
/home/platon/.emacs.d/elpa/cider-20201210.1748/cider-resolve hides /usr/share/emacs/site-lisp/cider-resolve
/home/platon/.emacs.d/elpa/cider-20201210.1748/cider-compat hides /usr/share/emacs/site-lisp/cider-compat
/home/platon/.emacs.d/elpa/cider-20201210.1748/cider-format hides /usr/share/emacs/site-lisp/cider-format
/home/platon/.emacs.d/elpa/cider-20201210.1748/cider-common hides /usr/share/emacs/site-lisp/cider-common
/home/platon/.emacs.d/elpa/a-20201203.1927/a hides /usr/share/emacs/site-lisp/a
/home/platon/.emacs.d/elpa/cider-20201210.1748/cider-profile hides /usr/share/emacs/site-lisp/cider-profile
/home/platon/.emacs.d/elpa/cider-20201210.1748/cider-selector hides /usr/share/emacs/site-lisp/cider-selector
/home/platon/.emacs.d/elpa/cider-20201210.1748/cider-client hides /usr/share/emacs/site-lisp/cider-client
/home/platon/.emacs.d/elpa/cider-20201210.1748/cider-scratch hides /usr/share/emacs/site-lisp/cider-scratch
/home/platon/.emacs.d/elpa/cider-20201210.1748/cider-repl-history hides /usr/share/emacs/site-lisp/cider-repl-history
/home/platon/.emacs.d/elpa/cider-20201210.1748/cider-find hides /usr/share/emacs/site-lisp/cider-find
/home/platon/.emacs.d/elpa/cider-20201210.1748/cider-test hides /usr/share/emacs/site-lisp/cider-test
/home/platon/.emacs.d/elpa/cider-20201210.1748/nrepl-dict hides /usr/share/emacs/site-lisp/nrepl-dict
/home/platon/.emacs.d/elpa/cider-20201210.1748/cider-overlays hides /usr/share/emacs/site-lisp/cider-overlays
/home/platon/.emacs.d/elpa/protobuf-mode-20200619.1742/protobuf-mode hides /usr/share/emacs/site-lisp/protobuf-mode
/home/platon/.emacs.d/elpa/parseclj-20201012.712/parseclj-lex hides /usr/share/emacs/site-lisp/parseclj-lex
/home/platon/.emacs.d/elpa/cider-20201210.1748/cider-mode hides /usr/share/emacs/site-lisp/cider-mode
/home/platon/.emacs.d/elpa/cider-20201210.1748/cider-xref hides /usr/share/emacs/site-lisp/cider-xref
/home/platon/.emacs.d/elpa/cider-20201210.1748/cider-apropos hides /usr/share/emacs/site-lisp/cider-apropos
/home/platon/.emacs.d/elpa/cider-20201210.1748/cider-browse-spec hides /usr/share/emacs/site-lisp/cider-browse-spec
/home/platon/.emacs.d/elpa/cider-20201210.1748/cider-tracing hides /usr/share/emacs/site-lisp/cider-tracing
/home/platon/.emacs.d/elpa/clojure-mode-20201126.1558/clojure-mode hides /usr/share/emacs/site-lisp/clojure-mode
/home/platon/.emacs.d/elpa/epl-20180205.2049/epl hides /usr/share/emacs/site-lisp/epl/epl
/home/platon/.emacs.d/elpa/pkg-info-20150517.1143/pkg-info hides /usr/share/emacs/site-lisp/pkg-info/pkg-info
/home/platon/.emacs.d/elpa/queue-0.2/queue hides /usr/share/emacs/site-lisp/queue/queue
/home/platon/.emacs.d/elpa/sesman-20190909.1754/sesman-browser hides /usr/share/emacs/site-lisp/sesman/sesman-browser
/home/platon/.emacs.d/elpa/sesman-20190909.1754/sesman hides /usr/share/emacs/site-lisp/sesman/sesman
/home/platon/.emacs.d/elpa/spinner-1.7.3/spinner hides /usr/share/emacs/site-lisp/spinner/spinner
/home/platon/.emacs.d/elpa/less-css-mode-20161001.453/less-css-mode hides /home/platon/sync/sources/emacs/lisp/textmodes/less-css-mode

Features:
(shadow sort mail-extr emacsbug sendmail vc-git sql view thingatpt
edmacro kmacro magit-submodule magit-obsolete magit-blame magit-stash
magit-reflog magit-bisect magit-push magit-pull magit-fetch magit-clone
magit-remote magit-commit magit-sequence magit-notes magit-worktree
magit-tag magit-merge magit-branch magit-reset magit-files magit-refs
magit-status magit magit-repos magit-apply magit-wip magit-log
which-func imenu magit-diff smerge-mode diff diff-mode magit-core
magit-autorevert autorevert filenotify magit-margin magit-transient
magit-process magit-mode git-commit transient format-spec magit-git
magit-section magit-utils crm log-edit message rmc puny dired
dired-loaddefs rfc822 mml mml-sec epa derived epg epg-config gnus-util
rmail rmail-loaddefs text-property-search time-date mm-decode mm-bodies
mm-encode mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums
mail-prsvr mailabbrev mail-utils gmm-utils mailheader pcvs-util add-log
with-editor cl-extra async-bytecomp advice async shell pcomplete comint
ansi-color ring server dash quail help-mode easy-mmode info package
easymenu browse-url url url-proxy url-privacy url-expand url-methods
url-history url-cookie url-domsuf url-util mailcap url-handlers
url-parse auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs
password-cache json subr-x map url-vars seq byte-opt gv bytecomp
byte-compile cconv cl-loaddefs cl-lib iso-transl tooltip eldoc electric
uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch timer
select scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite charscript charprop case-table epa-hook
jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button
loaddefs faces cus-face macroexp files window text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote threads dbusbind inotify lcms2
dynamic-setting font-render-setting cairo move-toolbar gtk x-toolkit x
multi-tty make-network-process emacs)

Memory information:
((conses 16 142677 11960)
 (symbols 48 14644 1)
 (strings 32 51220 3154)
 (string-bytes 1 1720184)
 (vectors 16 28209)
 (vector-slots 8 323827 18562)
 (floats 8 68 156)
 (intervals 56 377 0)
 (buffers 984 14))





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45292; Package emacs. (Thu, 17 Dec 2020 13:47:01 GMT) Full text and rfc822 format available.

Message #8 received at 45292 <at> debbugs.gnu.org (full text, mbox):

From: Platon Pronko <platon7pronko <at> gmail.com>
To: 45292 <at> debbugs.gnu.org
Subject: Re: bug#45292: Acknowledgement (28.0.50; first key typed ignores
 current input method (in magit commit buffer))
Date: Thu, 17 Dec 2020 16:45:53 +0300
Seems that removal of record_asynch_buffer_change() at the end of read_and_dispose_of_process_output() causes the issue.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45292; Package emacs. (Thu, 17 Dec 2020 16:33:01 GMT) Full text and rfc822 format available.

Message #11 received at 45292 <at> debbugs.gnu.org (full text, mbox):

From: Platon Pronko <platon7pronko <at> gmail.com>
To: 45292 <at> debbugs.gnu.org
Subject: Re: bug#45292: Acknowledgement (28.0.50; first key typed ignores
 current input method (in magit commit buffer))
Date: Thu, 17 Dec 2020 19:31:57 +0300
Digged into it further. Here's what I found:

1. quail-input-method is used to translate keys according current keymap.

2. At the time of the first keystroke ("j" in my example) quail-input-method sees incorrect buffer (verified this by calling and printing buffer-name from inside quail-input-method). It sees "magit: test-repo" on the first keystroke, and "COMMIT_EDITMSG" on subsequent keystrokes. And since "magit: test-repo" is read-only, no translation is done and key is returned as-is.

3. So apparently record_asynch_buffer_change() was crucial to update the current buffer.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45292; Package emacs. (Wed, 23 Dec 2020 23:33:02 GMT) Full text and rfc822 format available.

Message #14 received at 45292 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Platon Pronko <platon7pronko <at> gmail.com>
Cc: 45292 <at> debbugs.gnu.org
Subject: Re: bug#45292: Acknowledgement (28.0.50; first key typed ignores
 current input method (in magit commit buffer))
Date: Wed, 23 Dec 2020 18:32:20 -0500
> Digged into it further. Here's what I found:
>
> 1. quail-input-method is used to translate keys according current keymap.
>
> 2. At the time of the first keystroke ("j" in my example) quail-input-method
> sees incorrect buffer (verified this by calling and printing buffer-name
> from inside quail-input-method). It sees "magit: test-repo" on the first
> keystroke, and "COMMIT_EDITMSG" on subsequent keystrokes. And since "magit:
> test-repo" is read-only, no translation is done and key is returned as-is.
>
> 3. So apparently record_asynch_buffer_change() was crucial to update the current buffer.

Here's what's happening:
1- after hitting `c c`, Magit launches `git` in the background
2- at this point we're entering `read_char` and the current buffer is the
   Magit buffer.
3- soon after, git launches the editor, which Magit has set to emacsclient
4- emacsclient contacts us
5- while still in `read_char` is waiting in `sit_for`, we process
   emacsclient which sets up the git-commit buffer,
   displays it and select it as the main window.
6- `sit_for` carefully preserves the current buffer so after step 5,
   we're still in the Magit buffer even though the selected windows is
   not the git-commit one.
7- we hit `j` in the git-commit buffer/window but it's read while in
   cvs-commit
8- boom!

I installed the patch below which fixes this problem.


        Stefan


diff --git a/src/dispnew.c b/src/dispnew.c
index bcea26a66a..534002584e 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -6062,6 +6062,8 @@ sit_for (Lisp_Object timeout, bool reading, int display_option)
   intmax_t sec;
   int nsec;
   bool do_display = display_option > 0;
+  bool curbuf_eq_winbuf
+    = (current_buffer == XBUFFER (XWINDOW (selected_window)->contents));
 
   swallow_events (do_display);
 
@@ -6116,6 +6118,13 @@ sit_for (Lisp_Object timeout, bool reading, int display_option)
   wait_reading_process_output (sec, nsec, reading ? -1 : 1, do_display,
 			       Qnil, NULL, 0);
 
+  if (reading && curbuf_eq_winbuf)
+    /* Timers and process filters/sentinels may have changed the selected
+       window (e.g. in response to a connection from emacsclient), in which
+       case we should follow it (unless we weren't in the selected-window's
+       buffer to start with).  */
+    set_buffer_internal (XBUFFER (XWINDOW (selected_window)->contents));
+
   return detect_input_pending () ? Qnil : Qt;
 }
 





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45292; Package emacs. (Thu, 24 Dec 2020 07:27:02 GMT) Full text and rfc822 format available.

Message #17 received at 45292 <at> debbugs.gnu.org (full text, mbox):

From: Platon Pronko <platon7pronko <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 45292 <at> debbugs.gnu.org
Subject: Re: bug#45292: Acknowledgement (28.0.50; first key typed ignores
 current input method (in magit commit buffer))
Date: Thu, 24 Dec 2020 10:26:14 +0300
Thank you! Tested the version with the patch - the problem doesn't appear anymore on my machine.




Reply sent to Stefan Kangas <stefan <at> marxist.se>:
You have taken responsibility. (Sun, 04 Apr 2021 01:02:02 GMT) Full text and rfc822 format available.

Notification sent to Platon Pronko <platon7pronko <at> gmail.com>:
bug acknowledged by developer. (Sun, 04 Apr 2021 01:02:02 GMT) Full text and rfc822 format available.

Message #22 received at 45292-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: Platon Pronko <platon7pronko <at> gmail.com>
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, 45292-done <at> debbugs.gnu.org
Subject: Re: bug#45292: 28.0.50; first key typed ignores current input method
 (in magit commit buffer)
Date: Sat, 3 Apr 2021 20:00:57 -0500
Platon Pronko <platon7pronko <at> gmail.com> writes:

> Thank you! Tested the version with the patch - the problem doesn't appear anymore on my machine.

I'm therefore closing this bug report.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 02 May 2021 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 360 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.