@item C-x \ @var{method} @key{RET}
Temporarily enable the selected transient input method ; it will be
automatically disabled after inserting a single character
-(@code{transient-input-method}).
+(@code{activate-transient-input-method}).
@item C-h I @var{method} @key{RET}
@itemx C-h C-\ @var{method} @key{RET}
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
+@findex activate-transient-input-method
@kindex C-x \
Sometimes it can be convenient to enable an input method
@dfn{transiently}, for inserting only a single character. Typing
-@kbd{C-x \} (@code{transient-input-method}) will temporarily enable an
-input method, let you insert a single character using the input method
-rules, and then automatically disable the input method. If no
+@kbd{C-x \} (@code{activate-transient-input-method}) will temporarily
+enable an input method, let you insert a single character using the input
+method rules, and then automatically disable the input method. If no
transient input method was selected yet, @kbd{C-x \} will prompt you
for an input method; subsequent invocations of this command will
enable the selected transient input method. To select a different
;; 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)
+(define-key ctl-x-map "\\" 'activate-transient-input-method)
(defvar describe-language-environment-map
(let ((map (make-sparse-keymap "Describe Language Environment")))
`(menu-item "Set Coding Systems" ,set-coding-system-map))
(bindings--define-key map [separator-input-method] menu-bar-separator)
- (bindings--define-key map [describe-input-method]
- '(menu-item "Describe Input Method" describe-input-method))
+ (bindings--define-key map [activate-transient-input-method]
+ '(menu-item "Transient Input Method" activate-transient-input-method))
(bindings--define-key map [set-input-method]
'(menu-item "Select Input Method..." set-input-method))
(bindings--define-key map [toggle-input-method]
mule-input-method-string)
:set-after '(current-language-environment))
-(defcustom transient-input-method nil
+(defcustom default-transient-input-method nil
"Default transient input method.
This is the input method activated by the command
-`transient-input-method' (\\[transient-input-method])."
+`activate-transient-input-method' (\\[activate-transient-input-method])."
:link '(custom-manual "(emacs)Input Methods")
:group 'mule
:type '(choice (const nil)
:set-after '(current-language-environment)
:version "28.1")
+(defvar current-transient-input-method nil
+ "The current input method temporarily enabled by `activate-transient-input-method'.
+If nil, that means no transient input method is active now.")
+(make-variable-buffer-local 'current-transient-input-method)
+(put 'current-transient-input-method 'permanent-local t)
+
+(defvar previous-transient-input-method nil
+ "The input method that was active before enabling the transient input method.
+If nil, that means no previous input method was active.")
+(make-variable-buffer-local 'previous-transient-input-method)
+(put 'previous-transient-input-method 'permanent-local t)
+
(put 'input-method-function 'permanent-local t)
(defvar input-method-history nil
(defun deactivate-input-method ()
"Turn off the current input method."
(when current-input-method
- (add-to-history 'input-method-history current-input-method)
+ (unless current-transient-input-method
+ (add-to-history 'input-method-history current-input-method))
(unwind-protect
(progn
(setq input-method-function nil
(defvar toggle-input-method-active nil
"Non-nil inside `toggle-input-method'.")
-(defun transient-input-method (&optional arg interactive)
- "Enable a transient input method for the current buffer.
-If `transient-input-method' was not yet defined, prompt for it."
- (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.
(if toggle-input-method-active
(error "Recursive use of `toggle-input-method'"))
(if (and current-input-method (not arg))
- (deactivate-input-method)
+ (if current-transient-input-method
+ (deactivate-transient-input-method)
+ (deactivate-input-method))
(let ((toggle-input-method-active t)
(default (or (car input-method-history) default-input-method)))
(if (and arg default (equal current-input-method default)
(when interactive
(customize-mark-as-set 'default-input-method)))))))
+(defun activate-transient-input-method (&optional arg interactive)
+ "Select and enable a transient input method for the current buffer.
+If `default-transient-input-method' was not yet defined, prompt for it."
+ (interactive "P\np")
+ (when (or arg (not default-transient-input-method))
+ (let* ((default (or (car input-method-history) default-input-method))
+ (input-method
+ (read-input-method-name
+ (format-prompt "Transient input method" default)
+ default t)))
+ (setq default-transient-input-method input-method)
+ (when interactive
+ (customize-mark-as-set 'default-transient-input-method))))
+ (let* ((clearfun (make-symbol "clear-transient-input-method"))
+ (exitfun
+ (lambda ()
+ (deactivate-transient-input-method)
+ (remove-hook 'input-method-after-insert-chunk-hook clearfun))))
+ (fset clearfun (lambda () (funcall exitfun)))
+ (add-hook 'input-method-after-insert-chunk-hook clearfun)
+ (setq previous-transient-input-method current-input-method)
+ (when previous-transient-input-method
+ (deactivate-input-method))
+ (activate-input-method default-transient-input-method)
+ (setq current-transient-input-method default-transient-input-method)
+ exitfun))
+
+(defun deactivate-transient-input-method ()
+ "Disable currently active transient input method for the current buffer."
+ (when current-transient-input-method
+ (deactivate-input-method)
+ (when previous-transient-input-method
+ (activate-input-method previous-transient-input-method)
+ (setq previous-transient-input-method nil))
+ (setq current-transient-input-method nil)))
+
(autoload 'help-buffer "help-mode")
(defun describe-input-method (input-method)
:help "Highlight all matches for current search string"))
(define-key map [isearch-search-replace-separator]
'(menu-item "--"))
+ (define-key map [isearch-transient-input-method]
+ '(menu-item "Turn on transient input method"
+ isearch-transient-input-method
+ :help "Turn on transient input method for search"))
(define-key map [isearch-toggle-specified-input-method]
'(menu-item "Turn on specific input method"
isearch-toggle-specified-input-method
;; For searching multilingual text.
(define-key map "\C-\\" 'isearch-toggle-input-method)
(define-key map "\C-^" 'isearch-toggle-specified-input-method)
+ (define-key map "\C-x\\" 'isearch-transient-input-method)
;; People expect to be able to paste with the mouse.
(define-key map [mouse-2] #'isearch-mouse-2)
\\[isearch-toggle-specified-input-method],
and specify an input method you want to use.
+To activate a transient input method, type \\[isearch-transient-input-method].
+
The above keys, bound in `isearch-mode-map', are often controlled by
options; do \\[apropos] on search-.* to find them.
Other control and meta characters terminate the search
"over")
(if isearch-wrapped "wrapped ")
(if (and (not isearch-success) (buffer-narrowed-p) widen-automatically)
- "narrowed-buffer " "")
+ "narrowed " "")
(if (and (not isearch-success) (not isearch-case-fold-search))
"case-sensitive ")
(let ((prefix ""))