aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2020-11-01 23:35:41 +0200
committerJuri Linkov2020-11-01 23:35:41 +0200
commit030ab2dad50a448bd5cf3ef06f5d768717cdac70 (patch)
tree3743ed4178af7b06a348514a15b9379ddd8f15ee
parent1a1019f99fce48c372f8a43c2a9758f5dac9153e (diff)
downloademacs-030ab2dad50a448bd5cf3ef06f5d768717cdac70.tar.gz
emacs-030ab2dad50a448bd5cf3ef06f5d768717cdac70.zip
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.
-rw-r--r--doc/emacs/mule.texi15
-rw-r--r--etc/NEWS25
-rw-r--r--lisp/international/mule-cmds.el40
3 files changed, 72 insertions, 8 deletions
diff --git a/doc/emacs/mule.texi b/doc/emacs/mule.texi
index b78019020a6..d4ad1d6d5e2 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}).
578@item C-x @key{RET} C-\ @var{method} @key{RET} 578@item C-x @key{RET} C-\ @var{method} @key{RET}
579Select a new input method for the current buffer (@code{set-input-method}). 579Select a new input method for the current buffer (@code{set-input-method}).
580 580
581@item C-x \ @var{method} @key{RET}
582Temporarily enable the selected transient input method, and
583automatically disable it after inserting a single character
584(@code{transient-input-method}).
585
581@item C-h I @var{method} @key{RET} 586@item C-h I @var{method} @key{RET}
582@itemx C-h C-\ @var{method} @key{RET} 587@itemx C-h C-\ @var{method} @key{RET}
583@findex describe-input-method 588@findex describe-input-method
@@ -675,6 +680,16 @@ character.
675input methods. The list gives information about each input method, 680input methods. The list gives information about each input method,
676including the string that stands for it in the mode line. 681including the string that stands for it in the mode line.
677 682
683@findex transient-input-method
684@kindex C-x \
685 To insert only a single character using a transient input method you
686can first select a transient input method by typing @kbd{C-u C-x \}.
687Then typing @kbd{C-x \} (@code{transient-input-method}) will
688temporarily enable the selected transient input method, and disable it
689automatically after using the activated input method to insert
690a single character. This is useful to insert a character from input
691methods with rare Unicode characters.
692
678@node Coding Systems 693@node Coding Systems
679@section Coding Systems 694@section Coding Systems
680@cindex coding systems 695@cindex coding systems
diff --git a/etc/NEWS b/etc/NEWS
index 7bf212dd134..1061a15cd23 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -133,14 +133,6 @@ characters. In particular, this significantly improves word-wrapping
133for CJK text mixed with Latin text. 133for CJK text mixed with Latin text.
134 134
135--- 135---
136** New input method 'compose' based on X Multi_key sequences.
137
138---
139** Improved language transliteration in Malayalam input methods.
140Added a new Mozhi scheme. The inapplicable ITRANS scheme is now
141deprecated. Errors in the Inscript method were corrected.
142
143---
144** Rudimentary support for the 'st' terminal emulator. 136** Rudimentary support for the 'st' terminal emulator.
145Emacs now supports 256 color display on the 'st' terminal emulator. 137Emacs now supports 256 color display on the 'st' terminal emulator.
146 138
@@ -629,6 +621,23 @@ recorded for the purpose of 'view-lossage'.
629The menu bar "Help" menu now has a "Show Recent Inputs" item under the 621The menu bar "Help" menu now has a "Show Recent Inputs" item under the
630"Describe" sub-menu. 622"Describe" sub-menu.
631 623
624** Input methods
625
626+++
627*** 'C-x \' temporarily enables a transient input method.
628'C-u C-x \' can be used to select a transient input method, e.g.
629'C-u C-x \ compose RET' selects the 'compose' input method. Then typing
630'C-x \ 1 2' will insert the character '½', and disable the input method
631afterwards.
632
633---
634*** New input method 'compose' based on X Multi_key sequences.
635
636---
637*** Improved language transliteration in Malayalam input methods.
638Added a new Mozhi scheme. The inapplicable ITRANS scheme is now
639deprecated. Errors in the Inscript method were corrected.
640
632** Ispell 641** Ispell
633 642
634+++ 643+++
diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el
index e3155dfc52c..c5a01451637 100644
--- a/lisp/international/mule-cmds.el
+++ b/lisp/international/mule-cmds.el
@@ -55,6 +55,7 @@
55 55
56;; Keep "C-x C-m ..." for mule specific commands. 56;; Keep "C-x C-m ..." for mule specific commands.
57(define-key ctl-x-map "\C-m" mule-keymap) 57(define-key ctl-x-map "\C-m" mule-keymap)
58(define-key ctl-x-map "\\" 'transient-input-method)
58 59
59(defvar describe-language-environment-map 60(defvar describe-language-environment-map
60 (let ((map (make-sparse-keymap "Describe Language Environment"))) 61 (let ((map (make-sparse-keymap "Describe Language Environment")))
@@ -1344,6 +1345,16 @@ This is the input method activated automatically by the command
1344 mule-input-method-string) 1345 mule-input-method-string)
1345 :set-after '(current-language-environment)) 1346 :set-after '(current-language-environment))
1346 1347
1348(defcustom transient-input-method nil
1349 "Default transient input method.
1350This is the input method activated automatically by the command
1351`transient-input-method' (\\[transient-input-method])."
1352 :link '(custom-manual "(emacs)Input Methods")
1353 :group 'mule
1354 :type '(choice (const nil)
1355 mule-input-method-string)
1356 :set-after '(current-language-environment))
1357
1347(put 'input-method-function 'permanent-local t) 1358(put 'input-method-function 'permanent-local t)
1348 1359
1349(defvar input-method-history nil 1360(defvar input-method-history nil
@@ -1519,6 +1530,35 @@ To deactivate it programmatically, use `deactivate-input-method'."
1519(defvar toggle-input-method-active nil 1530(defvar toggle-input-method-active nil
1520 "Non-nil inside `toggle-input-method'.") 1531 "Non-nil inside `toggle-input-method'.")
1521 1532
1533(defun transient-input-method (&optional arg interactive)
1534 "Enable transient input method for the current buffer."
1535 (interactive "P\np")
1536 (when (or arg (not transient-input-method))
1537 (let* ((default (or (car input-method-history) default-input-method))
1538 (input-method
1539 (read-input-method-name
1540 (if default "Transient input method (default %s): " "Transient input method: ")
1541 default t)))
1542 (setq transient-input-method input-method)
1543 (when interactive
1544 (customize-mark-as-set 'transient-input-method))))
1545 (let* ((previous-input-method current-input-method)
1546 (history input-method-history)
1547 (clearfun (make-symbol "clear-transient-input-method"))
1548 (exitfun
1549 (lambda ()
1550 (deactivate-input-method)
1551 (when previous-input-method
1552 (activate-input-method previous-input-method))
1553 (setq input-method-history history)
1554 (remove-hook 'input-method-after-insert-chunk-hook clearfun))))
1555 (fset clearfun (lambda () (funcall exitfun)))
1556 (add-hook 'input-method-after-insert-chunk-hook clearfun)
1557 (when previous-input-method
1558 (deactivate-input-method))
1559 (activate-input-method transient-input-method)
1560 exitfun))
1561
1522(defun toggle-input-method (&optional arg interactive) 1562(defun toggle-input-method (&optional arg interactive)
1523 "Enable or disable multilingual text input method for the current buffer. 1563 "Enable or disable multilingual text input method for the current buffer.
1524Only one input method can be enabled at any time in a given buffer. 1564Only one input method can be enabled at any time in a given buffer.