Commit ef8a8c8c authored by Kenichi Handa's avatar Kenichi Handa
Browse files

(mule-keymap): Re-arranged.

(set-language-info): Typo fixed in docstring.
(read-language-name): Use assoc-ignore-case to allow lose matching.
(read-language-and-input-method-name): Likewise.
parent f35c859c
...@@ -42,6 +42,11 @@ ...@@ -42,6 +42,11 @@
(fset 'mule-describe-language-support-prefix (fset 'mule-describe-language-support-prefix
mule-describe-language-support-map) mule-describe-language-support-map)
(defvar mule-set-language-environment-map
(make-sparse-keymap "Set Language Environment"))
(fset 'mule-set-language-environment-prefix
mule-set-language-environment-map)
(define-key mule-keymap "m" 'toggle-enable-multibyte-characters) (define-key mule-keymap "m" 'toggle-enable-multibyte-characters)
(define-key mule-keymap "f" 'set-buffer-file-coding-system) (define-key mule-keymap "f" 'set-buffer-file-coding-system)
(define-key mule-keymap "t" 'set-terminal-coding-system) (define-key mule-keymap "t" 'set-terminal-coding-system)
...@@ -54,30 +59,38 @@ ...@@ -54,30 +59,38 @@
(define-key help-map "C" 'describe-current-coding-system) (define-key help-map "C" 'describe-current-coding-system)
(define-key help-map "h" 'view-hello-file) (define-key help-map "h" 'view-hello-file)
(define-key mule-keymap [view-hello-file]
'("Show many languages" . view-hello-file))
(define-key mule-keymap [mule-diag]
'("Show diagnosis for MULE" . mule-diag))
(define-key mule-keymap [separator-coding-system]
'("--"))
(define-key mule-keymap [set-process-coding-system] (define-key mule-keymap [set-process-coding-system]
'(" ... of process" . set-current-process-coding-system)) '("Set coding system of process" . set-current-process-coding-system))
(define-key mule-keymap [set-keyboard-coding-system] (define-key mule-keymap [set-keyboard-coding-system]
'(" ... of keyboard" . set-keyboard-coding-system)) '("Set coding system of keyboard" . set-keyboard-coding-system))
(define-key mule-keymap [set-terminal-coding-system] (define-key mule-keymap [set-terminal-coding-system]
'(" ... of terminal" . set-terminal-coding-system)) '("Set coding system of terminal" . set-terminal-coding-system))
(define-key mule-keymap [set-buffer-file-coding-system] (define-key mule-keymap [set-buffer-file-coding-system]
'(" ... of visiting file" . set-buffer-file-coding-system)) '("Set coding system of buffer file" . set-buffer-file-coding-system))
(define-key mule-keymap [separator-mule]
'("Setting coding systems"))
(define-key mule-keymap [describe-current-coding-system] (define-key mule-keymap [describe-current-coding-system]
'("Describe current coding systems" . describe-current-coding-system)) '("Describe current coding systems" . describe-current-coding-system))
(define-key mule-keymap [describe-language-support] (define-key mule-keymap [separator-input-method]
'("Describe language support" . mule-describe-language-support-prefix)) '("--"))
(define-key mule-keymap [view-hello-file]
'("Show many languages" . view-hello-file))
(define-key mule-keymap [describe-input-method] (define-key mule-keymap [describe-input-method]
'("Describe input method" . describe-input-method)) '("Describe input method" . describe-input-method))
(define-key mule-keymap [select-input-method] (define-key mule-keymap [select-input-method]
'("Select input method" . select-input-method)) '("Select input method" . select-input-method))
(define-key mule-keymap [toggle-input-method] (define-key mule-keymap [toggle-input-method]
'("Toggle input method" . toggle-input-method)) '("Toggle input method" . toggle-input-method))
(define-key mule-keymap [separator-mule]
'("--"))
(define-key mule-keymap [set-language-environment]
'("Set language environment" . mule-set-language-environment-prefix))
(define-key mule-keymap [describe-language-support]
'("Describe language support" . mule-describe-language-support-prefix))
(define-key mule-keymap [toggle-mule] (define-key mule-keymap [toggle-mule]
'("Toggle MULE" . toggle-enable-multibyte-characters)) '("Disable/enable multibyte character" . toggle-enable-multibyte-characters))
;; These are meaningless when running under X. ;; These are meaningless when running under X.
(put 'set-keyboard-coding-system 'menu-enable (put 'set-keyboard-coding-system 'menu-enable
...@@ -139,6 +152,13 @@ KEY is a symbol denoting the kind of required information." ...@@ -139,6 +152,13 @@ KEY is a symbol denoting the kind of required information."
(interactive) (interactive)
(describe-language-support ,lang))) (describe-language-support ,lang)))
;; Return a lambda form which calls `set-language-environment' with
;; argument LANG.
(defun build-set-language-environment-function (lang)
`(lambda ()
(interactive)
(set-language-environment ,lang)))
(defun set-language-info (language-name key info) (defun set-language-info (language-name key info)
"Set for LANGUAGE-NAME the information INFO under KEY. "Set for LANGUAGE-NAME the information INFO under KEY.
LANGUAGE-NAME is a string LANGUAGE-NAME is a string
...@@ -148,7 +168,7 @@ INFO is any Lisp object which contains the actual information. ...@@ -148,7 +168,7 @@ INFO is any Lisp object which contains the actual information.
Currently, the following KEYs are used by Emacs: Currently, the following KEYs are used by Emacs:
charset: list of symbols whose values are charsets specific to the language. charset: list of symbols whose values are charsets specific to the language.
coding-system: list of coding systems specific to the langauge. coding-system: list of coding systems specific to the langauge.
setup-function: see the documentation of `set-language-envrionment'. setup-function: see the documentation of `set-language-environment'.
tutorial: a tutorial file name written in the language. tutorial: a tutorial file name written in the language.
sample-text: one line short text containing characters of the language. sample-text: one line short text containing characters of the language.
documentation: a docstring describing how the language is supported, documentation: a docstring describing how the language is supported,
...@@ -172,11 +192,16 @@ should use prefix \"user-\" in the name of KEY." ...@@ -172,11 +192,16 @@ should use prefix \"user-\" in the name of KEY."
(setcdr lang-slot (cons key-slot (cdr lang-slot))))) (setcdr lang-slot (cons key-slot (cdr lang-slot)))))
(setcdr key-slot info) (setcdr key-slot info)
;; Setup menu. ;; Setup menu.
(if (eq key 'documentation) (cond ((eq key 'documentation)
(define-key mule-describe-language-support-map (define-key mule-describe-language-support-map
(vector (intern language-name)) (vector (intern language-name))
(cons language-name (cons language-name
(build-describe-language-support-function language-name)))) (build-describe-language-support-function language-name))))
((eq key 'setup-function)
(define-key mule-set-language-environment-map
(vector (intern language-name))
(cons language-name
(build-set-language-environment-function language-name)))))
)) ))
(defun set-language-info-alist (language-name alist) (defun set-language-info-alist (language-name alist)
...@@ -195,9 +220,8 @@ ALIST is an alist of KEY and INFO. See the documentation of ...@@ -195,9 +220,8 @@ ALIST is an alist of KEY and INFO. See the documentation of
(function (lambda (elm) (assq key elm))) (function (lambda (elm) (assq key elm)))
t t
initial-input))) initial-input)))
;; In spite of the documentation, completing-read returns null (and (> (length name) 0)
;; string instead of nil if input is null. (car (assoc-ignore-case (downcase name) language-info-alist)))))
(and (> (length name) 0) name)))
;;; Multilingual input methods. ;;; Multilingual input methods.
...@@ -270,20 +294,18 @@ Return a cons of those names." ...@@ -270,20 +294,18 @@ Return a cons of those names."
(if (null language-name) (if (null language-name)
(error "No input method for the specified language")) (error "No input method for the specified language"))
(let* ((completion-ignore-case t) (let* ((completion-ignore-case t)
(key-slot (key-slot (cdr (assq 'input-method
(assq 'input-method (assoc language-name language-info-alist))))
(cdr (assoc language-name language-info-alist))))
(method-name (method-name
(completing-read "Input method: " (cdr key-slot) nil t (completing-read "Input method: " key-slot nil t
(if (and previous-input-method (if (and previous-input-method
(string= language-name (string= language-name
(car previous-input-method))) (car previous-input-method)))
(cons (cdr previous-input-method) 0))))) (cons (cdr previous-input-method) 0)))))
;; In spite of the documentation, completing-read returns
;; null string instead of nil if input is null.
(if (= (length method-name) 0) (if (= (length method-name) 0)
(error "No input method specified")) (error "No input method specified"))
(list language-name method-name)))) (list language-name
(car (assoc-ignore-case (downcase method-name) key-slot))))))
(defun set-default-input-method (language-name method-name) (defun set-default-input-method (language-name method-name)
"Set the default input method to METHOD-NAME for inputting LANGUAGE-NAME. "Set the default input method to METHOD-NAME for inputting LANGUAGE-NAME.
......
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