187
|
1 ;;; mule-cmds.el --- Commands for multilingual environment
|
155
|
2
|
|
3 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
|
197
|
4 ;; Licensed to the Free Software Foundation.
|
155
|
5 ;; Copyright (C) 1997 MORIOKA Tomohiko
|
|
6
|
|
7 ;; Keywords: mule, multilingual
|
|
8
|
|
9 ;; This file is part of XEmacs.
|
|
10
|
|
11 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
12 ;; under the terms of the GNU General Public License as published by
|
|
13 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
14 ;; any later version.
|
|
15
|
|
16 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
19 ;; General Public License for more details.
|
|
20
|
|
21 ;; You should have received a copy of the GNU General Public License
|
|
22 ;; along with XEmacs; see the file COPYING. If not, write to the Free
|
|
23 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
24 ;; 02111-1307, USA.
|
|
25
|
|
26 ;;; Code:
|
|
27
|
|
28 ;;; MULE related key bindings and menus.
|
|
29
|
|
30 (defvar mule-keymap (make-sparse-keymap "MULE")
|
|
31 "Keymap for MULE (Multilingual environment) specific commands.")
|
|
32 (fset 'mule-prefix mule-keymap)
|
|
33
|
165
|
34 ;; Keep "C-x C-m ..." for mule specific commands.
|
|
35 (define-key ctl-x-map "\C-m" 'mule-prefix)
|
155
|
36
|
|
37 (define-key mule-keymap "f" 'set-buffer-file-coding-system)
|
|
38 (define-key mule-keymap "F" 'set-default-buffer-file-coding-system) ; XEmacs
|
|
39 (define-key mule-keymap "t" 'set-terminal-coding-system)
|
|
40 (define-key mule-keymap "k" 'set-keyboard-coding-system)
|
|
41 (define-key mule-keymap "p" 'set-current-process-coding-system)
|
|
42 (define-key mule-keymap "P" 'set-default-process-coding-system) ; XEmacs
|
197
|
43 (define-key mule-keymap "\C-\\" 'select-input-method)
|
155
|
44 (define-key mule-keymap "c" 'list-coding-system-briefly) ; XEmacs
|
|
45 (define-key mule-keymap "C" 'list-coding-system) ; XEmacs
|
|
46 (define-key mule-keymap "r" 'toggle-display-direction) ; XEmacs
|
197
|
47 (define-key mule-keymap "l" 'set-language-environment)
|
155
|
48
|
|
49 (define-key help-map "\C-L" 'describe-language-support)
|
197
|
50 (define-key help-map "L" 'describe-language-environment)
|
155
|
51 (define-key help-map "\C-\\" 'describe-input-method)
|
197
|
52 (define-key help-map "I" 'describe-input-method)
|
155
|
53 (define-key help-map "C" 'describe-current-coding-system)
|
|
54 (define-key help-map "h" 'view-hello-file)
|
|
55
|
|
56 ;; Menu for XEmacs were moved to x11/x-menubar.el.
|
|
57
|
|
58
|
|
59 ;; This should be a single character key binding because users use it
|
|
60 ;; very frequently while editing multilingual text. Now we can use
|
|
61 ;; only two such keys: "\C-\\" and "\C-^", but the latter is not
|
|
62 ;; convenient because it requires shifting on most keyboards. An
|
|
63 ;; alternative is "\C-\]" which is now bound to `abort-recursive-edit'
|
|
64 ;; but it won't be used that frequently.
|
|
65 (define-key global-map "\C-\\" 'toggle-input-method)
|
|
66
|
|
67 (defun view-hello-file ()
|
|
68 "Display the HELLO file which list up many languages and characters."
|
|
69 (interactive)
|
165
|
70 ;; We have to decode the file in any environment.
|
|
71 (let ((coding-system-for-read 'iso-2022-7))
|
|
72 (find-file-read-only (expand-file-name "HELLO" data-directory))))
|
155
|
73
|
|
74
|
|
75 ;;; Language support staffs.
|
|
76
|
|
77 (defvar primary-language "English"
|
|
78 "Name of a user's primary language.
|
|
79 Emacs provide various language supports based on this variable.")
|
|
80
|
|
81 (defvar language-info-alist nil
|
|
82 "Alist of language names vs the corresponding information of various kind.
|
|
83 Each element looks like:
|
165
|
84 (LANGUAGE-NAME . ((KEY . INFO) ...))
|
155
|
85 where LANGUAGE-NAME is a string,
|
|
86 KEY is a symbol denoting the kind of information,
|
|
87 INFO is any Lisp object which contains the actual information related
|
|
88 to KEY.")
|
|
89
|
|
90 (defun get-language-info (language-name key)
|
|
91 "Return the information for LANGUAGE-NAME of the kind KEY.
|
|
92 KEY is a symbol denoting the kind of required information."
|
197
|
93 (if (symbolp language-name)
|
|
94 (setq language-name (symbol-name language-name)))
|
|
95 (let ((lang-slot (assoc-ignore-case language-name language-info-alist)))
|
155
|
96 (if lang-slot
|
165
|
97 (cdr (assq key (cdr lang-slot))))))
|
155
|
98
|
|
99 (defun set-language-info (language-name key info)
|
|
100 "Set for LANGUAGE-NAME the information INFO under KEY.
|
|
101 KEY is a symbol denoting the kind of information.
|
|
102 INFO is any Lisp object which contains the actual information.
|
|
103
|
|
104 Currently, the following KEYs are used by Emacs:
|
197
|
105
|
155
|
106 charset: list of symbols whose values are charsets specific to the language.
|
197
|
107
|
155
|
108 coding-system: list of coding systems specific to the langauge.
|
197
|
109
|
155
|
110 tutorial: a tutorial file name written in the language.
|
197
|
111
|
155
|
112 sample-text: one line short text containing characters of the language.
|
197
|
113
|
|
114 documentation: t or a string describing how Emacs supports the language.
|
|
115 If a string is specified, it is shown before any other information
|
|
116 of the language by the command `describe-language-environment'.
|
|
117
|
165
|
118 setup-function: a function to call for setting up environment
|
197
|
119 convenient for a user of the language.
|
155
|
120
|
197
|
121 If KEY is documentation or setup-function, you can also specify
|
|
122 a cons cell as INFO, in which case, the car part should be
|
|
123 a normal value as INFO for KEY (as described above),
|
|
124 and the cdr part should be a symbol whose value is a menu keymap
|
|
125 in which an entry for the language is defined. But, only the car part
|
|
126 is actually set as the information.
|
|
127
|
|
128 We will define more KEYs in the future. To avoid conflict,
|
|
129 if you want to use your own KEY values, make them start with `user-'."
|
|
130 (if (symbolp language-name)
|
|
131 (setq language-name (symbol-name language-name)))
|
155
|
132 (let (lang-slot key-slot)
|
|
133 (setq lang-slot (assoc language-name language-info-alist))
|
165
|
134 (if (null lang-slot) ; If no slot for the language, add it.
|
|
135 (setq lang-slot (list language-name)
|
|
136 language-info-alist (cons lang-slot language-info-alist)))
|
155
|
137 (setq key-slot (assq key lang-slot))
|
165
|
138 (if (null key-slot) ; If no slot for the key, add it.
|
|
139 (progn
|
|
140 (setq key-slot (list key))
|
|
141 (setcdr lang-slot (cons key-slot (cdr lang-slot)))))
|
155
|
142 ;; Setup menu.
|
197
|
143 (cond ((eq key 'documentation)
|
165
|
144 ;; (define-key-after mule-describe-language-support-map
|
|
145 ;; (vector (intern language-name))
|
|
146 ;; (cons language-name info)
|
|
147 ;; t)
|
|
148 (eval-after-load "x-menubar"
|
|
149 `(add-menu-button '("Mule" "Describe Language Support")
|
|
150 (vector ,language-name ',info t)))
|
|
151 )
|
|
152 ((eq key 'setup-function)
|
|
153 ;; (define-key-after mule-set-language-environment-map
|
|
154 ;; (vector (intern language-name))
|
|
155 ;; (cons language-name info)
|
|
156 ;; t)
|
|
157 (eval-after-load "x-menubar"
|
|
158 `(add-menu-button '("Mule" "Set Language Environment")
|
|
159 (vector ,language-name ',info t)))
|
|
160 ))
|
155
|
161 ))
|
|
162
|
|
163 (defun set-language-info-alist (language-name alist)
|
|
164 "Set for LANGUAGE-NAME the information in ALIST.
|
|
165 ALIST is an alist of KEY and INFO. See the documentation of
|
|
166 `set-langauge-info' for the meanings of KEY and INFO."
|
197
|
167 (if (symbolp language-name)
|
|
168 (setq language-name (symbol-name language-name)))
|
155
|
169 (while alist
|
|
170 (set-language-info language-name (car (car alist)) (cdr (car alist)))
|
|
171 (setq alist (cdr alist))))
|
|
172
|
197
|
173 (defun read-language-name (key prompt &optional default)
|
|
174 "Read language name which has information for KEY, prompting with PROMPT.
|
|
175 DEFAULT is the default choice of language.
|
|
176 This returns a language name as a string."
|
155
|
177 (let* ((completion-ignore-case t)
|
165
|
178 (name (completing-read prompt
|
|
179 language-info-alist
|
|
180 (function (lambda (elm) (assq key elm)))
|
197
|
181 t nil nil default)))
|
|
182 (if (and (> (length name) 0)
|
|
183 (get-language-info name key))
|
|
184 name)))
|
155
|
185
|
|
186 ;;; Multilingual input methods.
|
|
187
|
197
|
188 (defconst leim-list-file-name "leim-list.el"
|
|
189 "Name of LEIM list file.
|
|
190 This file contains a list of libraries of Emacs input methods (LEIM)
|
|
191 in the format of Lisp expression for registering each input method.
|
|
192 Emacs loads this file at startup time.")
|
|
193
|
|
194 (defvar leim-list-header (format "\
|
|
195 ;;; %s -- list of LEIM (Library of Emacs Input Method)
|
|
196 ;;
|
|
197 ;; This file contains a list of LEIM (Library of Emacs Input Method)
|
|
198 ;; in the same directory as this file. Loading this file registeres
|
|
199 ;; the whole input methods in Emacs.
|
|
200 ;;
|
|
201 ;; Each entry has the form:
|
|
202 ;; (register-input-method
|
|
203 ;; INPUT-METHOD LANGUAGE-NAME ACTIVATE-FUNC
|
|
204 ;; TITLE DESCRIPTION
|
|
205 ;; ARG ...)
|
|
206 ;; See the function `register-input-method' for the meanings of arguments.
|
|
207 ;;
|
|
208 ;; If this directory is included in load-path, Emacs automatically
|
|
209 ;; loads this file at startup time.
|
|
210
|
|
211 "
|
|
212 leim-list-file-name)
|
|
213 "Header to be inserted in LEIM list file.")
|
|
214
|
|
215 (defvar leim-list-entry-regexp "^(register-input-method"
|
|
216 "Regexp matching head of each entry in LEIM list file.
|
|
217 See also the variable `leim-list-header'")
|
|
218
|
|
219 (defvar update-leim-list-functions
|
|
220 '(quail-update-leim-list-file)
|
|
221 "List of functions to call to update LEIM list file.
|
|
222 Each function is called with one arg, LEIM directory name.")
|
|
223
|
|
224 (defun update-leim-list-file (&rest dirs)
|
|
225 "Update LEIM list file in directories DIRS."
|
|
226 (let ((functions update-leim-list-functions))
|
|
227 (while functions
|
|
228 (apply (car functions) dirs)
|
|
229 (setq functions (cdr functions)))))
|
|
230
|
155
|
231 (defvar current-input-method nil
|
|
232 "The current input method for multilingual text.
|
197
|
233 If nil, that means no input method is activated now.")
|
155
|
234 (make-variable-buffer-local 'current-input-method)
|
|
235 (put 'current-input-method 'permanent-local t)
|
|
236
|
|
237 (defvar current-input-method-title nil
|
197
|
238 "Title string of the current input method shown in mode line.")
|
155
|
239 (make-variable-buffer-local 'current-input-method-title)
|
|
240 (put 'current-input-method-title 'permanent-local t)
|
|
241
|
197
|
242 (defcustom default-input-method nil
|
|
243 "*Default input method for multilingual text.
|
|
244 This is the input method activated automatically by the command
|
|
245 `toggle-input-method' (\\[toggle-input-method])."
|
|
246 :group 'mule)
|
155
|
247
|
197
|
248 (defvar input-method-history nil
|
|
249 "History list for some commands that read input methods.")
|
|
250 (make-variable-buffer-local 'input-method-history)
|
|
251 (put 'input-method-history 'permanent-local t)
|
155
|
252
|
|
253 (defvar inactivate-current-input-method-function nil
|
|
254 "Function to call for inactivating the current input method.
|
|
255 Every input method should set this to an appropriate value when activated.
|
197
|
256 This function is called with no argument.
|
|
257
|
|
258 This function should never change the value of `current-input-method'.
|
|
259 It is set to nil by the function `inactivate-input-method'.")
|
155
|
260 (make-variable-buffer-local 'inactivate-current-input-method-function)
|
|
261 (put 'inactivate-current-input-method-function 'permanent-local t)
|
|
262
|
|
263 (defvar describe-current-input-method-function nil
|
|
264 "Function to call for describing the current input method.
|
|
265 This function is called with no argument.")
|
|
266 (make-variable-buffer-local 'describe-current-input-method-function)
|
|
267 (put 'describe-current-input-method-function 'permanent-local t)
|
|
268
|
197
|
269 (defvar input-method-alist nil
|
|
270 "Alist of input method names vs the corresponding information to use it.
|
|
271 Each element has the form:
|
|
272 (INPUT-METHOD LANGUAGE-NAME ACTIVATE-FUNC TITLE DESCRIPTION ...)
|
|
273 See the function `register-input-method' for the meanings of each elements.")
|
|
274
|
|
275 (defun register-input-method (input-method language-name &rest args)
|
|
276 "Register INPUT-METHOD as an input method for LANGUAGE-NAME.
|
|
277 INPUT-METHOD and LANGUAGE-NAME are symbols or strings.
|
|
278 The remaining arguments are:
|
|
279 ACTIVATE-FUNC, TITLE, DESCRIPTION, and ARG ...
|
|
280 where,
|
|
281 ACTIVATE-FUNC is a function to call for activating this method.
|
|
282 TITLE is a string shown in mode-line while this method is active,
|
|
283 DESCRIPTION is a string describing about this method,
|
|
284 Arguments to ACTIVATE-FUNC are INPUT-METHOD and ARGs."
|
|
285 (if (symbolp language-name)
|
|
286 (setq language-name (symbol-name language-name)))
|
|
287 (if (symbolp input-method)
|
|
288 (setq input-method (symbol-name input-method)))
|
|
289 (let ((info (cons language-name args))
|
|
290 (slot (assoc input-method input-method-alist)))
|
|
291 (if slot
|
|
292 (setcdr slot info)
|
|
293 (setq slot (cons input-method info))
|
|
294 (setq input-method-alist (cons slot input-method-alist)))))
|
|
295
|
|
296 (defun read-input-method-name (prompt &optional default inhibit-null)
|
|
297 "Read a name of input method from a minibuffer prompting with PROMPT.
|
|
298 If DEFAULT is non-nil, use that as the default,
|
|
299 and substitute it into PROMPT at the first `%s'.
|
|
300 If INHIBIT-NULL is non-nil, null input signals an error.
|
155
|
301
|
197
|
302 The return value is a string."
|
|
303 (if default
|
|
304 (setq prompt (format prompt default)))
|
|
305 (let* ((completion-ignore-case t)
|
|
306 ;; This binding is necessary because input-method-history is
|
|
307 ;; buffer local.
|
|
308 (input-method (completing-read prompt input-method-alist
|
|
309 nil t nil 'input-method-history)
|
|
310 ;;default)
|
|
311 ))
|
|
312 (if (> (length input-method) 0)
|
|
313 input-method
|
203
|
314 ;; If we have a default, use it, otherwise check inhibit-null
|
|
315 (if default
|
|
316 default
|
|
317 (if inhibit-null
|
|
318 (error "No valid input method is specified"))))))
|
155
|
319
|
197
|
320 (defun activate-input-method (input-method)
|
|
321 "Turn INPUT-METHOD on.
|
|
322 If some input method is already on, turn it off at first."
|
|
323 (if (symbolp input-method)
|
|
324 (setq input-method (symbol-name input-method)))
|
|
325 (if (and current-input-method
|
|
326 (not (string= current-input-method input-method)))
|
|
327 (inactivate-input-method))
|
|
328 (unless current-input-method
|
|
329 (let ((slot (assoc input-method input-method-alist)))
|
|
330 (if (null slot)
|
|
331 (error "Can't activate input method `%s'" input-method))
|
|
332 (apply (nth 2 slot) input-method (nthcdr 5 slot))
|
|
333 (setq current-input-method input-method)
|
|
334 (setq current-input-method-title (nth 3 slot))
|
|
335 (run-hooks 'input-method-activate-hook))))
|
155
|
336
|
197
|
337 (defun inactivate-input-method ()
|
|
338 "Turn off the current input method."
|
|
339 (when current-input-method
|
|
340 (if input-method-history
|
|
341 (unless (string= current-input-method (car input-method-history))
|
|
342 (setq input-method-history
|
|
343 (cons current-input-method
|
|
344 (delete current-input-method input-method-history))))
|
|
345 (setq input-method-history (list current-input-method)))
|
|
346 (unwind-protect
|
|
347 (funcall inactivate-current-input-method-function)
|
|
348 (unwind-protect
|
|
349 (run-hooks 'input-method-inactivate-hook)
|
|
350 (setq current-input-method nil
|
|
351 current-input-method-title nil)))))
|
|
352
|
|
353 (defun select-input-method (input-method)
|
|
354 "Select and turn on INPUT-METHOD.
|
|
355 This sets the default input method to what you specify,
|
|
356 and turn it on for the current buffer."
|
|
357 (interactive
|
|
358 (let* ((default (or (car input-method-history) default-input-method)))
|
|
359 (list (read-input-method-name
|
|
360 (if default "Select input method (default %s): " "Select input method: ")
|
|
361 default t))))
|
|
362 (activate-input-method input-method)
|
|
363 (setq default-input-method input-method))
|
155
|
364
|
|
365 (defun toggle-input-method (&optional arg)
|
197
|
366 "Turn on or off a multilingual text input method for the current buffer.
|
|
367
|
|
368 With arg, read an input method from minibuffer and turn it on.
|
|
369
|
|
370 Without arg, if some input method is currently activated, turn it off,
|
|
371 else turn on an input method selected last time
|
|
372 or the default input method (see `default-input-method').
|
|
373
|
|
374 When there's no input method to turn on, turn on what read from minibuffer."
|
155
|
375 (interactive "P")
|
197
|
376 (if (eq arg 1)
|
|
377 (setq arg nil))
|
|
378 (let* ((default (or (car input-method-history) default-input-method)))
|
|
379 (if (and current-input-method (not arg))
|
|
380 (inactivate-input-method)
|
|
381 (activate-input-method
|
|
382 (if (or arg (not default))
|
|
383 (read-input-method-name
|
|
384 (if default "Input method (default %s): " "Input method: " )
|
|
385 default t)
|
|
386 default))
|
|
387 (or default-input-method
|
|
388 (setq default-input-method current-input-method)))))
|
155
|
389
|
197
|
390 (defun describe-input-method (input-method)
|
|
391 "Describe input method INPUT-METHOD."
|
|
392 (interactive
|
|
393 (list (read-input-method-name
|
|
394 "Describe input method (default, current choice): ")))
|
|
395 (if (and input-method (symbolp input-method))
|
|
396 (setq input-method (symbol-name input-method)))
|
|
397 (if (null input-method)
|
|
398 (describe-current-input-method)
|
|
399 (with-output-to-temp-buffer "*Help*"
|
|
400 (let ((elt (assoc input-method input-method-alist)))
|
|
401 (princ (format "Input method: %s (`%s' in mode line) for %s\n %s\n"
|
|
402 input-method (nth 3 elt) (nth 1 elt) (nth 4 elt)))))))
|
|
403
|
|
404 (defun describe-current-input-method ()
|
|
405 "Describe the input method currently in use."
|
155
|
406 (if current-input-method
|
|
407 (if (and (symbolp describe-current-input-method-function)
|
165
|
408 (fboundp describe-current-input-method-function))
|
155
|
409 (funcall describe-current-input-method-function)
|
|
410 (message "No way to describe the current input method `%s'"
|
|
411 (cdr current-input-method))
|
|
412 (ding))
|
197
|
413 (error "No input method is activated now")))
|
155
|
414
|
165
|
415 (defun read-multilingual-string (prompt &optional initial-input
|
197
|
416 input-method)
|
165
|
417 "Read a multilingual string from minibuffer, prompting with string PROMPT.
|
|
418 The input method selected last time is activated in minibuffer.
|
197
|
419 If optional second arg INITIAL-INPUT is non-nil, insert it in the minibuffer
|
|
420 initially.
|
|
421 Optional 3rd argument INPUT-METHOD specifies the input method
|
|
422 to be activated instead of the one selected last time. It is a symbol
|
|
423 or a string."
|
|
424 (setq input-method
|
|
425 (or input-method
|
|
426 default-input-method
|
|
427 (read-input-method-name "Input method: " nil t)))
|
|
428 (if (and input-method (symbolp input-method))
|
|
429 (setq input-method (symbol-name input-method)))
|
|
430 (let ((current-input-method input-method))
|
|
431 (read-string prompt initial-input nil nil t)))
|
155
|
432
|
|
433 ;; Variables to control behavior of input methods. All input methods
|
|
434 ;; should react to these variables.
|
|
435
|
197
|
436 (defcustom input-method-verbose-flag t
|
|
437 "*If this flag is non-nil, input methods give extra guidance.
|
|
438
|
|
439 The extra guidance is done by showing list of available keys in echo
|
|
440 area.
|
155
|
441
|
197
|
442 For complex input methods such as `chinese-py' and `japanese',
|
|
443 when you use the input method in the minibuffer, the guidance is
|
|
444 shown at the bottom short window (split from the existing window).
|
|
445 For simple input methods, guidance is not shown
|
|
446 when you are in the minibuffer."
|
|
447 :type 'boolean
|
|
448 :group 'mule)
|
|
449
|
|
450 (defcustom input-method-highlight-flag t
|
|
451 "*If this flag is non-nil, input methods highlight partially-entered text.
|
|
452 For instance, while you are in the middle of a Quail input method sequence,
|
|
453 the text inserted so far is temporarily underlined.
|
|
454 The underlining goes away when you finish or abort the input method sequence."
|
|
455 :type 'boolean
|
|
456 :group 'mule)
|
155
|
457
|
165
|
458 (defvar input-method-activate-hook nil
|
197
|
459 "Normal hook run just after an input method is activated.
|
|
460
|
|
461 The variable `current-input-method' keeps the input method name
|
|
462 just activated.")
|
155
|
463
|
165
|
464 (defvar input-method-inactivate-hook nil
|
197
|
465 "Normal hook run just after an input method is inactivated.
|
|
466
|
|
467 The variable `current-input-method' still keeps the input method name
|
|
468 just inacitvated.")
|
155
|
469
|
165
|
470 (defvar input-method-after-insert-chunk-hook nil
|
|
471 "Normal hook run just after an input method insert some chunk of text.")
|
155
|
472
|
197
|
473 (defvar input-method-exit-on-invalid-key nil
|
|
474 "This flag controls the behaviour of an input method on invalid key input.
|
|
475 Usually, when a user types a key which doesn't start any character
|
|
476 handled by the input method, the key is handled by turning off the
|
|
477 input method temporalily. After the key is handled, the input method is
|
|
478 back on.
|
|
479 But, if this flag is non-nil, the input method is never back on.")
|
|
480
|
155
|
481
|
|
482 ;;; Language specific setup functions.
|
|
483 ;; (defun set-language-environment (language-name)
|
|
484 ;; "Setup a user's environment for LANGUAGE-NAME.
|
|
485 ;;
|
|
486 ;; To setup, a fucntion returned by:
|
|
487 ;; (get-language-info LANGUAGE-NAME 'setup-function)
|
|
488 ;; is called."
|
|
489 ;; (interactive (list (read-language-name 'setup-function "Language: ")))
|
|
490 ;; (let (func)
|
|
491 ;; (if (or (null language-name)
|
|
492 ;; (null (setq func
|
|
493 ;; (get-language-info language-name 'setup-function))))
|
|
494 ;; (error "No way to setup environment for the specified language"))
|
|
495 ;; (funcall func)))
|
|
496
|
|
497 ;; Print all arguments with `princ', then print "\n".
|
|
498 (defsubst princ-list (&rest args)
|
|
499 (while args (princ (car args)) (setq args (cdr args)))
|
|
500 (princ "\n"))
|
|
501
|
|
502 (defun describe-language-support (language-name)
|
165
|
503 "Describe how Emacs supports LANGUAGE-NAME.
|
|
504
|
|
505 For that, a function returned by:
|
|
506 (get-language-info LANGUAGE-NAME 'describe-function)
|
|
507 is called."
|
155
|
508 (interactive (list (read-language-name 'documentation "Language: ")))
|
165
|
509 (let (func)
|
155
|
510 (if (or (null language-name)
|
165
|
511 (null (setq func
|
|
512 (get-language-info language-name 'describe-function))))
|
155
|
513 (error "No documentation for the specified language"))
|
165
|
514 (funcall func)))
|
|
515
|
|
516 ;; Print LANGUAGE-NAME specific information such as input methods,
|
|
517 ;; charsets, and coding systems. This function is intended to be
|
|
518 ;; called from various describe-LANGUAGE-support functions defined in
|
|
519 ;; lisp/language/LANGUAGE.el.
|
|
520 (defun describe-language-support-internal (language-name)
|
|
521 (with-output-to-temp-buffer "*Help*"
|
|
522 (let ((doc (get-language-info language-name 'documentation)))
|
|
523 (if (stringp doc)
|
|
524 (princ-list doc)))
|
|
525 (princ "-----------------------------------------------------------\n")
|
|
526 (princ-list "List of items specific to "
|
|
527 language-name
|
|
528 " support")
|
|
529 (princ "-----------------------------------------------------------\n")
|
|
530 (let ((str (get-language-info language-name 'sample-text)))
|
|
531 (if (stringp str)
|
|
532 (progn
|
|
533 (princ "<sample text>\n")
|
|
534 (princ-list " " str))))
|
|
535 (princ "<input methods>\n")
|
|
536 (let ((l (get-language-info language-name 'input-method)))
|
|
537 (while l
|
|
538 (princ-list " " (car (car l)))
|
|
539 (setq l (cdr l))))
|
|
540 (princ "<character sets>\n")
|
|
541 (let ((l (get-language-info language-name 'charset)))
|
|
542 (if (null l)
|
|
543 (princ-list " nothing specific to " language-name)
|
|
544 (while l
|
|
545 (princ-list " " (car l) ": "
|
|
546 (charset-description (car l)))
|
|
547 (setq l (cdr l)))))
|
|
548 (princ "<coding systems>\n")
|
|
549 (let ((l (get-language-info language-name 'coding-system)))
|
|
550 (if (null l)
|
|
551 (princ-list " nothing specific to " language-name)
|
|
552 (while l
|
|
553 (princ-list " " (car l) ":\n\t"
|
|
554 (coding-system-docstring (car l)))
|
|
555 (setq l (cdr l)))))))
|
155
|
556
|
|
557 ;;; Charset property
|
|
558
|
|
559 ;; (defsubst get-charset-property (charset propname)
|
|
560 ;; "Return the value of CHARSET's PROPNAME property.
|
|
561 ;; This is the last value stored with
|
|
562 ;; `(put-charset-property CHARSET PROPNAME VALUE)'."
|
|
563 ;; (plist-get (charset-plist charset) propname))
|
|
564
|
|
565 ;; (defsubst put-charset-property (charset propname value)
|
|
566 ;; "Store CHARSETS's PROPNAME property with value VALUE.
|
|
567 ;; It can be retrieved with `(get-charset-property CHARSET PROPNAME)'."
|
|
568 ;; (set-charset-plist charset
|
|
569 ;; (plist-put (charset-plist charset) propname value)))
|
|
570
|
|
571 ;;; Character code property
|
|
572 ;; (put 'char-code-property-table 'char-table-extra-slots 0)
|
|
573
|
|
574 ;; (defvar char-code-property-table
|
|
575 ;; (make-char-table 'char-code-property-table)
|
|
576 ;; "Char-table containing a property list of each character code.
|
|
577 ;;
|
|
578 ;; See also the documentation of `get-char-code-property' and
|
|
579 ;; `put-char-code-property'")
|
|
580
|
|
581 ;; (defun get-char-code-property (char propname)
|
|
582 ;; "Return the value of CHAR's PROPNAME property in `char-code-property-table'."
|
|
583 ;; (let ((plist (aref char-code-property-table char)))
|
|
584 ;; (if (listp plist)
|
|
585 ;; (car (cdr (memq propname plist))))))
|
|
586
|
|
587 ;; (defun put-char-code-property (char propname value)
|
|
588 ;; "Store CHAR's PROPNAME property with VALUE in `char-code-property-table'.
|
|
589 ;; It can be retrieved with `(get-char-code-property CHAR PROPNAME)'."
|
|
590 ;; (let ((plist (aref char-code-property-table char)))
|
|
591 ;; (if plist
|
|
592 ;; (let ((slot (memq propname plist)))
|
|
593 ;; (if slot
|
|
594 ;; (setcar (cdr slot) value)
|
|
595 ;; (nconc plist (list propname value))))
|
|
596 ;; (aset char-code-property-table char (list propname value)))))
|
|
597
|
|
598 ;;; mule-cmds.el ends here
|