Subject: bug#52173: `ś' character not available using `C-x 8'

From: Robert Pluim <[email-masked]>
Date: Mon, 29 Nov 2021 17:52:46 +0100

>>>>> On Mon, 29 Nov 2021 15:55:16 +0000, André A. Gomes <[email-masked]> said:

    André> Robert Pluim <[email-masked]> writes:
    >> What might be more useful is an input-method ring, so
    >> you could quickly switch between 2 or more input methods.

    André> I agree.  It should be easier to go from any 2 input methods defined by
    André> quail.

    André> I will add it to my todo.

A rough cut. Of course this should probably be part of `toggle-input-method'.

diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el
index b922f192a9..4f385d5b79 100644
--- a/lisp/international/mule-cmds.el
+++ b/lisp/international/mule-cmds.el
@@ -1553,6 +1553,35 @@ set-input-method
 (defvar toggle-input-method-active nil
   "Non-nil inside `toggle-input-method'.")
 
+(if dump-mode
+    (load "emacs-lisp/ring")
+  (require 'ring))
+(defvar input-method-ring nil)
+(defun update-input-method-ring (variable value)
+  (when (length> value 0)
+    (dolist (im value)
+      (when (not (assoc (symbol-name im) input-method-alist))
+        (error "%S is not a known input method" im)))
+    (setq input-method-ring (ring-convert-sequence-to-ring value)))
+    (set-default variable value))
+
+(defcustom input-method-list nil
+  "List of input methods to cycle through with `cycle-input-method'."
+  :type '(choice (const nil)
+                 (repeat :tag "List of input methods"
+                         (symbol :tag "Input method")))
+  :group 'mule
+  :set #'update-input-method-ring
+  :version "29.1")
+
+(defun cycle-input-method ()
+  "Cycle through `input-method-ring'."
+  (interactive)
+  (if (and current-input-method
+           (ring-member input-method-ring (intern current-input-method)))
+      (activate-input-method (ring-next input-method-ring (intern current-input-method) ))
+    (activate-input-method (ring-ref input-method-ring 0))))
+
 (defun toggle-input-method (&optional arg interactive)
   "Enable or disable multilingual text input method for the current buffer.
 Only one input method can be enabled at any time in a given buffer.

Robert
--