Commit 3dcad254 authored by Kenichi Handa's avatar Kenichi Handa

(set-keyboard-coding-system): Perform the

necessary setup here instead of calling encoded-kbd-setup-display.
parent fd503d99
...@@ -1268,36 +1268,57 @@ See also the command `set-keyboard-coding-system'.") ...@@ -1268,36 +1268,57 @@ See also the command `set-keyboard-coding-system'.")
(defun set-keyboard-coding-system (coding-system &optional terminal) (defun set-keyboard-coding-system (coding-system &optional terminal)
"Set coding system for keyboard input on TERMINAL to CODING-SYSTEM. "Set coding system for keyboard input on TERMINAL to CODING-SYSTEM.
In addition, this command calls `encoded-kbd-setup-display' to set up the
translation of keyboard input events to the specified coding system.
For a list of possible values of CODING-SYSTEM, use \\[list-coding-systems]. For a list of possible values of CODING-SYSTEM, use \\[list-coding-systems].
The default is determined by the selected language environment The default is determined by the selected language environment
or by the previous use of this command. or by the previous use of this command.
If CODING-SYSTEM is nil or the coding-type of CODING-SYSTEM is
`raw-text', the decoding of keyboard input is disabled.
TERMINAL may be a terminal object, a frame, or nil for the TERMINAL may be a terminal object, a frame, or nil for the
selected frame's terminal. The setting has no effect on selected frame's terminal. The setting has no effect on
graphical terminals." graphical terminals."
(interactive (interactive
(list (let ((default (if (and (not (keyboard-coding-system)) (list (let* ((coding (keyboard-coding-system nil))
default-keyboard-coding-system) (default (if (eq (coding-system-type coding) 'raw-text)
default-keyboard-coding-system))) default-keyboard-coding-system)))
(read-coding-system (read-coding-system
(format "Coding system for keyboard input (default %s): " (format "Coding system for keyboard input (default %s): "
default) default)
default)))) default))))
(if (and (not coding-system) (let ((coding-type (coding-system-type coding-system))
(not (keyboard-coding-system))) (saved-meta-mode
(setq coding-system default-keyboard-coding-system)) (terminal-parameter terminal 'keyboard-coding-saved-meta-mode)))
(if coding-system (if (not (eq coding-type 'raw-text))
(setq default-keyboard-coding-system coding-system)) (let (accept-8-bit)
(if (and coding-system (if (not (or (coding-system-get coding-system :suitable-for-keyboard)
(not (coding-system-get coding-system :ascii-compatible-p)) (coding-system-get coding-system :ascii-compatible-p)))
(not (coding-system-get coding-system :suitable-for-keyboard))) (error "Unsuitable coding system for keyboard: %s" coding-system))
(error "%s is not suitable for keyboard" coding-system)) (cond ((memq coding-type '(charset utf-8 shift-jis big5 ccl))
(setq accept-8-bit t))
((eq coding-type 'iso-2022)
(let ((flags (coding-system-get coding-system :flags)))
(or (memq '7-bit flags)
(setq accept-8-bit t))))
(t
(error "Unsupported coding system for keyboard: %s"
coding-system)))
(when accept-8-bit
(or saved-meta-mode
(set-terminal-parameter terminal
'keyboard-coding-saved-meta-mode
(cons (nth 2 (current-input-mode))
nil)))
(set-input-meta-mode 8)))
(when saved-meta-mode
(set-input-meta-mode (car saved-meta-mode))
(set-terminal-parameter terminal
'keyboard-coding-saved-meta-mode
nil))))
(set-keyboard-coding-system-internal coding-system terminal) (set-keyboard-coding-system-internal coding-system terminal)
(setq keyboard-coding-system coding-system) (setq keyboard-coding-system coding-system))
(encoded-kbd-setup-display terminal))
(defcustom keyboard-coding-system nil (defcustom keyboard-coding-system nil
"Specify coding system for keyboard input. "Specify coding system for keyboard input.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment