unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#45292: 28.0.50; first key typed ignores current input method (in magit commit buffer)
@ 2020-12-17 12:52 Platon Pronko
       [not found] ` <handler.45292.B.16082095764744.ack@debbugs.gnu.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Platon Pronko @ 2020-12-17 12:52 UTC (permalink / raw)
  To: 45292; +Cc: monnier

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))






^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#45292: Acknowledgement (28.0.50; first key typed ignores current input method (in magit commit buffer))
       [not found] ` <handler.45292.B.16082095764744.ack@debbugs.gnu.org>
@ 2020-12-17 13:45   ` Platon Pronko
  2020-12-17 16:31     ` Platon Pronko
  0 siblings, 1 reply; 6+ messages in thread
From: Platon Pronko @ 2020-12-17 13:45 UTC (permalink / raw)
  To: 45292

Seems that removal of record_asynch_buffer_change() at the end of read_and_dispose_of_process_output() causes the issue.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#45292: Acknowledgement (28.0.50; first key typed ignores current input method (in magit commit buffer))
  2020-12-17 13:45   ` bug#45292: Acknowledgement (28.0.50; first key typed ignores current input method (in magit commit buffer)) Platon Pronko
@ 2020-12-17 16:31     ` Platon Pronko
  2020-12-23 23:32       ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Platon Pronko @ 2020-12-17 16:31 UTC (permalink / raw)
  To: 45292

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.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#45292: Acknowledgement (28.0.50; first key typed ignores current input method (in magit commit buffer))
  2020-12-17 16:31     ` Platon Pronko
@ 2020-12-23 23:32       ` Stefan Monnier
  2020-12-24  7:26         ` Platon Pronko
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2020-12-23 23:32 UTC (permalink / raw)
  To: Platon Pronko; +Cc: 45292

> 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;
 }
 






^ permalink raw reply related	[flat|nested] 6+ messages in thread

* bug#45292: Acknowledgement (28.0.50; first key typed ignores current input method (in magit commit buffer))
  2020-12-23 23:32       ` Stefan Monnier
@ 2020-12-24  7:26         ` Platon Pronko
  2021-04-04  1:00           ` bug#45292: 28.0.50; first key typed ignores current input method (in magit commit buffer) Stefan Kangas
  0 siblings, 1 reply; 6+ messages in thread
From: Platon Pronko @ 2020-12-24  7:26 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 45292

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





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#45292: 28.0.50; first key typed ignores current input method (in magit commit buffer)
  2020-12-24  7:26         ` Platon Pronko
@ 2021-04-04  1:00           ` Stefan Kangas
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Kangas @ 2021-04-04  1:00 UTC (permalink / raw)
  To: Platon Pronko; +Cc: Stefan Monnier, 45292-done

Platon Pronko <platon7pronko@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.





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-04-04  1:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-17 12:52 bug#45292: 28.0.50; first key typed ignores current input method (in magit commit buffer) Platon Pronko
     [not found] ` <handler.45292.B.16082095764744.ack@debbugs.gnu.org>
2020-12-17 13:45   ` bug#45292: Acknowledgement (28.0.50; first key typed ignores current input method (in magit commit buffer)) Platon Pronko
2020-12-17 16:31     ` Platon Pronko
2020-12-23 23:32       ` Stefan Monnier
2020-12-24  7:26         ` Platon Pronko
2021-04-04  1:00           ` bug#45292: 28.0.50; first key typed ignores current input method (in magit commit buffer) Stefan Kangas

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).