;;; mule-cmds.el --- commands for multilingual environment -*-coding: iso-2022-7bit -*-
;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
-;; 2007, 2008, 2009 Free Software Foundation, Inc.
+;; 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-;; 2005, 2006, 2007, 2008, 2009
+;; 2005, 2006, 2007, 2008, 2009, 2010
;; National Institute of Advanced Industrial Science and Technology (AIST)
;; Registration Number H14PRO021
;; Copyright (C) 2003
(define-key-after map [universal-coding-system-argument]
`(menu-item ,(purecopy "For Next Command") universal-coding-system-argument
:help ,(purecopy "Coding system to be used by next command")))
- (define-key-after map [separator-1] '("--"))
+ (define-key-after map [separator-1] menu-bar-separator)
(define-key-after map [set-buffer-file-coding-system]
`(menu-item ,(purecopy "For Saving This Buffer") set-buffer-file-coding-system
:help ,(purecopy "How to encode this buffer when saved")))
(define-key-after map [set-file-name-coding-system]
`(menu-item ,(purecopy "For File Name") set-file-name-coding-system
:help ,(purecopy "How to decode/encode file names")))
- (define-key-after map [separator-2] '("--"))
+ (define-key-after map [separator-2] menu-bar-separator)
(define-key-after map [set-keyboard-coding-system]
`(menu-item ,(purecopy "For Keyboard") set-keyboard-coding-system
`(menu-item ,(purecopy "For Terminal") set-terminal-coding-system
:enable (null (memq initial-window-system '(x w32 ns)))
:help ,(purecopy "How to encode terminal output")))
- (define-key-after map [separator-3] '("--"))
+ (define-key-after map [separator-3] menu-bar-separator)
(define-key-after map [set-selection-coding-system]
`(menu-item ,(purecopy "For X Selections/Clipboard") set-selection-coding-system
(let ((map (make-sparse-keymap "Mule (Multilingual Environment)")))
(define-key-after map [set-language-environment]
`(menu-item ,(purecopy "Set Language Environment") ,setup-language-environment-map))
- (define-key-after map [separator-mule] '("--"))
+ (define-key-after map [separator-mule] menu-bar-separator)
(define-key-after map [toggle-input-method]
`(menu-item ,(purecopy "Toggle Input Method") toggle-input-method))
`(menu-item ,(purecopy "Select Input Method...") set-input-method))
(define-key-after map [describe-input-method]
`(menu-item ,(purecopy "Describe Input Method") describe-input-method))
- (define-key-after map [separator-input-method] '("--"))
+ (define-key-after map [separator-input-method] menu-bar-separator)
(define-key-after map [set-various-coding-system]
`(menu-item ,(purecopy "Set Coding Systems") ,set-coding-system-map
:enable (file-readable-p
(expand-file-name "HELLO" data-directory))
:help ,(purecopy "Display file which says HELLO in many languages")))
- (define-key-after map [separator-coding-system] '("--"))
+ (define-key-after map [separator-coding-system] menu-bar-separator)
(define-key-after map [describe-language-environment]
`(menu-item ,(purecopy "Describe Language Environment")
- describe-language-environment-map
+ ,describe-language-environment-map
:help ,(purecopy "Show multilingual settings for a specific language")))
(define-key-after map [describe-input-method]
`(menu-item ,(purecopy "Describe Input Method...") describe-input-method
;; and delimiter characters. Support function of
;; coding-system-from-name.
(defun canonicalize-coding-system-name (name)
- (if (string-match "^iso[-_ ]?[0-9]" name)
- ;; "iso-8859-1" -> "8859-1", "iso-2022-jp" ->"2022-jp"
- (setq name (substring name (1- (match-end 0)))))
- (let ((idx (string-match "[-_ /]" name)))
- ;; Delete "-", "_", " ", "/" but do distinguish "16-be" and "16be".
- (while idx
- (if (and (>= idx 2)
- (eq (string-match "16-[lb]e$" name (- idx 2))
- (- idx 2)))
- (setq idx (string-match "[-_ /]" name (match-end 0)))
- (setq name (concat (substring name 0 idx) (substring name (1+ idx)))
- idx (string-match "[-_ /]" name idx))))
- name))
+ (if (string-match "^\\(ms\\|ibm\\|windows-\\)\\([0-9]+\\)$" name)
+ ;; "ms950", "ibm950", "windows-950" -> "cp950"
+ (concat "cp" (match-string 2 name))
+ (if (string-match "^iso[-_ ]?[0-9]" name)
+ ;; "iso-8859-1" -> "8859-1", "iso-2022-jp" ->"2022-jp"
+ (setq name (substring name (1- (match-end 0)))))
+ (let ((idx (string-match "[-_ /]" name)))
+ ;; Delete "-", "_", " ", "/" but do distinguish "16-be" and "16be".
+ (while idx
+ (if (and (>= idx 2)
+ (eq (string-match "16-[lb]e$" name (- idx 2))
+ (- idx 2)))
+ (setq idx (string-match "[-_ /]" name (match-end 0)))
+ (setq name (concat (substring name 0 idx) (substring name (1+ idx)))
+ idx (string-match "[-_ /]" name idx))))
+ name)))
(defun coding-system-from-name (name)
"Return a coding system whose name matches with NAME (string or symbol)."
"Display the HELLO file, which lists many languages and characters."
(interactive)
;; We have to decode the file in any environment.
- (letf (((default-value 'enable-multibyte-characters) t)
- (coding-system-for-read 'iso-2022-7bit))
- (view-file (expand-file-name "HELLO" data-directory))))
+ (letf ((coding-system-for-read 'iso-2022-7bit))
+ (view-file (expand-file-name "HELLO" data-directory))))
(defun universal-coding-system-argument (coding-system)
"Execute an I/O command using the specified coding system."
without loading the relevant Quail packages.
\n(fn INPUT-METHOD LANG-ENV ACTIVATE-FUNC TITLE DESCRIPTION &rest ARGS)"
(if (symbolp lang-env)
- (setq lang-env (symbol-name lang-env)))
+ (setq lang-env (symbol-name lang-env))
+ (setq lang-env (purecopy lang-env)))
(if (symbolp input-method)
- (setq input-method (symbol-name input-method)))
+ (setq input-method (symbol-name input-method))
+ (setq input-method (purecopy input-method)))
+ (setq args (mapcar 'purecopy args))
(let ((info (cons lang-env args))
(slot (assoc input-method input-method-alist)))
(if slot
(force-mode-line-update t))
(define-widget 'charset 'symbol
- (purecopy "An Emacs charset.")
+ "An Emacs charset."
:tag "Charset"
:complete-function (lambda ()
(interactive)
(> (aref (number-to-string (nth 2 (x-server-version))) 0)
?3))
;; Make non-line-break space display as a plain space.
- (aset standard-display-table 160 [32]))
+ (aset standard-display-table (unibyte-char-to-multibyte 160) [32]))
;; Most Windows programs send out apostrophes as \222. Most X fonts
;; don't contain a character at that position. Map it to the ASCII
;; apostrophe. [This is actually RIGHT SINGLE QUOTATION MARK,
;; fonts probably have the appropriate glyph at this position,
;; so they could use standard-display-8bit. It's better to use a
;; proper windows-1252 coding system. --fx]
- (aset standard-display-table 146 [39]))))
+ (aset standard-display-table (unibyte-char-to-multibyte 146) [39]))))
(defun set-language-environment-coding-systems (language-name)
"Do various coding system setups for language environment LANGUAGE-NAME."
("af" . "Latin-1") ; Afrikaans
("am" "Ethiopic" utf-8) ; Amharic
("an" . "Latin-9") ; Aragonese
- ; ar Arabic glibc uses 8859-6
+ ("ar" . "Arabic")
; as Assamese
; ay Aymara
("az" . "UTF-8") ; Azerbaijani
(error "Invalid char-table: %s" table))
(or (stringp table)
(error "Not a char-table nor a file name: %s" table)))
- (if (stringp table) (purecopy table))
+ (if (stringp table) (setq table (purecopy table)))
(let ((slot (assq name char-code-property-alist)))
(if slot
(setcdr slot table)
;; Pretty description of encoded string
;; Alist of ISO 2022 control code vs the corresponding mnemonic string.
-(defvar iso-2022-control-alist
+(defconst iso-2022-control-alist
'((?\x1b . "ESC")
(?\x0e . "SO")
(?\x0f . "SI")
:group 'mule
:global t)
-(defvar nonascii-insert-offset 0 "This variable is obsolete.")
-(defvar nonascii-translation-table nil "This variable is obsolete.")
+(defvar nonascii-insert-offset 0)
+(make-obsolete-variable 'nonascii-insert-offset "do not use it." "23.1")
+(defvar nonascii-translation-table nil)
+(make-obsolete-variable 'nonascii-translation-table "do not use it." "23.1")
(defvar ucs-names nil
"Alist of cached (CHAR-NAME . CHAR-CODE) pairs.")
(defun ucs-names ()
"Return alist of (CHAR-NAME . CHAR-CODE) pairs cached in `ucs-names'."
(or ucs-names
- (setq ucs-names
- (let (name names)
- (dotimes-with-progress-reporter (c #xEFFFF)
- "Loading Unicode character names..."
- (unless (or
- (and (>= c #x3400 ) (<= c #x4dbf )) ; CJK Ideograph Extension A
- (and (>= c #x4e00 ) (<= c #x9fff )) ; CJK Ideograph
- (and (>= c #xd800 ) (<= c #xfaff )) ; Private/Surrogate
- (and (>= c #x20000) (<= c #x2ffff)) ; CJK Ideograph Extensions B, C
- )
- (if (setq name (get-char-code-property c 'name))
- (setq names (cons (cons name c) names)))
- (if (setq name (get-char-code-property c 'old-name))
- (setq names (cons (cons name c) names)))))
- names))))
+ (let ((bmp-ranges
+ '((#x0000 . #x33FF)
+ ;; (#x3400 . #x4DBF) CJK Ideographs Extension A
+ (#x4DC0 . #x4DFF)
+ ;; (#x4E00 . #x9FFF) CJK Unified Ideographs
+ (#xA000 . #xD7FF)
+ ;; (#xD800 . #xFAFF) Surrogate/Private
+ (#xFB00 . #xFFFD)))
+ (upper-ranges
+ '((#x10000 . #x134FF)
+ ;; (#x13500 . #x167FF) unused
+ (#x16800 . #x16A3F)
+ ;; (#x16A40 . #x1AFFF) unused
+ (#x1B000 . #x1B0FF)
+ ;; (#x1B100 . #x1CFFF) unused
+ (#x1D000 . #x1FFFF)
+ ;; (#x20000 . #xDFFFF) CJK Ideograph Extension A, B, etc, unused
+ (#xE0000 . #xE01FF)))
+ (gc-cons-threshold 10000000)
+ c end name names)
+ (dolist (range bmp-ranges)
+ (setq c (car range)
+ end (cdr range))
+ (while (<= c end)
+ (if (setq name (get-char-code-property c 'name))
+ (push (cons name c) names))
+ (if (setq name (get-char-code-property c 'old-name))
+ (push (cons name c) names))
+ (setq c (1+ c))))
+ (dolist (range upper-ranges)
+ (setq c (car range)
+ end (cdr range))
+ (while (<= c end)
+ (if (setq name (get-char-code-property c 'name))
+ (push (cons name c) names))
+ (setq c (1+ c))))
+ (setq ucs-names names))))
(defvar ucs-completions (lazy-completion-table ucs-completions ucs-names)
"Lazy completion table for completing on Unicode character names.")