annotate lisp/mule/mule-cmds.el @ 404:2f8bb876ab1d r21-2-32

Import from CVS: tag r21-2-32
author cvs
date Mon, 13 Aug 2007 11:16:07 +0200
parents a86b2b5e0111
children b8cc9ab3f761
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1 ;;; mule-cmds.el --- Commands for multilingual environment
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
2
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
3 ;; Copyright (C) 1995,1999 Electrotechnical Laboratory, JAPAN.
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
4 ;; Licensed to the Free Software Foundation.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
5 ;; Copyright (C) 1997 MORIOKA Tomohiko
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
6
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
7 ;; Keywords: mule, multilingual
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
8
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
9 ;; This file is part of XEmacs.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
10
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
11 ;; XEmacs is free software; you can redistribute it and/or modify it
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
12 ;; under the terms of the GNU General Public License as published by
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
14 ;; any later version.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
15
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
16 ;; XEmacs is distributed in the hope that it will be useful, but
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
19 ;; General Public License for more details.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
20
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
22 ;; along with XEmacs; see the file COPYING. If not, write to the Free
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
23 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
24 ;; 02111-1307, USA.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
25
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
26 ;;; Code:
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
27
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
28 ;;; MULE related key bindings and menus.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
29
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
30 (defvar mule-keymap (make-sparse-keymap "Mule")
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
31 "Keymap for Mule (Multilingual environment) specific commands.")
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
32
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
33 ;; Keep "C-x C-m ..." for mule specific commands.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
34 (define-key ctl-x-map "\C-m" mule-keymap)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
35
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
36 (define-key mule-keymap "f" 'set-buffer-file-coding-system)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
37 (define-key mule-keymap "F" 'set-default-buffer-file-coding-system) ; XEmacs
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
38 (define-key mule-keymap "t" 'set-terminal-coding-system)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
39 (define-key mule-keymap "k" 'set-keyboard-coding-system)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
40 (define-key mule-keymap "p" 'set-buffer-process-coding-system)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
41 (define-key mule-keymap "x" 'set-selection-coding-system)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
42 (define-key mule-keymap "X" 'set-next-selection-coding-system)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
43 (define-key mule-keymap "\C-\\" 'set-input-method)
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
44 (define-key mule-keymap "c" 'universal-coding-system-argument)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
45 ;;(define-key mule-keymap "c" 'list-coding-system-briefly) ; XEmacs
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
46 (define-key mule-keymap "C" 'describe-coding-system) ; XEmacs
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
47 (define-key mule-keymap "r" 'toggle-display-direction) ; XEmacs
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
48 (define-key mule-keymap "l" 'set-language-environment)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
49
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
50 (define-key help-map "L" 'describe-language-environment)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
51 (define-key help-map "\C-\\" 'describe-input-method)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
52 (define-key help-map "I" 'describe-input-method)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
53 (define-key help-map "h" 'view-hello-file)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
54
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
55 ;; Menu for XEmacs were moved to menubar-items.el.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
56
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
57
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
58 ;; This should be a single character key binding because users use it
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
59 ;; very frequently while editing multilingual text. Now we can use
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
60 ;; only two such keys: "\C-\\" and "\C-^", but the latter is not
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
61 ;; convenient because it requires shifting on most keyboards. An
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
62 ;; alternative is "\C-\]" which is now bound to `abort-recursive-edit'
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
63 ;; but it won't be used that frequently.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
64 (define-key global-map "\C-\\" 'toggle-input-method)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
65
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
66 ;;; This is no good because people often type Shift-SPC
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
67 ;;; meaning to type SPC. -- rms.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
68 ;;; ;; Here's an alternative key binding for X users (Shift-SPACE).
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
69 ;;; (define-key global-map [?\S- ] 'toggle-input-method)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
70
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
71 (defun coding-system-change-eol-conversion (coding-system eol-type)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
72 "Return a coding system which differs from CODING-SYSTEM in eol conversion.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
73 The returned coding system converts end-of-line by EOL-TYPE
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
74 but text as the same way as CODING-SYSTEM.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
75 EOL-TYPE should be `lf', `crlf', `cr' or nil.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
76 If EOL-TYPE is nil, the returned coding system detects
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
77 how end-of-line is formatted automatically while decoding.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
78
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
79 EOL-TYPE can be specified by an symbol `unix', `dos' or `mac'.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
80 They means `lf', `crlf', and `cr' respectively."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
81 (if (symbolp eol-type)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
82 (setq eol-type (cond ((or (eq eol-type 'unix)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
83 (eq eol-type 'lf))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
84 'eol-lf)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
85 ((or (eq eol-type 'dos)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
86 (eq eol-type 'crlf))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
87 'eol-crlf)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
88 ((or (eq eol-type 'mac)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
89 (eq eol-type 'cr))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
90 'eol-cr)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
91 (t eol-type))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
92 (let ((orig-eol-type (coding-system-eol-type coding-system)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
93 (if (null orig-eol-type)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
94 (if (not eol-type)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
95 coding-system
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
96 (coding-system-property coding-system eol-type))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
97 (let ((base (coding-system-base coding-system)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
98 (if (not eol-type)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
99 base
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
100 (if (= eol-type orig-eol-type)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
101 coding-system
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
102 (setq orig-eol-type (coding-system-eol-type base))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
103 (if (null orig-eol-type)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
104 (coding-system-property base eol-type))))))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
105
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
106 ;; (defun coding-system-change-text-conversion (coding-system coding)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
107 ;; "Return a coding system which differs from CODING-SYSTEM in text conversion.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
108 ;; The returned coding system converts text by CODING
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
109 ;; but end-of-line as the same way as CODING-SYSTEM.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
110 ;; If CODING is nil, the returned coding system detects
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
111 ;; how text is formatted automatically while decoding."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
112 ;; (if (not coding)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
113 ;; (coding-system-base coding-system)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
114 ;; (let ((eol-type (coding-system-eol-type coding-system)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
115 ;; (coding-system-change-eol-conversion
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
116 ;; coding
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
117 ;; (if (numberp eol-type) (aref [unix dos mac] eol-type))))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
118
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
119 (defun view-hello-file ()
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
120 "Display the HELLO file which list up many languages and characters."
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
121 (interactive)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
122 ;; We have to decode the file in any environment.
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
123 (let ((coding-system-for-read 'iso-2022-7bit))
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
124 (find-file-read-only (expand-file-name "HELLO" data-directory))))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
125
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
126 (defun universal-coding-system-argument ()
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
127 "Execute an I/O command using the specified coding system."
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
128 (interactive)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
129 (let* ((default (and buffer-file-coding-system
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
130 (not (eq (coding-system-type buffer-file-coding-system)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
131 t))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
132 (coding-system-name buffer-file-coding-system)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
133 (coding-system
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
134 (read-coding-system
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
135 (if default
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
136 (format "Coding system for following command (default, %s): "
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
137 default)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
138 "Coding system for following command: ")
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
139 default))
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
140 (keyseq (read-key-sequence
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
141 (format "Command to execute with %s:" coding-system)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
142 (cmd (key-binding keyseq)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
143 (let ((coding-system-for-read coding-system)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
144 (coding-system-for-write coding-system))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
145 (message "")
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
146 (call-interactively cmd))))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
147
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
148 (defun set-default-coding-systems (coding-system)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
149 "Set default value of various coding systems to CODING-SYSTEM.
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
150 This sets the following coding systems:
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
151 o coding system of a newly created buffer
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
152 o default coding system for terminal output
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
153 o default coding system for keyboard input
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
154 o default coding system for subprocess I/O
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
155 o default coding system for converting file names."
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
156 (check-coding-system coding-system)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
157 ;;(setq-default buffer-file-coding-system coding-system)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
158 (set-default-buffer-file-coding-system coding-system)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
159 ;; (if default-enable-multibyte-characters
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
160 ;; (setq default-file-name-coding-system coding-system))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
161 ;; If coding-system is nil, honor that on MS-DOS as well, so
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
162 ;; that they could reset the terminal coding system.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
163 ;; (unless (and (eq window-system 'pc) coding-system)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
164 ;; (setq default-terminal-coding-system coding-system))
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
165 (set-terminal-coding-system coding-system)
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
166 ;;(setq default-keyboard-coding-system coding-system)
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
167 (set-keyboard-coding-system coding-system)
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
168 ;;(setq default-process-coding-system (cons coding-system coding-system))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
169 ;; Refer to coding-system-for-read and coding-system-for-write
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
170 ;; so that C-x RET c works.
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
171 (add-hook 'comint-exec-hook
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
172 `(lambda ()
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
173 (let ((proc (get-buffer-process (current-buffer))))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
174 (set-process-input-coding-system
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
175 proc (or coding-system-for-read ',coding-system))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
176 (set-process-output-coding-system
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
177 proc (or coding-system-for-write ',coding-system))))
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
178 'append)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
179 (setq file-name-coding-system coding-system))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
180
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
181 (defun prefer-coding-system (coding-system)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
182 "Add CODING-SYSTEM at the front of the priority list for automatic detection.
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
183 This also sets the following coding systems:
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
184 o coding system of a newly created buffer
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
185 o default coding system for terminal output
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
186 o default coding system for keyboard input
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
187 o default coding system for converting file names.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
188
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
189 If CODING-SYSTEM specifies a certain type of EOL conversion, the coding
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
190 systems set by this function will use that type of EOL conversion.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
191
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
192 This command does not change the default value of terminal coding system
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
193 for MS-DOS terminal, because DOS terminals only support a single coding
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
194 system, and Emacs automatically sets the default to that coding system at
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
195 startup."
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
196 (interactive "zPrefer coding system: ")
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
197 (if (not (and coding-system (find-coding-system coding-system)))
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
198 (error "Invalid coding system `%s'" coding-system))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
199 (let ((coding-category (coding-system-category coding-system))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
200 (base (coding-system-base coding-system))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
201 (eol-type (coding-system-eol-type coding-system)))
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
202 (if (not coding-category)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
203 ;; CODING-SYSTEM is no-conversion or undecided.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
204 (error "Can't prefer the coding system `%s'" coding-system))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
205 (set-coding-category-system coding-category (or base coding-system))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
206 ;; (update-coding-systems-internal)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
207 (or (eq coding-category (car (coding-category-list)))
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
208 ;; We must change the order.
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
209 (set-coding-priority-list (list coding-category)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
210 (if (and base (interactive-p))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
211 (message "Highest priority is set to %s (base of %s)"
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
212 base coding-system))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
213 ;; If they asked for specific EOL conversion, honor that.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
214 (if (memq eol-type '(lf crlf mac))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
215 (setq coding-system
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
216 (coding-system-change-eol-conversion base eol-type))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
217 (setq coding-system base))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
218 (set-default-coding-systems coding-system)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
219
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
220 ;; (defun find-coding-systems-region-subset-p (list1 list2)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
221 ;; "Return non-nil if all elements in LIST1 are included in LIST2.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
222 ;; Comparison done with EQ."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
223 ;; (catch 'tag
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
224 ;; (while list1
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
225 ;; (or (memq (car list1) list2)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
226 ;; (throw 'tag nil))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
227 ;; (setq list1 (cdr list1)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
228 ;; t))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
229
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
230 ;; (defun find-coding-systems-region (from to)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
231 ;; "Return a list of proper coding systems to encode a text between FROM and TO.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
232 ;; All coding systems in the list can safely encode any multibyte characters
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
233 ;; in the text.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
234 ;;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
235 ;; If the text contains no multibyte characters, return a list of a single
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
236 ;; element `undecided'."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
237 ;; (find-coding-systems-for-charsets (find-charset-region from to)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
238
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
239 ;; (defun find-coding-systems-string (string)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
240 ;; "Return a list of proper coding systems to encode STRING.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
241 ;; All coding systems in the list can safely encode any multibyte characters
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
242 ;; in STRING.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
243 ;;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
244 ;; If STRING contains no multibyte characters, return a list of a single
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
245 ;; element `undecided'."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
246 ;; (find-coding-systems-for-charsets (find-charset-string string)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
247
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
248 ;; (defun find-coding-systems-for-charsets (charsets)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
249 ;; "Return a list of proper coding systems to encode characters of CHARSETS.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
250 ;; CHARSETS is a list of character sets."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
251 ;; (if (or (null charsets)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
252 ;; (and (= (length charsets) 1)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
253 ;; (eq 'ascii (car charsets))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
254 ;; '(undecided)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
255 ;; (setq charsets (delq 'composition charsets))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
256 ;; (let ((l (coding-system-list 'base-only))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
257 ;; (charset-preferred-codings
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
258 ;; (mapcar (function
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
259 ;; (lambda (x)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
260 ;; (if (eq x 'unknown)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
261 ;; 'raw-text
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
262 ;; (get-charset-property x 'preferred-coding-system))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
263 ;; charsets))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
264 ;; (priorities (mapcar (function (lambda (x) (symbol-value x)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
265 ;; coding-category-list))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
266 ;; codings coding safe)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
267 ;; (if (memq 'unknown charsets)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
268 ;; ;; The region contains invalid multibyte characters.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
269 ;; (setq l '(raw-text)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
270 ;; (while l
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
271 ;; (setq coding (car l) l (cdr l))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
272 ;; (if (and (setq safe (coding-system-get coding 'safe-charsets))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
273 ;; (or (eq safe t)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
274 ;; (find-coding-systems-region-subset-p charsets safe)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
275 ;; ;; We put the higher priority to coding systems included
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
276 ;; ;; in CHARSET-PREFERRED-CODINGS, and within them, put the
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
277 ;; ;; higher priority to coding systems which support smaller
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
278 ;; ;; number of charsets.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
279 ;; (let ((priority
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
280 ;; (+ (if (coding-system-get coding 'mime-charset) 4096 0)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
281 ;; (lsh (length (memq coding priorities)) 7)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
282 ;; (if (memq coding charset-preferred-codings) 64 0)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
283 ;; (if (> (coding-system-type coding) 0) 32 0)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
284 ;; (if (consp safe) (- 32 (length safe)) 0))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
285 ;; (setq codings (cons (cons priority coding) codings)))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
286 ;; (mapcar 'cdr
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
287 ;; (sort codings (function (lambda (x y) (> (car x) (car y))))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
288 ;; )))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
289
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
290 ;; (defun find-multibyte-characters (from to &optional maxcount excludes)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
291 ;; "Find multibyte characters in the region specified by FROM and TO.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
292 ;; If FROM is a string, find multibyte characters in the string.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
293 ;; The return value is an alist of the following format:
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
294 ;; ((CHARSET COUNT CHAR ...) ...)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
295 ;; where
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
296 ;; CHARSET is a character set,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
297 ;; COUNT is a number of characters,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
298 ;; CHARs are found characters of the character set.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
299 ;; Optional 3rd arg MAXCOUNT limits how many CHARs are put in the above list.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
300 ;; Optional 4th arg EXCLUDE is a list of character sets to be ignored.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
301 ;;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
302 ;; For invalid characters, CHARs are actually strings."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
303 ;; (let ((chars nil)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
304 ;; charset char)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
305 ;; (if (stringp from)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
306 ;; (let ((idx 0))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
307 ;; (while (setq idx (string-match "[^\000-\177]" from idx))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
308 ;; (setq char (aref from idx)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
309 ;; charset (char-charset char))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
310 ;; (if (eq charset 'unknown)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
311 ;; (setq char (match-string 0)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
312 ;; (if (or (eq charset 'unknown)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
313 ;; (not (or (eq excludes t) (memq charset excludes))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
314 ;; (let ((slot (assq charset chars)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
315 ;; (if slot
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
316 ;; (if (not (memq char (nthcdr 2 slot)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
317 ;; (let ((count (nth 1 slot)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
318 ;; (setcar (cdr slot) (1+ count))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
319 ;; (if (or (not maxcount) (< count maxcount))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
320 ;; (nconc slot (list char)))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
321 ;; (setq chars (cons (list charset 1 char) chars)))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
322 ;; (setq idx (1+ idx))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
323 ;; (save-excursion
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
324 ;; (goto-char from)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
325 ;; (while (re-search-forward "[^\000-\177]" to t)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
326 ;; (setq char (preceding-char)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
327 ;; charset (char-charset char))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
328 ;; (if (eq charset 'unknown)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
329 ;; (setq char (match-string 0)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
330 ;; (if (or (eq charset 'unknown)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
331 ;; (not (or (eq excludes t) (memq charset excludes))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
332 ;; (let ((slot (assq charset chars)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
333 ;; (if slot
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
334 ;; (if (not (member char (nthcdr 2 slot)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
335 ;; (let ((count (nth 1 slot)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
336 ;; (setcar (cdr slot) (1+ count))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
337 ;; (if (or (not maxcount) (< count maxcount))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
338 ;; (nconc slot (list char)))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
339 ;; (setq chars (cons (list charset 1 char) chars))))))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
340 ;; (nreverse chars)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
341
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
342 ;; (defvar last-coding-system-specified nil
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
343 ;; "Most recent coding system explicitly specified by the user when asked.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
344 ;; This variable is set whenever Emacs asks the user which coding system
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
345 ;; to use in order to write a file. If you set it to nil explicitly,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
346 ;; then call `write-region', then afterward this variable will be non-nil
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
347 ;; only if the user was explicitly asked and specified a coding system.")
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
348
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
349 ;; (defun select-safe-coding-system (from to &optional default-coding-system)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
350 ;; "Ask a user to select a safe coding system from candidates.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
351 ;; The candidates of coding systems which can safely encode a text
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
352 ;; between FROM and TO are shown in a popup window.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
353 ;;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
354 ;; Optional arg DEFAULT-CODING-SYSTEM specifies a coding system to be
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
355 ;; checked at first. If omitted, buffer-file-coding-system of the
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
356 ;; current buffer is used.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
357 ;;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
358 ;; If the text can be encoded safely by DEFAULT-CODING-SYSTEM, it is
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
359 ;; returned without any user interaction.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
360 ;;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
361 ;; Kludgy feature: if FROM is a string, the string is the target text,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
362 ;; and TO is ignored."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
363 ;; (or default-coding-system
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
364 ;; (setq default-coding-system buffer-file-coding-system))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
365 ;; (let* ((charsets (if (stringp from) (find-charset-string from)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
366 ;; (find-charset-region from to)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
367 ;; (safe-coding-systems (find-coding-systems-for-charsets charsets)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
368 ;; (if (or (not enable-multibyte-characters)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
369 ;; (eq (car safe-coding-systems) 'undecided)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
370 ;; (eq default-coding-system 'no-conversion)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
371 ;; (and default-coding-system
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
372 ;; (memq (coding-system-base default-coding-system)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
373 ;; safe-coding-systems)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
374 ;; default-coding-system
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
375 ;;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
376 ;; ;; At first, change each coding system to the corresponding
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
377 ;; ;; mime-charset name if it is also a coding system.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
378 ;; (let ((l safe-coding-systems)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
379 ;; mime-charset)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
380 ;; (while l
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
381 ;; (setq mime-charset (coding-system-get (car l) 'mime-charset))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
382 ;; (if (and mime-charset (coding-system-p mime-charset))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
383 ;; (setcar l mime-charset))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
384 ;; (setq l (cdr l))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
385 ;;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
386 ;; (let ((non-safe-chars (find-multibyte-characters
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
387 ;; from to 3
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
388 ;; (and default-coding-system
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
389 ;; (coding-system-get default-coding-system
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
390 ;; 'safe-charsets))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
391 ;; show-position overlays)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
392 ;; (save-excursion
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
393 ;; ;; Highlight characters that default-coding-system can't encode.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
394 ;; (when (integerp from)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
395 ;; (goto-char from)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
396 ;; (let ((found nil))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
397 ;; (while (and (not found)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
398 ;; (re-search-forward "[^\000-\177]" to t))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
399 ;; (setq found (assq (char-charset (preceding-char))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
400 ;; non-safe-chars))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
401 ;; (forward-line -1)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
402 ;; (setq show-position (point))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
403 ;; (save-excursion
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
404 ;; (while (and (< (length overlays) 256)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
405 ;; (re-search-forward "[^\000-\177]" to t))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
406 ;; (let* ((char (preceding-char))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
407 ;; (charset (char-charset char)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
408 ;; (when (assq charset non-safe-chars)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
409 ;; (setq overlays (cons (make-overlay (1- (point)) (point))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
410 ;; overlays))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
411 ;; (overlay-put (car overlays) 'face 'highlight))))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
412 ;;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
413 ;; ;; At last, ask a user to select a proper coding system.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
414 ;; (unwind-protect
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
415 ;; (save-window-excursion
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
416 ;; (when show-position
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
417 ;; ;; At first, be sure to show the current buffer.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
418 ;; (set-window-buffer (selected-window) (current-buffer))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
419 ;; (set-window-start (selected-window) show-position))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
420 ;; ;; Then, show a helpful message.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
421 ;; (with-output-to-temp-buffer "*Warning*"
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
422 ;; (save-excursion
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
423 ;; (set-buffer standard-output)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
424 ;; (insert "The target text contains the following non ASCII character(s):\n")
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
425 ;; (let ((len (length non-safe-chars))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
426 ;; (shown 0))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
427 ;; (while (and non-safe-chars (< shown 3))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
428 ;; (when (> (length (car non-safe-chars)) 2)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
429 ;; (setq shown (1+ shown))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
430 ;; (insert (format "%25s: " (car (car non-safe-chars))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
431 ;; (let ((l (nthcdr 2 (car non-safe-chars))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
432 ;; (while l
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
433 ;; (if (or (stringp (car l)) (char-valid-p (car l)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
434 ;; (insert (car l)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
435 ;; (setq l (cdr l))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
436 ;; (if (> (nth 1 (car non-safe-chars)) 3)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
437 ;; (insert "..."))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
438 ;; (insert "\n"))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
439 ;; (setq non-safe-chars (cdr non-safe-chars)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
440 ;; (if (< shown len)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
441 ;; (insert (format "%27s\n" "..."))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
442 ;; (insert (format "\
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
443 ;; These can't be encoded safely by the coding system %s.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
444 ;;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
445 ;; Please select one from the following safe coding systems:\n"
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
446 ;; default-coding-system))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
447 ;; (let ((pos (point))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
448 ;; (fill-prefix " "))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
449 ;; (mapcar (function (lambda (x) (princ " ") (princ x)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
450 ;; safe-coding-systems)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
451 ;; (fill-region-as-paragraph pos (point)))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
452 ;;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
453 ;; ;; Read a coding system.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
454 ;; (let* ((safe-names (mapcar (lambda (x) (list (symbol-name x)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
455 ;; safe-coding-systems))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
456 ;; (name (completing-read
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
457 ;; (format "Select coding system (default %s): "
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
458 ;; (car safe-coding-systems))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
459 ;; safe-names nil t nil nil
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
460 ;; (car (car safe-names)))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
461 ;; (setq last-coding-system-specified (intern name))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
462 ;; (if (integerp (coding-system-eol-type default-coding-system))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
463 ;; (setq last-coding-system-specified
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
464 ;; (coding-system-change-eol-conversion
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
465 ;; last-coding-system-specified
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
466 ;; (coding-system-eol-type default-coding-system))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
467 ;; last-coding-system-specified))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
468 ;; (kill-buffer "*Warning*")
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
469 ;; (while overlays
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
470 ;; (delete-overlay (car overlays))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
471 ;; (setq overlays (cdr overlays)))))))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
472
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
473 ;; (setq select-safe-coding-system-function 'select-safe-coding-system)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
474
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
475 ;; (defun select-message-coding-system ()
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
476 ;; "Return a coding system to encode the outgoing message of the current buffer.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
477 ;; It at first tries the first coding system found in these variables
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
478 ;; in this order:
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
479 ;; (1) local value of `buffer-file-coding-system'
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
480 ;; (2) value of `sendmail-coding-system'
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
481 ;; (3) value of `default-buffer-file-coding-system'
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
482 ;; (4) value of `default-sendmail-coding-system'
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
483 ;; If the found coding system can't encode the current buffer,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
484 ;; or none of them are bound to a coding system,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
485 ;; it asks the user to select a proper coding system."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
486 ;; (let ((coding (or (and (local-variable-p 'buffer-file-coding-system)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
487 ;; buffer-file-coding-system)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
488 ;; sendmail-coding-system
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
489 ;; default-buffer-file-coding-system
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
490 ;; default-sendmail-coding-system)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
491 ;; (if (eq coding 'no-conversion)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
492 ;; ;; We should never use no-conversion for outgoing mails.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
493 ;; (setq coding nil))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
494 ;; (if (fboundp select-safe-coding-system-function)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
495 ;; (funcall select-safe-coding-system-function
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
496 ;; (point-min) (point-max) coding)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
497 ;; coding)))
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
498
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
499 ;;; Language support stuff.
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
500
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
501 (defvar language-info-alist nil
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
502 "Alist of language environment definitions.
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
503 Each element looks like:
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
504 (LANGUAGE-NAME . ((KEY . INFO) ...))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
505 where LANGUAGE-NAME is a string, the name of the language environment,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
506 KEY is a symbol denoting the kind of information, and
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
507 INFO is the data associated with KEY.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
508 Meaningful values for KEY include
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
509
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
510 documentation value is documentation of what this language environment
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
511 is meant for, and how to use it.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
512 charset value is a list of the character sets used by this
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
513 language environment.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
514 sample-text value is one line of text,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
515 written using those character sets,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
516 appropriate for this language environment.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
517 setup-function value is a function to call to switch to this
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
518 language environment.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
519 exit-function value is a function to call to leave this
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
520 language environment.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
521 coding-system value is a list of coding systems that are good
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
522 for saving text written in this language environment.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
523 This list serves as suggestions to the user;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
524 in effect, as a kind of documentation.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
525 coding-priority value is a list of coding systems for this language
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
526 environment, in order of decreasing priority.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
527 This is used to set up the coding system priority
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
528 list when you switch to this language environment.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
529 input-method value is a default input method for this language
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
530 environment.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
531 features value is a list of features requested in this
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
532 language environment.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
533 tutorial value is a tutorial file name written in the language.")
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
534
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
535 (defun get-language-info (lang-env key)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
536 "Return information listed under KEY for language environment LANG-ENV.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
537 KEY is a symbol denoting the kind of information.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
538 For a list of useful values for KEY and their meanings,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
539 see `language-info-alist'."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
540 (if (symbolp lang-env)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
541 (setq lang-env (symbol-name lang-env)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
542 (let ((lang-slot (assoc-ignore-case lang-env language-info-alist)))
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
543 (if lang-slot
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
544 (cdr (assq key (cdr lang-slot))))))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
545
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
546 (defun set-language-info (lang-env key info)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
547 "Modify part of the definition of language environment LANG-ENV.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
548 Specifically, this stores the information INFO under KEY
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
549 in the definition of this language environment.
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
550 KEY is a symbol denoting the kind of information.
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
551 INFO is the value for that information.
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
552
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
553 For a list of useful values for KEY and their meanings,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
554 see `language-info-alist'."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
555 (if (symbolp lang-env)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
556 (setq lang-env (symbol-name lang-env)))
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
557 (let (lang-slot key-slot)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
558 (setq lang-slot (assoc lang-env language-info-alist))
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
559 (if (null lang-slot) ; If no slot for the language, add it.
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
560 (setq lang-slot (list lang-env)
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
561 language-info-alist (cons lang-slot language-info-alist)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
562 (setq key-slot (assq key lang-slot))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
563 (if (null key-slot) ; If no slot for the key, add it.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
564 (progn
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
565 (setq key-slot (list key))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
566 (setcdr lang-slot (cons key-slot (cdr lang-slot)))))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
567 (setcdr key-slot info)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
568
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
569 (defun set-language-info-alist (lang-env alist &optional parents)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
570 "Store ALIST as the definition of language environment LANG-ENV.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
571 ALIST is an alist of KEY and INFO values. See the documentation of
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
572 `set-language-info' for the meanings of KEY and INFO."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
573 (if (symbolp lang-env)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
574 (setq lang-env (symbol-name lang-env)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
575 (let (; (describe-map describe-language-environment-map)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
576 ; (setup-map setup-language-environment-map)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
577 )
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
578 ;; (if parents
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
579 ;; (let ((l parents)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
580 ;; map parent-symbol parent)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
581 ;; (while l
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
582 ;; (if (symbolp (setq parent-symbol (car l)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
583 ;; (setq parent (symbol-name parent))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
584 ;; (setq parent parent-symbol parent-symbol (intern parent)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
585 ;; (setq map (lookup-key describe-map (vector parent-symbol)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
586 ;; (if (not map)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
587 ;; (progn
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
588 ;; (setq map (intern (format "describe-%s-environment-map"
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
589 ;; (downcase parent))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
590 ;; (define-prefix-command map)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
591 ;; (define-key-after describe-map (vector parent-symbol)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
592 ;; (cons parent map) t)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
593 ;; (setq describe-map (symbol-value map))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
594 ;; (setq map (lookup-key setup-map (vector parent-symbol)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
595 ;; (if (not map)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
596 ;; (progn
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
597 ;; (setq map (intern (format "setup-%s-environment-map"
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
598 ;; (downcase parent))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
599 ;; (define-prefix-command map)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
600 ;; (define-key-after setup-map (vector parent-symbol)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
601 ;; (cons parent map) t)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
602 ;; (setq setup-map (symbol-value map))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
603 ;; (setq l (cdr l)))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
604
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
605 ;; Set up menu items for this language env.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
606 (let ((doc (assq 'documentation alist)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
607 (when doc
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
608 ;; (define-key-after describe-map (vector (intern lang-env))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
609 ;; (cons lang-env 'describe-specified-language-support) t)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
610 (when (featurep 'menubar)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
611 (eval-after-load
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
612 "menubar-items.elc"
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
613 `(add-menu-button
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
614 '("Mule" "Describe Language Support")
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
615 (vector ,lang-env
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
616 '(describe-language-environment ,lang-env)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
617 t))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
618 ))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
619 ;; (define-key-after setup-map (vector (intern lang-env))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
620 ;; (cons lang-env 'setup-specified-language-environment) t)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
621 (when (featurep 'menubar)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
622 (eval-after-load
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
623 "menubar-items.elc"
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
624 `(add-menu-button
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
625 '("Mule" "Set Language Environment")
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
626 (vector ,lang-env
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
627 '(set-language-environment ,lang-env)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
628 t))))
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
629
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
630 (while alist
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
631 (set-language-info lang-env (car (car alist)) (cdr (car alist)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
632 (setq alist (cdr alist)))))
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
633
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
634 (defun read-language-name (key prompt &optional default)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
635 "Read a language environment name which has information for KEY.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
636 If KEY is nil, read any language environment.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
637 Prompt with PROMPT. DEFAULT is the default choice of language environment.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
638 This returns a language environment name as a string."
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
639 (let* ((completion-ignore-case t)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
640 (name (completing-read prompt
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
641 language-info-alist
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
642 (and key
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
643 (function (lambda (elm) (assq key elm))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
644 t nil nil default)))
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
645 (if (and (> (length name) 0)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
646 (or (not key)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
647 (get-language-info name key)))
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
648 name)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
649
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
650 ;;; Multilingual input methods.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
651
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
652 (defconst leim-list-file-name "leim-list.el"
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
653 "Name of LEIM list file.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
654 This file contains a list of libraries of Emacs input methods (LEIM)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
655 in the format of Lisp expression for registering each input method.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
656 Emacs loads this file at startup time.")
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
657
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
658 (defvar leim-list-header (format
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
659 ";;; %s -- list of LEIM (Library of Emacs Input Method)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
660 ;;
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
661 ;; This file contains a list of LEIM (Library of Emacs Input Method)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
662 ;; in the same directory as this file. Loading this file registers
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
663 ;; the whole input methods in Emacs.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
664 ;;
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
665 ;; Each entry has the form:
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
666 ;; (register-input-method
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
667 ;; INPUT-METHOD LANGUAGE-NAME ACTIVATE-FUNC
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
668 ;; TITLE DESCRIPTION
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
669 ;; ARG ...)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
670 ;; See the function `register-input-method' for the meanings of arguments.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
671 ;;
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
672 ;; If this directory is included in load-path, Emacs automatically
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
673 ;; loads this file at startup time.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
674
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
675 "
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
676 leim-list-file-name)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
677 "Header to be inserted in LEIM list file.")
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
678
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
679 (defvar leim-list-entry-regexp "^(register-input-method"
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
680 "Regexp matching head of each entry in LEIM list file.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
681 See also the variable `leim-list-header'")
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
682
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
683 (defvar update-leim-list-functions
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
684 '(quail-update-leim-list-file)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
685 "List of functions to call to update LEIM list file.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
686 Each function is called with one arg, LEIM directory name.")
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
687
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
688 (defun update-leim-list-file (&rest dirs)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
689 "Update LEIM list file in directories DIRS."
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
690 (let ((functions update-leim-list-functions))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
691 (while functions
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
692 (apply (car functions) dirs)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
693 (setq functions (cdr functions)))))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
694
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
695 (defvar current-input-method nil
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
696 "The current input method for multilingual text.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
697 If nil, that means no input method is activated now.")
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
698 (make-variable-buffer-local 'current-input-method)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
699 (put 'current-input-method 'permanent-local t)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
700
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
701 (defvar current-input-method-title nil
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
702 "Title string of the current input method shown in mode line.")
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
703 (make-variable-buffer-local 'current-input-method-title)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
704 (put 'current-input-method-title 'permanent-local t)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
705
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
706 (defcustom default-input-method nil
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
707 "*Default input method for multilingual text (a string).
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
708 This is the input method activated automatically by the command
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
709 `toggle-input-method' (\\[toggle-input-method])."
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
710 :group 'mule
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
711 :type '(choice (const nil) string))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
712
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
713 (put 'input-method-function 'permanent-local t)
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
714
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
715 (defvar input-method-history nil
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
716 "History list for some commands that read input methods.")
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
717 (make-variable-buffer-local 'input-method-history)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
718 (put 'input-method-history 'permanent-local t)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
719
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
720 (defvar inactivate-current-input-method-function nil
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
721 "Function to call for inactivating the current input method.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
722 Every input method should set this to an appropriate value when activated.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
723 This function is called with no argument.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
724
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
725 This function should never change the value of `current-input-method'.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
726 It is set to nil by the function `inactivate-input-method'.")
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
727 (make-variable-buffer-local 'inactivate-current-input-method-function)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
728 (put 'inactivate-current-input-method-function 'permanent-local t)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
729
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
730 (defvar describe-current-input-method-function nil
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
731 "Function to call for describing the current input method.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
732 This function is called with no argument.")
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
733 (make-variable-buffer-local 'describe-current-input-method-function)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
734 (put 'describe-current-input-method-function 'permanent-local t)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
735
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
736 (defvar input-method-alist nil
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
737 "Alist of input method names vs how to use them.
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
738 Each element has the form:
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
739 (INPUT-METHOD LANGUAGE-ENV ACTIVATE-FUNC TITLE DESCRIPTION ARGS...)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
740 See the function `register-input-method' for the meanings of the elements.")
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
741
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
742 (defun register-input-method (input-method lang-env &rest args)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
743 "Register INPUT-METHOD as an input method for language environment ENV.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
744 INPUT-METHOD and LANG-ENV are symbols or strings.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
745
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
746 The remaining arguments are:
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
747 ACTIVATE-FUNC, TITLE, DESCRIPTION, and ARGS...
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
748 ACTIVATE-FUNC is a function to call to activate this method.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
749 TITLE is a string to show in the mode line when this method is active.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
750 DESCRIPTION is a string describing this method and what it is good for.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
751 The ARGS, if any, are passed as arguments to ACTIVATE-FUNC.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
752 All told, the arguments to ACTIVATE-FUNC are INPUT-METHOD and the ARGS.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
753
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
754 This function is mainly used in the file \"leim-list.el\" which is
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
755 created at building time of emacs, registering all quail input methods
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
756 contained in the emacs distribution.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
757
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
758 In case you want to register a new quail input method by yourself, be
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
759 careful to use the same input method title as given in the third
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
760 parameter of `quail-define-package' (if the values are different, the
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
761 string specified in this function takes precedence).
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
762
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
763 The commands `describe-input-method' and `list-input-methods' need
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
764 this duplicated values to show some information about input methods
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
765 without loading the affected quail packages."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
766 (if (symbolp lang-env)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
767 (setq lang-env (symbol-name lang-env)))
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
768 (if (symbolp input-method)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
769 (setq input-method (symbol-name input-method)))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
770 (let ((info (cons lang-env args))
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
771 (slot (assoc input-method input-method-alist)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
772 (if slot
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
773 (setcdr slot info)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
774 (setq slot (cons input-method info))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
775 (setq input-method-alist (cons slot input-method-alist)))))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
776
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
777 (defun read-input-method-name (prompt &optional default inhibit-null)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
778 "Read a name of input method from a minibuffer prompting with PROMPT.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
779 If DEFAULT is non-nil, use that as the default,
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
780 and substitute it into PROMPT at the first `%s'.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
781 If INHIBIT-NULL is non-nil, null input signals an error.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
782
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
783 The return value is a string."
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
784 (if default
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
785 (setq prompt (format prompt default)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
786 (let* ((completion-ignore-case t)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
787 ;; This binding is necessary because input-method-history is
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
788 ;; buffer local.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
789 (input-method (completing-read prompt input-method-alist
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
790 nil t nil 'input-method-history
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
791 default)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
792 (if (and input-method (symbolp input-method))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
793 (setq input-method (symbol-name input-method)))
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
794 (if (> (length input-method) 0)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
795 input-method
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
796 (if inhibit-null
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
797 (error "No valid input method is specified")))))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
798
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
799 (defun activate-input-method (input-method)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
800 "Switch to input method INPUT-METHOD for the current buffer.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
801 If some other input method is already active, turn it off first.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
802 If INPUT-METHOD is nil, deactivate any current input method."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
803 (if (and input-method (symbolp input-method))
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
804 (setq input-method (symbol-name input-method)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
805 (if (and current-input-method
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
806 (not (string= current-input-method input-method)))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
807 (inactivate-input-method))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
808 (unless (or current-input-method (null input-method))
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
809 (let ((slot (assoc input-method input-method-alist)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
810 (if (null slot)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
811 (error "Can't activate input method `%s'" input-method))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
812 (let ((func (nth 2 slot)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
813 (if (functionp func)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
814 (apply (nth 2 slot) input-method (nthcdr 5 slot))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
815 (if (and (consp func) (symbolp (car func)) (symbolp (cdr func)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
816 (progn
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
817 (require (cdr func))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
818 (apply (car func) input-method (nthcdr 5 slot)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
819 (error "Can't activate input method `%s'" input-method))))
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
820 (setq current-input-method input-method)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
821 (setq current-input-method-title (nth 3 slot))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
822 (unwind-protect
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
823 (run-hooks 'input-method-activate-hook)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
824 (force-mode-line-update)))))
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
825
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
826 (defun inactivate-input-method ()
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
827 "Turn off the current input method."
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
828 (when current-input-method
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
829 (if input-method-history
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
830 (unless (string= current-input-method (car input-method-history))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
831 (setq input-method-history
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
832 (cons current-input-method
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
833 (delete current-input-method input-method-history))))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
834 (setq input-method-history (list current-input-method)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
835 (unwind-protect
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
836 (funcall inactivate-current-input-method-function)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
837 (unwind-protect
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
838 (run-hooks 'input-method-inactivate-hook)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
839 (setq current-input-method nil
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
840 current-input-method-title nil)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
841 (force-mode-line-update)))))
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
842
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
843 (defun set-input-method (input-method)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
844 "Select and activate input method INPUT-METHOD for the current buffer.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
845 This also sets the default input method to the one you specify."
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
846 (interactive
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
847 (let* ((default (or (car input-method-history) default-input-method)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
848 (list (read-input-method-name
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
849 (if default "Select input method (default %s): " "Select input method: ")
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
850 default t))))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
851 (activate-input-method input-method)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
852 (setq default-input-method input-method))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
853
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
854 (defun toggle-input-method (&optional arg)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
855 "Turn on or off a multilingual text input method for the current buffer.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
856
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
857 With no prefix argument, if an input method is currently activated,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
858 turn it off. Otherwise, activate an input method -- the one most
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
859 recently used, or the one specified in `default-input-method', or
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
860 the one read from the minibuffer.
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
861
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
862 With a prefix argument, read an input method from the minibuffer and
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
863 turn it on.
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
864
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
865 The default is to use the most recent input method specified
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
866 \(not including the currently active input method, if any)."
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
867 (interactive "P")
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
868 (if (and current-input-method (not arg))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
869 (inactivate-input-method)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
870 (let ((default (or (car input-method-history) default-input-method)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
871 (if (and arg default (equal current-input-method default)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
872 (> (length input-method-history) 1))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
873 (setq default (nth 1 input-method-history)))
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
874 (activate-input-method
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
875 (if (or arg (not default))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
876 (progn
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
877 (read-input-method-name
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
878 (if default "Input method (default %s): " "Input method: " )
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
879 default t))
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
880 default))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
881 (or default-input-method
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
882 (setq default-input-method current-input-method)))))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
883
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
884 (defun describe-input-method (input-method)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
885 "Describe input method INPUT-METHOD."
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
886 (interactive
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
887 (list (read-input-method-name
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
888 "Describe input method (default, current choice): ")))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
889 (if (and input-method (symbolp input-method))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
890 (setq input-method (symbol-name input-method)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
891 (if (null input-method)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
892 (describe-current-input-method)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
893 (with-output-to-temp-buffer "*Help*"
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
894 (let ((elt (assoc input-method input-method-alist)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
895 (princ (format "Input method: %s (`%s' in mode line) for %s\n %s\n"
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
896 input-method (nth 3 elt) (nth 1 elt) (nth 4 elt)))))))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
897
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
898 (defun describe-current-input-method ()
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
899 "Describe the input method currently in use."
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
900 (if current-input-method
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
901 (if (and (symbolp describe-current-input-method-function)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
902 (fboundp describe-current-input-method-function))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
903 (funcall describe-current-input-method-function)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
904 (message "No way to describe the current input method `%s'"
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
905 current-input-method)
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
906 (ding))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
907 (error "No input method is activated now")))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
908
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
909 (defun read-multilingual-string (prompt &optional initial-input input-method)
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
910 "Read a multilingual string from minibuffer, prompting with string PROMPT.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
911 The input method selected last time is activated in minibuffer.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
912 If optional second arg INITIAL-INPUT is non-nil, insert it in the minibuffer
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
913 initially.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
914 Optional 3rd argument INPUT-METHOD specifies the input method
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
915 to be activated instead of the one selected last time. It is a symbol
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
916 or a string."
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
917 (setq input-method
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
918 (or input-method
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
919 current-input-method
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
920 default-input-method
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
921 (read-input-method-name "Input method: " nil t)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
922 (if (and input-method (symbolp input-method))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
923 (setq input-method (symbol-name input-method)))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
924 (let ((prev-input-method current-input-method))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
925 (unwind-protect
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
926 (progn
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
927 (activate-input-method input-method)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
928 ;; FSF Emacs
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
929 ;; (read-string prompt initial-input nil nil t)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
930 (read-string prompt initial-input nil))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
931 (activate-input-method prev-input-method))))
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
932
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
933 ;; Variables to control behavior of input methods. All input methods
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
934 ;; should react to these variables.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
935
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
936 (defcustom input-method-verbose-flag 'default
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
937 "*A flag to control extra guidance given by input methods.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
938 The value should be nil, t, `complex-only', or `default'.
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
939
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
940 The extra guidance is done by showing list of available keys in echo
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
941 area. When you use the input method in the minibuffer, the guidance
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
942 is shown at the bottom short window (split from the existing window).
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
943
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
944 If the value is t, extra guidance is always given, if the value is
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
945 nil, extra guidance is always suppressed.
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
946
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
947 If the value is `complex-only', only complex input methods such as
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
948 `chinese-py' and `japanese' give extra guidance.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
949
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
950 If the value is `default', complex input methods always give extra
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
951 guidance, but simple input methods give it only when you are not in
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
952 the minibuffer.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
953
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
954 See also the variable `input-method-highlight-flag'."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
955 :type '(choice (const t) (const nil) (const complex-only) (const default))
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
956 :group 'mule)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
957
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
958 (defcustom input-method-highlight-flag t
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
959 "*If this flag is non-nil, input methods highlight partially-entered text.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
960 For instance, while you are in the middle of a Quail input method sequence,
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
961 the text inserted so far is temporarily underlined.
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
962 The underlining goes away when you finish or abort the input method sequence.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
963 See also the variable `input-method-verbose-flag'."
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
964 :type 'boolean
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
965 :group 'mule)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
966
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
967 (defvar input-method-activate-hook nil
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
968 "Normal hook run just after an input method is activated.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
969
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
970 The variable `current-input-method' keeps the input method name
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
971 just activated.")
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
972
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
973 (defvar input-method-inactivate-hook nil
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
974 "Normal hook run just after an input method is inactivated.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
975
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
976 The variable `current-input-method' still keeps the input method name
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
977 just inactivated.")
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
978
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
979 (defvar input-method-after-insert-chunk-hook nil
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
980 "Normal hook run just after an input method insert some chunk of text.")
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
981
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
982 (defvar input-method-exit-on-first-char nil
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
983 "This flag controls a timing when an input method returns.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
984 Usually, the input method does not return while there's a possibility
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
985 that it may find a different translation if a user types another key.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
986 But, it this flag is non-nil, the input method returns as soon as
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
987 the current key sequence gets long enough to have some valid translation.")
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
988
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
989 (defvar input-method-use-echo-area nil
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
990 "This flag controls how an input method shows an intermediate key sequence.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
991 Usually, the input method inserts the intermediate key sequence,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
992 or candidate translations corresponding to the sequence,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
993 at point in the current buffer.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
994 But, if this flag is non-nil, it displays them in echo area instead.")
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
995
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
996 (defvar input-method-exit-on-invalid-key nil
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
997 "This flag controls the behaviour of an input method on invalid key input.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
998 Usually, when a user types a key which doesn't start any character
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
999 handled by the input method, the key is handled by turning off the
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1000 input method temporarily. After that key, the input method is re-enabled.
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1001 But, if this flag is non-nil, the input method is never back on.")
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1002
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1003
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1004 (defvar set-language-environment-hook nil
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1005 "Normal hook run after some language environment is set.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1006
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1007 When you set some hook function here, that effect usually should not
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1008 be inherited to another language environment. So, you had better set
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1009 another function in `exit-language-environment-hook' (which see) to
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1010 cancel the effect.")
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1011
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1012 (defvar exit-language-environment-hook nil
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1013 "Normal hook run after exiting from some language environment.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1014 When this hook is run, the variable `current-language-environment'
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1015 is still bound to the language environment being exited.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1016
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1017 This hook is mainly used for canceling the effect of
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1018 `set-language-environment-hook' (which-see).")
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1019
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1020 (put 'setup-specified-language-environment 'apropos-inhibit t)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1021
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1022 (defun setup-specified-language-environment ()
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1023 "Switch to a specified language environment."
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1024 (interactive)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1025 (let (language-name)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1026 (if (and (symbolp last-command-event)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1027 (or (not (eq last-command-event 'Default))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1028 (setq last-command-event 'English))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1029 (setq language-name (symbol-name last-command-event)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1030 (set-language-environment language-name)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1031 (error "Bogus calling sequence"))))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1032
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1033 (defcustom current-language-environment "English"
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1034 "The last language environment specified with `set-language-environment'.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1035 This variable should be set only with \\[customize], which is equivalent
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1036 to using the function `set-language-environment'."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1037 :link '(custom-manual "(emacs)Language Environments")
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1038 :set (lambda (symbol value) (set-language-environment value))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1039 :get (lambda (x)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1040 (or (car-safe (assoc-ignore-case
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1041 (if (symbolp current-language-environment)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1042 (symbol-name current-language-environment)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1043 current-language-environment)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1044 language-info-alist))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1045 "English"))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1046 :type (cons 'choice (mapcar (lambda (lang)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1047 (list 'const (car lang)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1048 language-info-alist))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1049 :initialize 'custom-initialize-default
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1050 :group 'mule
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1051 :type 'string)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1052
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1053 (defun reset-language-environment ()
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1054 "Reset multilingual environment of Emacs to the default status.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1055
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1056 The default status is as follows:
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1057
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1058 The default value of buffer-file-coding-system is nil.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1059 The default coding system for process I/O is nil.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1060 The default value for the command `set-terminal-coding-system' is nil.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1061 The default value for the command `set-keyboard-coding-system' is nil.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1062
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1063 The order of priorities of coding categories and the coding system
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1064 bound to each category are as follows
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1065 coding category coding system
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1066 --------------------------------------------------
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1067 iso-8-2 iso-8859-1
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1068 iso-8-1 iso-8859-1
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1069 iso-7 iso-2022-7bit
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1070 iso-lock-shift iso-2022-lock
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1071 iso-8-designate iso-2022-8bit-ss2
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1072 no-conversion raw-text
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1073 shift-jis shift_jis
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1074 big5 big5
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1075 ucs-4 ----
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1076 utf-8 ----
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1077 "
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1078 (interactive)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1079 ;; This function formerly set default-enable-multibyte-characters to t,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1080 ;; but that is incorrect. It should not alter the unibyte/multibyte choice.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1081
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1082 (set-coding-category-system 'iso-7 'iso-2022-7bit)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1083 (set-coding-category-system 'iso-8-1 'iso-8859-1)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1084 (set-coding-category-system 'iso-8-2 'iso-8859-1)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1085 (set-coding-category-system 'iso-lock-shift 'iso-2022-lock)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1086 (set-coding-category-system 'iso-8-designate 'iso-2022-8bit-ss2)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1087 (set-coding-category-system 'no-conversion 'raw-text)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1088 (set-coding-category-system 'shift-jis 'shift_jis)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1089 (set-coding-category-system 'big5 'big5)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1090 (cond ((eq (coding-system-type (coding-category-system 'utf-8)) 'utf-8)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1091 (set-coding-category-system 'ucs-4 'iso-10646-ucs-4)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1092 (set-coding-category-system 'utf-8 'utf-8)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1093 (set-coding-priority-list
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1094 '(iso-8-1
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1095 iso-8-2
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1096 iso-7
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1097 iso-lock-shift
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1098 iso-8-designate
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1099 utf-8
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1100 ucs-4
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1101 no-conversion
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1102 shift-jis
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1103 big5))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1104 )
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1105 (t
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1106 (set-coding-priority-list
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1107 '(iso-8-1
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1108 iso-8-2
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1109 iso-7
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1110 iso-lock-shift
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1111 iso-8-designate
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1112 no-conversion
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1113 shift-jis
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1114 big5))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1115 ))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1116
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1117 ;; (update-coding-systems-internal)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1118
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1119 (set-default-coding-systems nil)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1120 ;; Don't alter the terminal and keyboard coding systems here.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1121 ;; The terminal still supports the same coding system
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1122 ;; that it supported a minute ago.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1123 ;;; (set-terminal-coding-system-internal nil)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1124 ;;; (set-keyboard-coding-system-internal nil)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1125
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1126 ;; (setq nonascii-translation-table nil
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1127 ;; nonascii-insert-offset 0)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1128 )
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1129
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1130 (defun set-language-environment (language-name)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1131 "Set up multi-lingual environment for using LANGUAGE-NAME.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1132 This sets the coding system priority and the default input method
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1133 and sometimes other things. LANGUAGE-NAME should be a string
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1134 which is the name of a language environment. For example, \"Latin-1\"
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1135 specifies the character set for the major languages of Western Europe."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1136 (interactive (list (read-language-name
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1137 nil
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1138 "Set language environment (default, English): ")))
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1139 (if language-name
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1140 (if (symbolp language-name)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1141 (setq language-name (symbol-name language-name)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1142 (setq language-name "English"))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1143 (or (assoc-ignore-case language-name language-info-alist)
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1144 (error "Language environment not defined: %S" language-name))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1145 (if current-language-environment
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1146 (let ((func (get-language-info current-language-environment
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1147 'exit-function)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1148 (run-hooks 'exit-language-environment-hook)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1149 (if (fboundp func) (funcall func))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1150 (let ((default-eol-type (coding-system-eol-type
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1151 default-buffer-file-coding-system)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1152 (reset-language-environment)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1153
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1154 (setq current-language-environment language-name)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1155 (set-language-environment-coding-systems language-name default-eol-type))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1156 (let ((input-method (get-language-info language-name 'input-method)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1157 (when input-method
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1158 (setq default-input-method input-method)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1159 (if input-method-history
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1160 (setq input-method-history
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1161 (cons input-method
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1162 (delete input-method input-method-history))))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1163 ;; (let ((nonascii (get-language-info language-name 'nonascii-translation))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1164 ;; (dos-table
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1165 ;; (if (eq window-system 'pc)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1166 ;; (intern
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1167 ;; (concat "cp" dos-codepage "-nonascii-translation-table")))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1168 ;; (cond
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1169 ;; ((char-table-p nonascii)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1170 ;; (setq nonascii-translation-table nonascii))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1171 ;; ((and (eq window-system 'pc) (boundp dos-table))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1172 ;; ;; DOS terminals' default is to use a special non-ASCII translation
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1173 ;; ;; table as appropriate for the installed codepage.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1174 ;; (setq nonascii-translation-table (symbol-value dos-table)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1175 ;; ((charsetp nonascii)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1176 ;; (setq nonascii-insert-offset (- (make-char nonascii) 128)))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1177
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1178 ;; (setq charset-origin-alist
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1179 ;; (get-language-info language-name 'charset-origin-alist))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1180
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1181 ;; Unibyte setups if necessary.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1182 ;; (unless default-enable-multibyte-characters
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1183 ;; ;; Syntax and case table.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1184 ;; (let ((syntax (get-language-info language-name 'unibyte-syntax)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1185 ;; (if syntax
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1186 ;; (let ((set-case-syntax-set-multibyte nil))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1187 ;; (load syntax nil t))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1188 ;; ;; No information for syntax and case. Reset to the defaults.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1189 ;; (let ((syntax-table (standard-syntax-table))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1190 ;; (case-table (standard-case-table))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1191 ;; (ch (if (eq window-system 'pc) 128 160)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1192 ;; (while (< ch 256)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1193 ;; (modify-syntax-entry ch " " syntax-table)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1194 ;; (aset case-table ch ch)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1195 ;; (setq ch (1+ ch)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1196 ;; (set-char-table-extra-slot case-table 0 nil)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1197 ;; (set-char-table-extra-slot case-table 1 nil)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1198 ;; (set-char-table-extra-slot case-table 2 nil))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1199 ;; (set-standard-case-table (standard-case-table))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1200 ;; (let ((list (buffer-list)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1201 ;; (while list
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1202 ;; (with-current-buffer (car list)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1203 ;; (set-case-table (standard-case-table)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1204 ;; (setq list (cdr list))))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1205 ;; ;; Display table and coding system for terminal.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1206 ;; (let ((coding (get-language-info language-name 'unibyte-display)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1207 ;; (if coding
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1208 ;; (standard-display-european-internal)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1209 ;; (standard-display-default (if (eq window-system 'pc) 128 160) 255)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1210 ;; (aset standard-display-table 146 nil))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1211 ;; (or (eq window-system 'pc)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1212 ;; (set-terminal-coding-system coding))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1213
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1214 (let ((required-features (get-language-info language-name 'features)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1215 (while required-features
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1216 (require (car required-features))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1217 (setq required-features (cdr required-features))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1218 (let ((func (get-language-info language-name 'setup-function)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1219 (if (fboundp func)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1220 (funcall func)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1221 (run-hooks 'set-language-environment-hook)
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1222 (force-mode-line-update t))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1223
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1224 ;; (defun standard-display-european-internal ()
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1225 ;; ;; Actually set up direct output of non-ASCII characters.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1226 ;; (standard-display-8bit (if (eq window-system 'pc) 128 160) 255)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1227 ;; ;; Unibyte Emacs on MS-DOS wants to display all 8-bit characters with
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1228 ;; ;; the native font, and codes 160 and 146 stand for something very
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1229 ;; ;; different there.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1230 ;; (or (and (eq window-system 'pc) (not default-enable-multibyte-characters))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1231 ;; (progn
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1232 ;; ;; Make non-line-break space display as a plain space.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1233 ;; ;; Most X fonts do the wrong thing for code 160.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1234 ;; (aset standard-display-table 160 [32])
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1235 ;; ;; Most Windows programs send out apostrophe's as \222. Most X fonts
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1236 ;; ;; don't contain a character at that position. Map it to the ASCII
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1237 ;; ;; apostrophe.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1238 ;; (aset standard-display-table 146 [39]))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1239
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1240 (defun set-language-environment-coding-systems (language-name
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1241 &optional eol-type)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1242 "Do various coding system setups for language environment LANGUAGE-NAME.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1243
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1244 The optional arg EOL-TYPE specifies the eol-type of the default value
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1245 of buffer-file-coding-system set by this function."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1246 (let* ((priority (get-language-info language-name 'coding-priority))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1247 (default-coding (car priority)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1248 (if priority
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1249 (let ((categories (mapcar 'coding-system-category priority))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1250 category checked-categories)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1251 (set-default-coding-systems
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1252 (if (memq eol-type '(lf crlf cr unix dos mac))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1253 (coding-system-change-eol-conversion default-coding eol-type)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1254 default-coding))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1255 ;; (setq default-sendmail-coding-system default-coding)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1256 (while priority
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1257 (unless (memq (setq category (car categories)) checked-categories)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1258 (set-coding-category-system category (car priority))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1259 (setq checked-categories (cons category checked-categories)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1260 (setq priority (cdr priority)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1261 categories (cdr categories)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1262 (set-coding-priority-list (nreverse checked-categories))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1263 ;; (update-coding-systems-internal)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1264 ))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1265
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1266 ;; Print all arguments with `princ', then print "\n".
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1267 (defsubst princ-list (&rest args)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1268 (while args (princ (car args)) (setq args (cdr args)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1269 (princ "\n"))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1270
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1271 (put 'describe-specified-language-support 'apropos-inhibit t)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1272
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1273 ;; Print a language specific information such as input methods,
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1274 ;; charsets, and coding systems. This function is intended to be
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1275 ;; called from the menu:
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1276 ;; [menu-bar mule describe-language-environment LANGUAGE]
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1277 ;; and should not run it by `M-x describe-current-input-method-function'.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1278 (defun describe-specified-language-support ()
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1279 "Describe how Emacs supports the specified language environment."
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1280 (interactive)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1281 (let (language-name)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1282 (if (not (and (symbolp last-command-event)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1283 (setq language-name (symbol-name last-command-event))))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1284 (error "Bogus calling sequence"))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1285 (describe-language-environment language-name)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1286
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1287 (defun describe-language-environment (language-name)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1288 "Describe how Emacs supports language environment LANGUAGE-NAME."
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1289 (interactive
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1290 (list (read-language-name
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1291 'documentation
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1292 "Describe language environment (default, current choice): ")))
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1293 (if (null language-name)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1294 (setq language-name current-language-environment))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1295 (if (or (null language-name)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1296 (null (get-language-info language-name 'documentation)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1297 (error "No documentation for the specified language"))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1298 (if (symbolp language-name)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1299 (setq language-name (symbol-name language-name)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1300 (let ((doc (get-language-info language-name 'documentation)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1301 (with-output-to-temp-buffer "*Help*"
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1302 (princ-list language-name " language environment" "\n")
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1303 (if (stringp doc)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1304 (progn
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1305 (princ-list doc)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1306 (terpri)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1307 (let ((str (get-language-info language-name 'sample-text)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1308 (if (stringp str)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1309 (progn
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1310 (princ "Sample text:\n")
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1311 (princ-list " " str)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1312 (terpri))))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1313 (let ((input-method (get-language-info language-name 'input-method))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1314 (l (copy-sequence input-method-alist)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1315 (princ "Input methods")
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1316 (when input-method
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1317 (princ (format " (default, %s)" input-method))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1318 (setq input-method (assoc input-method input-method-alist))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1319 (setq l (cons input-method (delete input-method l))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1320 (princ ":\n")
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1321 (while l
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1322 (if (string= language-name (nth 1 (car l)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1323 (princ-list " " (car (car l))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1324 (format " (`%s' in mode line)" (nth 3 (car l)))))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1325 (setq l (cdr l))))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1326 (terpri)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1327 (princ "Character sets:\n")
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1328 (let ((l (get-language-info language-name 'charset)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1329 (if (null l)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1330 (princ-list " nothing specific to " language-name)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1331 (while l
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1332 (princ-list " " (car l) ": "
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1333 (charset-description (car l)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1334 (setq l (cdr l)))))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1335 (terpri)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1336 (princ "Coding systems:\n")
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1337 (let ((l (get-language-info language-name 'coding-system)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1338 (if (null l)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1339 (princ-list " nothing specific to " language-name)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1340 (while l
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1341 (princ ; (format " %s (`%c' in mode line):\n\t%s\n"
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1342 ;; In XEmacs, `coding-system-mnemonic' returns string.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1343 (format " %s (`%s' in mode line):\n\t%s\n"
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1344 (car l)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1345 (coding-system-mnemonic (car l))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1346 (coding-system-doc-string (car l))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1347 ;; (let ((aliases (coding-system-get (car l) 'alias-coding-systems)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1348 ;; (when aliases
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1349 ;; (princ "\t")
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1350 ;; (princ (cons 'alias: (cdr aliases)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1351 ;; (terpri)))
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1352 (setq l (cdr l))))))))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1353
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1354 ;;; Charset property
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1355
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1356 ;; (defsubst get-charset-property (charset propname)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1357 ;; "Return the value of CHARSET's PROPNAME property.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1358 ;; This is the last value stored with
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1359 ;; `(put-charset-property CHARSET PROPNAME VALUE)'."
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1360 ;; (plist-get (charset-plist charset) propname))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1361
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1362 ;; (defsubst put-charset-property (charset propname value)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1363 ;; "Store CHARSETS's PROPNAME property with value VALUE.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1364 ;; It can be retrieved with `(get-charset-property CHARSET PROPNAME)'."
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1365 ;; (set-charset-plist charset
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1366 ;; (plist-put (charset-plist charset) propname value)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1367
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1368 (defvar char-code-property-table
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1369 (make-char-table 'generic)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1370 "Char-table containing a property list of each character code.
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1371
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1372 See also the documentation of `get-char-code-property' and
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1373 `put-char-code-property'")
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1374 ;; (let ((plist (aref char-code-property-table char)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1375 (defun get-char-code-property (char propname)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1376 "Return the value of CHAR's PROPNAME property in `char-code-property-table'."
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1377 (let ((plist (get-char-table char char-code-property-table)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1378 (if (listp plist)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1379 (car (cdr (memq propname plist))))))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1380
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1381 (defun put-char-code-property (char propname value)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1382 "Store CHAR's PROPNAME property with VALUE in `char-code-property-table'.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1383 It can be retrieved with `(get-char-code-property CHAR PROPNAME)'."
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1384 (let ((plist (get-char-table char char-code-property-table)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1385 (if plist
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1386 (let ((slot (memq propname plist)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1387 (if slot
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1388 (setcar (cdr slot) value)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1389 (nconc plist (list propname value))))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1390 (put-char-table char (list propname value) char-code-property-table)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1391 )))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1392
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1393
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1394 ;; Pretty description of encoded string
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1395
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1396 ;; Alist of ISO 2022 control code vs the corresponding mnemonic string.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1397 ;; (defvar iso-2022-control-alist
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1398 ;; '((?\x1b . "ESC")
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1399 ;; (?\x0e . "SO")
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1400 ;; (?\x0f . "SI")
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1401 ;; (?\x8e . "SS2")
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1402 ;; (?\x8f . "SS3")
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1403 ;; (?\x9b . "CSI")))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1404
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1405 ;; (defun encoded-string-description (str coding-system)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1406 ;; "Return a pretty description of STR that is encoded by CODING-SYSTEM."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1407 ;; (setq str (string-as-unibyte str))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1408 ;; (let ((char (aref str 0))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1409 ;; desc)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1410 ;; (when (< char 128)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1411 ;; (setq desc (or (cdr (assq char iso-2022-control-alist))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1412 ;; (char-to-string char)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1413 ;; (let ((i 1)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1414 ;; (len (length str)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1415 ;; (while (< i len)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1416 ;; (setq char (aref str i))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1417 ;; (if (>= char 128)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1418 ;; (setq desc nil i len)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1419 ;; (setq desc (concat desc " "
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1420 ;; (or (cdr (assq char iso-2022-control-alist))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1421 ;; (char-to-string char)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1422 ;; i (1+ i))))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1423 ;; (or desc
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1424 ;; (mapconcat (function (lambda (x) (format "0x%02x" x))) str " "))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1425
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1426 ;; (defun encode-coding-char (char coding-system)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1427 ;; "Encode CHAR by CODING-SYSTEM and return the resulting string.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1428 ;; If CODING-SYSTEM can't safely encode CHAR, return nil."
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1429 ;; (if (cmpcharp char)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1430 ;; (setq char (car (decompose-composite-char char 'list))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1431 ;; (let ((str1 (char-to-string char))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1432 ;; (str2 (make-string 2 char))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1433 ;; (safe-charsets (and coding-system
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1434 ;; (coding-system-get coding-system 'safe-charsets)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1435 ;; enc1 enc2 i1 i2)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1436 ;; (when (or (eq safe-charsets t)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1437 ;; (memq (char-charset char) safe-charsets))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1438 ;; ;; We must find the encoded string of CHAR. But, just encoding
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1439 ;; ;; CHAR will put extra control sequences (usually to designate
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1440 ;; ;; ASCII charset) at the tail if type of CODING is ISO 2022.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1441 ;; ;; To exclude such tailing bytes, we at first encode one-char
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1442 ;; ;; string and two-char string, then check how many bytes at the
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1443 ;; ;; tail of both encoded strings are the same.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1444 ;;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1445 ;; (setq enc1 (string-as-unibyte (encode-coding-string str1 coding-system))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1446 ;; i1 (length enc1)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1447 ;; enc2 (string-as-unibyte (encode-coding-string str2 coding-system))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1448 ;; i2 (length enc2))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1449 ;; (while (and (> i1 0) (= (aref enc1 (1- i1)) (aref enc2 (1- i2))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1450 ;; (setq i1 (1- i1) i2 (1- i2)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1451 ;;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1452 ;; ;; Now (substring enc1 i1) and (substring enc2 i2) are the same,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1453 ;; ;; and they are the extra control sequences at the tail to
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1454 ;; ;; exclude.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1455 ;; (substring enc2 0 i2))))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 333
diff changeset
1456
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1457
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1458 ;;; mule-cmds.el ends here