[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 030ab2d: Transient input methods bound to 'C-x \' (bug#44266)
From: |
Juri Linkov |
Subject: |
master 030ab2d: Transient input methods bound to 'C-x \' (bug#44266) |
Date: |
Sun, 1 Nov 2020 16:35:52 -0500 (EST) |
branch: master
commit 030ab2dad50a448bd5cf3ef06f5d768717cdac70
Author: Juri Linkov <juri@linkov.net>
Commit: Juri Linkov <juri@linkov.net>
Transient input methods bound to 'C-x \' (bug#44266)
* lisp/international/mule-cmds.el (ctl-x-map): Bind 'C-x \' to
'transient-input-method'.
(input-method-function): New defcustom.
(transient-input-method): New command.
* doc/emacs/mule.texi (Select Input Method): Document
transient-input-method.
---
doc/emacs/mule.texi | 15 +++++++++++++++
etc/NEWS | 25 +++++++++++++++++--------
lisp/international/mule-cmds.el | 40 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 72 insertions(+), 8 deletions(-)
diff --git a/doc/emacs/mule.texi b/doc/emacs/mule.texi
index b780190..d4ad1d6 100644
--- a/doc/emacs/mule.texi
+++ b/doc/emacs/mule.texi
@@ -578,6 +578,11 @@ Enable or disable use of the selected input method
(@code{toggle-input-method}).
@item C-x @key{RET} C-\ @var{method} @key{RET}
Select a new input method for the current buffer (@code{set-input-method}).
+@item C-x \ @var{method} @key{RET}
+Temporarily enable the selected transient input method, and
+automatically disable it after inserting a single character
+(@code{transient-input-method}).
+
@item C-h I @var{method} @key{RET}
@itemx C-h C-\ @var{method} @key{RET}
@findex describe-input-method
@@ -675,6 +680,16 @@ character.
input methods. The list gives information about each input method,
including the string that stands for it in the mode line.
+@findex transient-input-method
+@kindex C-x \
+ To insert only a single character using a transient input method you
+can first select a transient input method by typing @kbd{C-u C-x \}.
+Then typing @kbd{C-x \} (@code{transient-input-method}) will
+temporarily enable the selected transient input method, and disable it
+automatically after using the activated input method to insert
+a single character. This is useful to insert a character from input
+methods with rare Unicode characters.
+
@node Coding Systems
@section Coding Systems
@cindex coding systems
diff --git a/etc/NEWS b/etc/NEWS
index 7bf212d..1061a15 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -133,14 +133,6 @@ characters. In particular, this significantly improves
word-wrapping
for CJK text mixed with Latin text.
---
-** New input method 'compose' based on X Multi_key sequences.
-
----
-** Improved language transliteration in Malayalam input methods.
-Added a new Mozhi scheme. The inapplicable ITRANS scheme is now
-deprecated. Errors in the Inscript method were corrected.
-
----
** Rudimentary support for the 'st' terminal emulator.
Emacs now supports 256 color display on the 'st' terminal emulator.
@@ -629,6 +621,23 @@ recorded for the purpose of 'view-lossage'.
The menu bar "Help" menu now has a "Show Recent Inputs" item under the
"Describe" sub-menu.
+** Input methods
+
++++
+*** 'C-x \' temporarily enables a transient input method.
+'C-u C-x \' can be used to select a transient input method, e.g.
+'C-u C-x \ compose RET' selects the 'compose' input method. Then typing
+'C-x \ 1 2' will insert the character '½', and disable the input method
+afterwards.
+
+---
+*** New input method 'compose' based on X Multi_key sequences.
+
+---
+*** Improved language transliteration in Malayalam input methods.
+Added a new Mozhi scheme. The inapplicable ITRANS scheme is now
+deprecated. Errors in the Inscript method were corrected.
+
** Ispell
+++
diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el
index e3155df..c5a0145 100644
--- a/lisp/international/mule-cmds.el
+++ b/lisp/international/mule-cmds.el
@@ -55,6 +55,7 @@
;; Keep "C-x C-m ..." for mule specific commands.
(define-key ctl-x-map "\C-m" mule-keymap)
+(define-key ctl-x-map "\\" 'transient-input-method)
(defvar describe-language-environment-map
(let ((map (make-sparse-keymap "Describe Language Environment")))
@@ -1344,6 +1345,16 @@ This is the input method activated automatically by the
command
mule-input-method-string)
:set-after '(current-language-environment))
+(defcustom transient-input-method nil
+ "Default transient input method.
+This is the input method activated automatically by the command
+`transient-input-method' (\\[transient-input-method])."
+ :link '(custom-manual "(emacs)Input Methods")
+ :group 'mule
+ :type '(choice (const nil)
+ mule-input-method-string)
+ :set-after '(current-language-environment))
+
(put 'input-method-function 'permanent-local t)
(defvar input-method-history nil
@@ -1519,6 +1530,35 @@ To deactivate it programmatically, use
`deactivate-input-method'."
(defvar toggle-input-method-active nil
"Non-nil inside `toggle-input-method'.")
+(defun transient-input-method (&optional arg interactive)
+ "Enable transient input method for the current buffer."
+ (interactive "P\np")
+ (when (or arg (not transient-input-method))
+ (let* ((default (or (car input-method-history) default-input-method))
+ (input-method
+ (read-input-method-name
+ (if default "Transient input method (default %s): " "Transient
input method: ")
+ default t)))
+ (setq transient-input-method input-method)
+ (when interactive
+ (customize-mark-as-set 'transient-input-method))))
+ (let* ((previous-input-method current-input-method)
+ (history input-method-history)
+ (clearfun (make-symbol "clear-transient-input-method"))
+ (exitfun
+ (lambda ()
+ (deactivate-input-method)
+ (when previous-input-method
+ (activate-input-method previous-input-method))
+ (setq input-method-history history)
+ (remove-hook 'input-method-after-insert-chunk-hook clearfun))))
+ (fset clearfun (lambda () (funcall exitfun)))
+ (add-hook 'input-method-after-insert-chunk-hook clearfun)
+ (when previous-input-method
+ (deactivate-input-method))
+ (activate-input-method transient-input-method)
+ exitfun))
+
(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.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 030ab2d: Transient input methods bound to 'C-x \' (bug#44266),
Juri Linkov <=