all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Jean Louis <bugs@gnu.support>
Cc: 45005@debbugs.gnu.org
Subject: bug#45005: 28.0.50; input method does not switch back
Date: Tue, 08 Dec 2020 10:43:48 +0200	[thread overview]
Message-ID: <87v9dc6557.fsf@mail.linkov.net> (raw)
In-Reply-To: <courier.000000005FC77150.000065C9@static.rcdrun.com> (Jean Louis's message of "Wed, 02 Dec 2020 13:49:50 +0300")

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

tags 45005 + patch
quit

> This is report for which I do not think that it is reproducible as I
> tried to invoke it with emacs -Q and I would need to perform some work
> from which I could not find out what invokes the bug.
>
> My other input method is by default set to german-postfix.
>
> My Emacs uptime now is about 1 day, 15 hours. About 15 hours ago, I
> could observe that I cannot turn off the input method with C-\ but
> that it remains engaged.
>
> Mode line may show DE<U: and when I press C-\ it shows U: but again I
> can write ü ö ä and some words in other languages collide. I am using
> other few input methods for other languages, then it becomes difficult
> writing English as some combinations of letters get converted in other
> letters, then I have to delete, etc. If I make new session it will of
> course be alright. For my last 5 years I have not encountered this
> situation that input-method kind of remains turned on even if I turn
> it off.

This problem can happen only when the default global value of
input-method-function is changed, so it still translates keys
while the input method is disabled.

When an input method is activated, 'quail-activate' uses

  (setq-local input-method-function #'quail-input-method)

to set the buffer-local value, and when an input method is deactivated,
removes the buffer-local value:

  (kill-local-variable 'input-method-function)

So it doesn't change its default global value.

The only place on the whole Emacs tree that can change the
default global value of input-method-function is 'isearch-done':

  (if isearch-input-method-local-p
      (setq input-method-function isearch-input-method-function)
     (kill-local-variable 'input-method-function))

Many functions in international/isearch-x.el set isearch-input-method-local-p
to 't', but never set it to 'nil'.  So when after using an input method
in Isearch (enabling and disabling it) on exiting Isearch, this code
always changes the default global value of input-method-function.

Instead of this, this code should use the same logic as used by
'quail-activate': when a previous input method should be re-activated,
then set its buffer-local value, otherwise use kill-local-variable.

This logic will obsolete the variable isearch-input-method-local-p:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: isearch-input-method-local-p.patch --]
[-- Type: text/x-diff, Size: 4148 bytes --]

diff --git a/lisp/isearch.el b/lisp/isearch.el
index a0aa250c4b..69c553deda 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -965,10 +965,6 @@ isearch-hidden
 ;; The value of input-method-function when isearch is invoked.
 (defvar isearch-input-method-function nil)
 
-;; A flag to tell if input-method-function is locally bound when
-;; isearch is invoked.
-(defvar isearch-input-method-local-p nil)
-
 (defvar isearch--saved-overriding-local-map nil)
 
 ;; Minor-mode-alist changes - kind of redundant with the
@@ -1238,7 +1234,6 @@ isearch-mode
 	search-ring-yank-pointer nil
 	isearch-opened-overlays nil
 	isearch-input-method-function input-method-function
-	isearch-input-method-local-p (local-variable-p 'input-method-function)
 	regexp-search-ring-yank-pointer nil
 
 	isearch-pre-scroll-point nil
@@ -1259,8 +1254,6 @@ isearch-mode
   ;; We must bypass input method while reading key.  When a user type
   ;; printable character, appropriate input method is turned on in
   ;; minibuffer to read multibyte characters.
-  (or isearch-input-method-local-p
-      (make-local-variable 'input-method-function))
   (setq input-method-function nil)
 
   (looking-at "")
@@ -1418,8 +1411,8 @@ isearch-done
 	(set-window-group-start (selected-window) found-start t))))
 
   (setq isearch-mode nil)
-  (if isearch-input-method-local-p
-      (setq input-method-function isearch-input-method-function)
+  (if isearch-input-method-function
+      (setq-local input-method-function isearch-input-method-function)
     (kill-local-variable 'input-method-function))
 
   (if isearch-tool-bar-old-map
diff --git a/lisp/international/isearch-x.el b/lisp/international/isearch-x.el
index f50f86a035..94716721b5 100644
--- a/lisp/international/isearch-x.el
+++ b/lisp/international/isearch-x.el
@@ -35,8 +35,7 @@ isearch-toggle-specified-input-method
   (interactive)
   (let ((overriding-terminal-local-map nil))
     (toggle-input-method t))
-  (setq isearch-input-method-function input-method-function
-	isearch-input-method-local-p t)
+  (setq isearch-input-method-function input-method-function)
   (setq input-method-function nil)
   (isearch-update))
 
@@ -46,8 +45,7 @@ isearch-toggle-input-method
   (interactive)
   (let ((overriding-terminal-local-map nil))
     (toggle-input-method))
-  (setq isearch-input-method-function input-method-function
-	isearch-input-method-local-p t)
+  (setq isearch-input-method-function input-method-function)
   (setq input-method-function nil)
   (isearch-update))
 
@@ -57,8 +55,7 @@ isearch-transient-input-method
   (interactive)
   (let ((overriding-terminal-local-map nil))
     (activate-transient-input-method))
-  (setq isearch-input-method-function input-method-function
-	isearch-input-method-local-p t)
+  (setq isearch-input-method-function input-method-function)
   (setq input-method-function nil)
   (isearch-update))
 
diff --git a/lisp/language/korea-util.el b/lisp/language/korea-util.el
index 3821785da7..13cd6a015d 100644
--- a/lisp/language/korea-util.el
+++ b/lisp/language/korea-util.el
@@ -70,8 +70,7 @@ isearch-toggle-korean-input-method
   (interactive)
   (let ((overriding-terminal-local-map nil))
     (toggle-korean-input-method))
-  (setq isearch-input-method-function input-method-function
-	isearch-input-method-local-p t)
+  (setq isearch-input-method-function input-method-function)
   (setq input-method-function nil)
   (isearch-update))
 
@@ -79,8 +78,7 @@ isearch-hangul-switch-symbol-ksc
   (interactive)
   (let ((overriding-terminal-local-map nil))
     (quail-hangul-switch-symbol-ksc))
-  (setq isearch-input-method-function input-method-function
-	isearch-input-method-local-p t)
+  (setq isearch-input-method-function input-method-function)
   (setq input-method-function nil)
   (isearch-update))
 
@@ -88,8 +86,7 @@ isearch-hangul-switch-hanja
   (interactive)
   (let ((overriding-terminal-local-map nil))
     (quail-hangul-switch-hanja))
-  (setq isearch-input-method-function input-method-function
-	isearch-input-method-local-p t)
+  (setq isearch-input-method-function input-method-function)
   (setq input-method-function nil)
   (isearch-update))
 

  reply	other threads:[~2020-12-08  8:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-02 10:49 bug#45005: 28.0.50; input method does not switch back Jean Louis
2020-12-08  8:43 ` Juri Linkov [this message]
2020-12-08 10:10   ` Jean Louis
2020-12-08 19:18     ` Juri Linkov
2020-12-09 19:31   ` Juri Linkov

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=87v9dc6557.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=45005@debbugs.gnu.org \
    --cc=bugs@gnu.support \
    /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.