annotate lisp/mule/mule-cmds.el @ 5050:6f2158fa75ed

Fix quick-build, use asserts() in place of ABORT() -------------------- ChangeLog entries follow: -------------------- ChangeLog addition: 2010-02-20 Ben Wing <ben@xemacs.org> * configure.ac (XE_COMPLEX_ARG): Correct doc of --quick-build: It also doesn't check for Lisp shadows. src/ChangeLog addition: 2010-02-20 Ben Wing <ben@xemacs.org> * EmacsFrame.c: * EmacsFrame.c (EmacsFrameRecomputeCellSize): * alloca.c (i00afunc): * buffer.c: * buffer.c (MARKED_SLOT): * buffer.c (complex_vars_of_buffer): * cm.c: * cm.c (cmcheckmagic): * console.c: * console.c (MARKED_SLOT): * device-x.c: * device-x.c (x_get_visual_depth): * emacs.c (sort_args): * eval.c (throw_or_bomb_out): * event-stream.c: * event-stream.c (Fadd_timeout): * event-stream.c (Fadd_async_timeout): * event-stream.c (Frecent_keys): * events.c: * events.c (Fdeallocate_event): * events.c (event_pixel_translation): * extents.c: * extents.c (process_extents_for_insertion_mapper): * fns.c (Fbase64_encode_region): * fns.c (Fbase64_encode_string): * fns.c (Fbase64_decode_region): * fns.c (Fbase64_decode_string): * font-lock.c: * font-lock.c (find_context): * frame-x.c: * frame-x.c (x_wm_mark_shell_size_user_specified): * frame-x.c (x_wm_mark_shell_position_user_specified): * frame-x.c (x_wm_set_shell_iconic_p): * frame-x.c (x_wm_set_cell_size): * frame-x.c (x_wm_set_variable_size): * frame-x.c (x_wm_store_class_hints): * frame-x.c (x_wm_maybe_store_wm_command): * frame-x.c (x_initialize_frame_size): * frame.c (delete_frame_internal): * frame.c (change_frame_size_1): * free-hook.c (check_free): * free-hook.c (note_block_input): * free-hook.c (log_gcpro): * gccache-gtk.c (gc_cache_lookup): * gccache-x.c: * gccache-x.c (gc_cache_lookup): * glyphs-gtk.c: * glyphs-gtk.c (init_image_instance_from_gdk_pixmap): * glyphs-x.c: * glyphs-x.c (extract_xpm_color_names): * insdel.c: * insdel.c (move_gap): * keymap.c: * keymap.c (keymap_lookup_directly): * keymap.c (keymap_delete_inverse_internal): * keymap.c (accessible_keymaps_mapper_1): * keymap.c (where_is_recursive_mapper): * lisp.h: * lstream.c (make_lisp_buffer_stream_1): * macros.c: * macros.c (pop_kbd_macro_event): * mc-alloc.c (remove_page_from_used_list): * menubar-x.c: * menubar-x.c (set_frame_menubar): * ralloc.c: * ralloc.c (obtain): * ralloc.c (relinquish): * ralloc.c (relocate_blocs): * ralloc.c (resize_bloc): * ralloc.c (r_alloc_free): * ralloc.c (r_re_alloc): * ralloc.c (r_alloc_thaw): * ralloc.c (init_ralloc): * ralloc.c (Free_Addr_Block): * scrollbar-x.c: * scrollbar-x.c (x_update_scrollbar_instance_status): * sunplay.c (init_device): * unexnt.c: * unexnt.c (read_in_bss): * unexnt.c (map_in_heap): * window.c: * window.c (real_window): * window.c (window_display_lines): * window.c (window_display_buffer): * window.c (set_window_display_buffer): * window.c (unshow_buffer): * window.c (Fget_lru_window): if (...) ABORT(); ---> assert(); More specifically: if (x == y) ABORT (); --> assert (x != y); if (x != y) ABORT (); --> assert (x == y); if (x > y) ABORT (); --> assert (x <= y); etc. if (!x) ABORT (); --> assert (x); if (x) ABORT (); --> assert (!x); DeMorgan's Law's applied and manually simplified: if (x && !y) ABORT (); --> assert (!x || y); if (!x || y >= z) ABORT (); --> assert (x && y < z); Checked to make sure that assert() of an expression with side effects ensures that the side effects get executed even when asserts are disabled, and add a comment about this being a requirement of any "disabled assert" expression. * depend: * make-src-depend: * make-src-depend (PrintDeps): Fix broken code in make-src-depend so it does what it was always supposed to do, which was separate out config.h and lisp.h and all the files they include into separate variables in the depend part of Makefile so that quick-build can turn off the lisp.h/config.h/text.h/etc. dependencies of the source files, to speed up recompilation.
author Ben Wing <ben@xemacs.org>
date Sat, 20 Feb 2010 05:05:54 -0600
parents b3ea9c582280
children 0b0241ae382f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 448
diff changeset
1 ;;; mule-cmds.el --- Commands for multilingual environment -*- coding: iso-2022-7bit; -*-
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 ;; Copyright (C) 1995,1999 Electrotechnical Laboratory, JAPAN.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4 ;; Licensed to the Free Software Foundation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 ;; Copyright (C) 1997 MORIOKA Tomohiko
1318
b531bf8658e9 [xemacs-hg @ 2003-02-21 06:56:46 by ben]
ben
parents: 1285
diff changeset
6 ;; Copyright (C) 2000, 2001, 2002, 2003 Ben Wing.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 ;; Keywords: mule, multilingual
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 ;; This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 ;; XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 ;; under the terms of the GNU General Public License as published by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 ;; any later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 ;; XEmacs is distributed in the hope that it will be useful, but
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 ;; General Public License for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 ;; along with XEmacs; see the file COPYING. If not, write to the Free
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 ;; 02111-1307, USA.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
27 ;; Note: Some of the code here is now in code-cmds.el
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
28
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 ;;; Code:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 ;;; MULE related key bindings and menus.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
33 ;; Preserve the old name
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
34 (defvaralias 'mule-keymap 'coding-keymap)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
35
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 (define-key mule-keymap "x" 'set-selection-coding-system)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 (define-key mule-keymap "X" 'set-next-selection-coding-system)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 (define-key mule-keymap "\C-\\" 'set-input-method)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 ;;(define-key mule-keymap "c" 'list-coding-system-briefly) ; XEmacs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 (define-key mule-keymap "C" 'describe-coding-system) ; XEmacs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 (define-key mule-keymap "r" 'toggle-display-direction) ; XEmacs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 (define-key mule-keymap "l" 'set-language-environment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 (define-key help-map "L" 'describe-language-environment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 (define-key help-map "\C-\\" 'describe-input-method)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 (define-key help-map "I" 'describe-input-method)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 (define-key help-map "h" 'view-hello-file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 ;; Menu for XEmacs were moved to menubar-items.el.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 ;; This should be a single character key binding because users use it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 ;; very frequently while editing multilingual text. Now we can use
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 ;; only two such keys: "\C-\\" and "\C-^", but the latter is not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 ;; convenient because it requires shifting on most keyboards. An
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 ;; alternative is "\C-\]" which is now bound to `abort-recursive-edit'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 ;; but it won't be used that frequently.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 (define-key global-map "\C-\\" 'toggle-input-method)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
60 ;; Original mapping will be altered by set-keyboard-coding-system.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
61 (define-key global-map [(meta \#)] 'ispell-word) ;originally "$"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
62 ;; (define-key global-map [(meta {)] 'insert-parentheses) ;originally "("
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
63
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 ;;; This is no good because people often type Shift-SPC
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 ;;; meaning to type SPC. -- rms.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 ;;; ;; Here's an alternative key binding for X users (Shift-SPACE).
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
67 ;;; (define-key global-map '(shift space) 'toggle-input-method)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 (defun view-hello-file ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 "Display the HELLO file which list up many languages and characters."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 ;; We have to decode the file in any environment.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 (let ((coding-system-for-read 'iso-2022-7bit))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 (find-file-read-only (expand-file-name "HELLO" data-directory))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75
3999
a0ef33811aa3 [xemacs-hg @ 2007-06-03 17:32:28 by aidan]
aidan
parents: 3769
diff changeset
76 (defvar system-type-file-name-coding
a0ef33811aa3 [xemacs-hg @ 2007-06-03 17:32:28 by aidan]
aidan
parents: 3769
diff changeset
77 '((darwin . utf-8))
a0ef33811aa3 [xemacs-hg @ 2007-06-03 17:32:28 by aidan]
aidan
parents: 3769
diff changeset
78 "A map from values of `system-type' to invariant file name coding systems.
a0ef33811aa3 [xemacs-hg @ 2007-06-03 17:32:28 by aidan]
aidan
parents: 3769
diff changeset
79 Used if a give system type does not vary in the coding system it uses for
a0ef33811aa3 [xemacs-hg @ 2007-06-03 17:32:28 by aidan]
aidan
parents: 3769
diff changeset
80 file names; otherwise, `language-info-alist' is consulted for this
a0ef33811aa3 [xemacs-hg @ 2007-06-03 17:32:28 by aidan]
aidan
parents: 3769
diff changeset
81 information. This affects the `file-name' coding system alias, but not the
a0ef33811aa3 [xemacs-hg @ 2007-06-03 17:32:28 by aidan]
aidan
parents: 3769
diff changeset
82 `file-name-coding-system' variable, which in practice is mostly ignored. ")
a0ef33811aa3 [xemacs-hg @ 2007-06-03 17:32:28 by aidan]
aidan
parents: 3769
diff changeset
83
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
85 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
86 ;;; Language Support Functions ;;;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
87 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 (defvar language-info-alist nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 "Alist of language environment definitions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 Each element looks like:
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
91 (LANGUAGE-NAME . ((PROP . VALUE) ...))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 where LANGUAGE-NAME is a string, the name of the language environment,
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
93 PROP is a symbol denoting a property, and VALUE is the data associated
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
94 with PROP.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
95 See `set-language-info' for documentation on PROP and VALUE.")
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
97 (defun get-language-info (lang-env prop)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
98 "Return information listed under PROP for language environment LANG-ENV.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
99 PROP is a symbol denoting a property.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
100 For a list of useful values for PROP and their meanings,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
101 see `set-language-info'."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 (if (symbolp lang-env)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 (setq lang-env (symbol-name lang-env)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 (let ((lang-slot (assoc-ignore-case lang-env language-info-alist)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 (if lang-slot
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
106 (cdr (assq prop (cdr lang-slot))))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
108 (defun set-language-info (lang-env prop value)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 "Modify part of the definition of language environment LANG-ENV.
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
110 Specifically, this stores the information VALUE under PROP
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 in the definition of this language environment.
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
112 PROP is a symbol denoting a property, and VALUE is the value of that property.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
113
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
114 Meaningful values for PROP include
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
115
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
116 documentation VALUE is documentation of what this language environment
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
117 is meant for, and how to use it.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
118
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
119 charset VALUE is a list of the character sets used by this
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
120 language environment.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
121
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
122 sample-text VALUE is one line of text,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
123 written using those character sets,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
124 appropriate for this language environment.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
125
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
126 setup-function VALUE is a function to call to switch to this
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
127 language environment.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
128
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
129 exit-function VALUE is a function to call to leave this
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
130 language environment.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
131
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
132 coding-system VALUE is a list of coding systems that are good
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
133 for saving text written in this language environment.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
134 This list serves as suggestions to the user;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
135 in effect, as a kind of documentation.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
136
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
137 coding-priority VALUE is a list of coding systems for this language
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
138 environment, in order of decreasing priority.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
139 This is used to set up the coding system priority
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
140 list when you switch to this language environment.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
141
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
142 input-method VALUE is a default input method for this language
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
143 environment.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
144
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
145 features VALUE is a list of features requested in this
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
146 language environment.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
147
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
148 tutorial VALUE is a tutorial file name written in the language.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
149
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
150 locale VALUE is a list of locale expressions, which serve
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
151 two purposes: (1) Determining the language
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
152 environment from the current system locale at
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
153 startup, and (2) determining how to set the system
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
154 locale when the language environment is changed.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
155 Each expression will be tried in turn, and should
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
156 be a string (for case (1), the string is matched
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
157 against the current locale using the regular
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
158 expression \"^STRING[^A-Za-z0-9]\"; for case (2),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
159 the string is passed directly to
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
160 `set-current-locale' until a non-nil result is
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
161 returned), or a function of one argument. For
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
162 case (1), this argument will be a locale, and the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
163 function should return t or nil to indicate
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
164 whether this locale matches the language
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
165 environment; for case (2), the argument will be
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
166 nil, and the function should call
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
167 `set-current-locale' itself and return the set
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
168 locale string if the locale was successfully set,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
169 and nil otherwise.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
171 NOTE: This property is *NOT* used under MS Windows;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
172 instead, the `mswindows-locale' property is used.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
173
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
174 cygwin-locale VALUE specifies a general Unix-style C library
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
175 locale that will be used to initialize the LANG
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
176 environment variable under MS Windows native, when the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
177 system cannot test out the locales specified in the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
178 `locale' property. This is so that Cygwin programs
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
179 can be run from an MS Windows native XEmacs. If not
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
180 specified, the last entry in `locale' will be used.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
181
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
182 native-coding-system VALUE is a single coding-system expression, or a
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
183 list of such expressions. These expressions are
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
184 used to compute the operating system's native
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
185 coding system, i.e. the coding system to be used
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
186 as the alias for `native' and `file-name'. This
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
187 specifies the coding system used for text
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
188 exchanged with the operating system, such as file
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
189 names, environment variables, subprocess
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
190 arguments, etc. Each expression should be either
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
191 a symbol naming a coding system or a function
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
192 (anything that is `functionp') of one argument,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
193 which is passed the current locale corresponding
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
194 to this language environment and should return a
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
195 coding system or nil. Each expression is tried in
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
196 turn until a coding system is obtained. If there
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
197 is no non-nil result, or no value is specified for
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
198 this property, the first coding system listed
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
199 under the `coding-system' property is used.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
200
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
201 NOTE: This is *NOT* used under MS Windows.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
202 Instead, `mswindows-multibyte-system-default'
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
203 is always used, since the system default code
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
204 page is what the Win32 API routines make use
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
205 of, and this cannot be changed. (We get around
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
206 this by using the Unicode versions whenever
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
207 possible -- i.e. on Windows NT/2000, and on
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
208 Windows 9x with the few API's that support
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
209 Unicode.)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
210
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
211 mswindows-locale VALUE is an element of the form MSWINDOWS-LOCALE, or
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
212 a list of such elements. Each element is an MS
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
213 Windows locale, of the form that can be passed to
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
214 `mswindows-set-current-locale'. This property is used
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
215 both to determine the current language environment at
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
216 startup (by matching MSWINDOWS-LOCALE against the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
217 value returned by `mswindows-user-default-locale') and
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
218 to set the values of `set-current-locale' and
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
219 `mswindows-set-current-locale' when the current
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
220 language environment is changed. (The correct CLIB
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
221 locale can always be generated by passing in the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
222 SUBLANG, with dashes in place of underscores, or the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
223 LANG if there's no SUBLANG. The return value will be
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
224 the canonicalized locale, in proper CLIB form.)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
225
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
226 If there is no value for this property, the MS Windows
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
227 locale is assumed to have the same name as the
4489
b75b075a9041 Support displaying invalid UTF-8 in language-environment-specific ways.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4468
diff changeset
228 language environment.
b75b075a9041 Support displaying invalid UTF-8 in language-environment-specific ways.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4468
diff changeset
229
4490
67fbcaf3dbdc error-sequence -> invalid-sequence
Aidan Kehoe <kehoea@parhasard.net>
parents: 4489
diff changeset
230 invalid-sequence-coding-system
4489
b75b075a9041 Support displaying invalid UTF-8 in language-environment-specific ways.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4468
diff changeset
231 VALUE is a fixed-width 8-bit coding system used to
b75b075a9041 Support displaying invalid UTF-8 in language-environment-specific ways.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4468
diff changeset
232 display Unicode error sequences (using a face to make
b75b075a9041 Support displaying invalid UTF-8 in language-environment-specific ways.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4468
diff changeset
233 it clear that the data is invalid). In Western Europe
4604
e0a8715fdb1f Support new IGNORE-INVALID-SEQUENCESP argument, #'query-coding-region.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4590
diff changeset
234 and the Americas this is normally windows-1252; in
e0a8715fdb1f Support new IGNORE-INVALID-SEQUENCESP argument, #'query-coding-region.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4590
diff changeset
235 Russia and the former Soviet Union koi8-ru or
e0a8715fdb1f Support new IGNORE-INVALID-SEQUENCESP argument, #'query-coding-region.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4590
diff changeset
236 windows-1251 makes more sense."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 (if (symbolp lang-env)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 (setq lang-env (symbol-name lang-env)))
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
239 (let (lang-slot prop-slot)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 (setq lang-slot (assoc lang-env language-info-alist))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 (if (null lang-slot) ; If no slot for the language, add it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 (setq lang-slot (list lang-env)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 language-info-alist (cons lang-slot language-info-alist)))
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
244 (setq prop-slot (assq prop lang-slot))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
245 (if (null prop-slot) ; If no slot for the prop, add it.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 (progn
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
247 (setq prop-slot (list prop))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
248 (setcdr lang-slot (cons prop-slot (cdr lang-slot)))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
249 (setcdr prop-slot value)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 (defun set-language-info-alist (lang-env alist &optional parents)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 "Store ALIST as the definition of language environment LANG-ENV.
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
253 ALIST is an alist of properties and values. See the documentation of
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
254 `set-language-info' for the allowed properties."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 (if (symbolp lang-env)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 (setq lang-env (symbol-name lang-env)))
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
257 ;; FSF has 30 lines of unbelievably ugly code to set up the menus
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
258 ;; appropriately. We just use a filter.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
259 (while alist
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
260 (set-language-info lang-env (car (car alist)) (cdr (car alist)))
3707
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
261 (setq alist (cdr alist)))
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
262 lang-env)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 (defun read-language-name (key prompt &optional default)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 "Read a language environment name which has information for KEY.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 If KEY is nil, read any language environment.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 Prompt with PROMPT. DEFAULT is the default choice of language environment.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 This returns a language environment name as a string."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 (let* ((completion-ignore-case t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 (name (completing-read prompt
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 language-info-alist
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 (and key
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 (function (lambda (elm) (assq key elm))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 t nil nil default)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 (if (and (> (length name) 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 (or (not key)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 (get-language-info name key)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 name)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 ;;; Multilingual input methods.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 (defconst leim-list-file-name "leim-list.el"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 "Name of LEIM list file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 This file contains a list of libraries of Emacs input methods (LEIM)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 in the format of Lisp expression for registering each input method.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 Emacs loads this file at startup time.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 (defvar leim-list-header (format
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 ";;; %s -- list of LEIM (Library of Emacs Input Method)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 ;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 ;; This file contains a list of LEIM (Library of Emacs Input Method)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 ;; in the same directory as this file. Loading this file registers
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 ;; the whole input methods in Emacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 ;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 ;; Each entry has the form:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 ;; (register-input-method
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 ;; INPUT-METHOD LANGUAGE-NAME ACTIVATE-FUNC
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 ;; TITLE DESCRIPTION
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 ;; ARG ...)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 ;; See the function `register-input-method' for the meanings of arguments.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 ;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 ;; If this directory is included in load-path, Emacs automatically
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 ;; loads this file at startup time.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 "
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 leim-list-file-name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 "Header to be inserted in LEIM list file.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 (defvar leim-list-entry-regexp "^(register-input-method"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 "Regexp matching head of each entry in LEIM list file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 See also the variable `leim-list-header'")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 (defvar update-leim-list-functions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 '(quail-update-leim-list-file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 "List of functions to call to update LEIM list file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 Each function is called with one arg, LEIM directory name.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 (defun update-leim-list-file (&rest dirs)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 "Update LEIM list file in directories DIRS."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 (let ((functions update-leim-list-functions))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 (while functions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 (apply (car functions) dirs)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 (setq functions (cdr functions)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 (defvar current-input-method nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 "The current input method for multilingual text.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 If nil, that means no input method is activated now.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 (make-variable-buffer-local 'current-input-method)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 (put 'current-input-method 'permanent-local t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 (defvar current-input-method-title nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 "Title string of the current input method shown in mode line.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 (make-variable-buffer-local 'current-input-method-title)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 (put 'current-input-method-title 'permanent-local t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 (defcustom default-input-method nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 "*Default input method for multilingual text (a string).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 This is the input method activated automatically by the command
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 `toggle-input-method' (\\[toggle-input-method])."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 :group 'mule
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 :type '(choice (const nil) string))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 (put 'input-method-function 'permanent-local t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 (defvar input-method-history nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 "History list for some commands that read input methods.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 (make-variable-buffer-local 'input-method-history)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 (put 'input-method-history 'permanent-local t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 (defvar inactivate-current-input-method-function nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 "Function to call for inactivating the current input method.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 Every input method should set this to an appropriate value when activated.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 This function is called with no argument.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 This function should never change the value of `current-input-method'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 It is set to nil by the function `inactivate-input-method'.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 (make-variable-buffer-local 'inactivate-current-input-method-function)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 (put 'inactivate-current-input-method-function 'permanent-local t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 (defvar describe-current-input-method-function nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 "Function to call for describing the current input method.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 This function is called with no argument.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 (make-variable-buffer-local 'describe-current-input-method-function)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 (put 'describe-current-input-method-function 'permanent-local t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 (defvar input-method-alist nil
2970
adda8fccb13d [xemacs-hg @ 2005-10-04 16:43:29 by stephent]
stephent
parents: 2367
diff changeset
367 "Alist mapping input method names to information used by the LEIM API.
adda8fccb13d [xemacs-hg @ 2005-10-04 16:43:29 by stephent]
stephent
parents: 2367
diff changeset
368 Elements have the form (METHOD LANGUAGE ACTIVATOR TITLE DESCRIPTION ARGS...).
adda8fccb13d [xemacs-hg @ 2005-10-04 16:43:29 by stephent]
stephent
parents: 2367
diff changeset
369 Use `register-input-method' to add input methods to the database. See its
adda8fccb13d [xemacs-hg @ 2005-10-04 16:43:29 by stephent]
stephent
parents: 2367
diff changeset
370 documentation for the meanings of the elements.")
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371
2970
adda8fccb13d [xemacs-hg @ 2005-10-04 16:43:29 by stephent]
stephent
parents: 2367
diff changeset
372 (defun register-input-method (method language
adda8fccb13d [xemacs-hg @ 2005-10-04 16:43:29 by stephent]
stephent
parents: 2367
diff changeset
373 ;; #### shouldn't be optional, but need to
adda8fccb13d [xemacs-hg @ 2005-10-04 16:43:29 by stephent]
stephent
parents: 2367
diff changeset
374 ;; audit callers
adda8fccb13d [xemacs-hg @ 2005-10-04 16:43:29 by stephent]
stephent
parents: 2367
diff changeset
375 &optional activator title description
adda8fccb13d [xemacs-hg @ 2005-10-04 16:43:29 by stephent]
stephent
parents: 2367
diff changeset
376 &rest args)
adda8fccb13d [xemacs-hg @ 2005-10-04 16:43:29 by stephent]
stephent
parents: 2367
diff changeset
377 "Register METHOD as an input method for language environment LANGUAGE.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378
2970
adda8fccb13d [xemacs-hg @ 2005-10-04 16:43:29 by stephent]
stephent
parents: 2367
diff changeset
379 METHOD and LANGUAGE may be symbols or strings.
adda8fccb13d [xemacs-hg @ 2005-10-04 16:43:29 by stephent]
stephent
parents: 2367
diff changeset
380 ACTIVATOR is the function called to activate this method. METHOD (the
adda8fccb13d [xemacs-hg @ 2005-10-04 16:43:29 by stephent]
stephent
parents: 2367
diff changeset
381 invocation name) and ARGS are passed to the function on activation.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 TITLE is a string to show in the mode line when this method is active.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 DESCRIPTION is a string describing this method and what it is good for.
2970
adda8fccb13d [xemacs-hg @ 2005-10-04 16:43:29 by stephent]
stephent
parents: 2367
diff changeset
384 Optional ARGS, if any, are stored and passed as arguments to ACTIVATOR.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385
2970
adda8fccb13d [xemacs-hg @ 2005-10-04 16:43:29 by stephent]
stephent
parents: 2367
diff changeset
386 When registering a new Quail input method, the input method title should be
adda8fccb13d [xemacs-hg @ 2005-10-04 16:43:29 by stephent]
stephent
parents: 2367
diff changeset
387 the one given in the third parameter of `quail-define-package' (if the values
adda8fccb13d [xemacs-hg @ 2005-10-04 16:43:29 by stephent]
stephent
parents: 2367
diff changeset
388 are different, the string specified in this function takes precedence).
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389
2970
adda8fccb13d [xemacs-hg @ 2005-10-04 16:43:29 by stephent]
stephent
parents: 2367
diff changeset
390 The information provided is registered in `input-method-alist'. The commands
adda8fccb13d [xemacs-hg @ 2005-10-04 16:43:29 by stephent]
stephent
parents: 2367
diff changeset
391 `describe-input-method' and `list-input-methods' use this database to show
adda8fccb13d [xemacs-hg @ 2005-10-04 16:43:29 by stephent]
stephent
parents: 2367
diff changeset
392 information about input methods without loading them."
adda8fccb13d [xemacs-hg @ 2005-10-04 16:43:29 by stephent]
stephent
parents: 2367
diff changeset
393 (if (symbolp language)
adda8fccb13d [xemacs-hg @ 2005-10-04 16:43:29 by stephent]
stephent
parents: 2367
diff changeset
394 (setq language (symbol-name language)))
adda8fccb13d [xemacs-hg @ 2005-10-04 16:43:29 by stephent]
stephent
parents: 2367
diff changeset
395 (if (symbolp method)
adda8fccb13d [xemacs-hg @ 2005-10-04 16:43:29 by stephent]
stephent
parents: 2367
diff changeset
396 (setq method (symbol-name method)))
adda8fccb13d [xemacs-hg @ 2005-10-04 16:43:29 by stephent]
stephent
parents: 2367
diff changeset
397 (let ((info (append (list language activator title description) args))
adda8fccb13d [xemacs-hg @ 2005-10-04 16:43:29 by stephent]
stephent
parents: 2367
diff changeset
398 (slot (assoc method input-method-alist)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 (if slot
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 (setcdr slot info)
2970
adda8fccb13d [xemacs-hg @ 2005-10-04 16:43:29 by stephent]
stephent
parents: 2367
diff changeset
401 (setq slot (cons method info))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 (setq input-method-alist (cons slot input-method-alist)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 (defun read-input-method-name (prompt &optional default inhibit-null)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 "Read a name of input method from a minibuffer prompting with PROMPT.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 If DEFAULT is non-nil, use that as the default,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 and substitute it into PROMPT at the first `%s'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 If INHIBIT-NULL is non-nil, null input signals an error.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 The return value is a string."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 (if default
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 (setq prompt (format prompt default)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 (let* ((completion-ignore-case t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 ;; This binding is necessary because input-method-history is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 ;; buffer local.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 (input-method (completing-read prompt input-method-alist
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 nil t nil 'input-method-history
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 default)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 (if (and input-method (symbolp input-method))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 (setq input-method (symbol-name input-method)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 (if (> (length input-method) 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 input-method
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 (if inhibit-null
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 (error "No valid input method is specified")))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 (defun activate-input-method (input-method)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 "Switch to input method INPUT-METHOD for the current buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 If some other input method is already active, turn it off first.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 If INPUT-METHOD is nil, deactivate any current input method."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 (if (and input-method (symbolp input-method))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 (setq input-method (symbol-name input-method)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 (if (and current-input-method
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 (not (string= current-input-method input-method)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 (inactivate-input-method))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 (unless (or current-input-method (null input-method))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 (let ((slot (assoc input-method input-method-alist)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 (if (null slot)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 (error "Can't activate input method `%s'" input-method))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 (let ((func (nth 2 slot)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 (if (functionp func)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 (apply (nth 2 slot) input-method (nthcdr 5 slot))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 (if (and (consp func) (symbolp (car func)) (symbolp (cdr func)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 (require (cdr func))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 (apply (car func) input-method (nthcdr 5 slot)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 (error "Can't activate input method `%s'" input-method))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 (setq current-input-method input-method)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 (setq current-input-method-title (nth 3 slot))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 (unwind-protect
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 (run-hooks 'input-method-activate-hook)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 (force-mode-line-update)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 (defun inactivate-input-method ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 "Turn off the current input method."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 (when current-input-method
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 (if input-method-history
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 (unless (string= current-input-method (car input-method-history))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 (setq input-method-history
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 (cons current-input-method
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 (delete current-input-method input-method-history))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 (setq input-method-history (list current-input-method)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 (unwind-protect
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 (funcall inactivate-current-input-method-function)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 (unwind-protect
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 (run-hooks 'input-method-inactivate-hook)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 (setq current-input-method nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 current-input-method-title nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 (force-mode-line-update)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 (defun set-input-method (input-method)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 "Select and activate input method INPUT-METHOD for the current buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 This also sets the default input method to the one you specify."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 (interactive
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 (let* ((default (or (car input-method-history) default-input-method)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 (list (read-input-method-name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 (if default "Select input method (default %s): " "Select input method: ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 default t))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 (activate-input-method input-method)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 (setq default-input-method input-method))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 (defun toggle-input-method (&optional arg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 "Turn on or off a multilingual text input method for the current buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 With no prefix argument, if an input method is currently activated,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 turn it off. Otherwise, activate an input method -- the one most
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 recently used, or the one specified in `default-input-method', or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 the one read from the minibuffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 With a prefix argument, read an input method from the minibuffer and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 turn it on.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 The default is to use the most recent input method specified
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 \(not including the currently active input method, if any)."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 (interactive "P")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 (if (and current-input-method (not arg))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 (inactivate-input-method)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 (let ((default (or (car input-method-history) default-input-method)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 (if (and arg default (equal current-input-method default)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 (> (length input-method-history) 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 (setq default (nth 1 input-method-history)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 (activate-input-method
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 (if (or arg (not default))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 (read-input-method-name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 (if default "Input method (default %s): " "Input method: " )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 default t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 default))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 (or default-input-method
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 (setq default-input-method current-input-method)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 (defun describe-input-method (input-method)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 "Describe input method INPUT-METHOD."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513 (interactive
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 (list (read-input-method-name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 "Describe input method (default, current choice): ")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 (if (and input-method (symbolp input-method))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 (setq input-method (symbol-name input-method)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 (if (null input-method)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 (describe-current-input-method)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 (with-output-to-temp-buffer "*Help*"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 (let ((elt (assoc input-method input-method-alist)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 (princ (format "Input method: %s (`%s' in mode line) for %s\n %s\n"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 input-method (nth 3 elt) (nth 1 elt) (nth 4 elt)))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525 (defun describe-current-input-method ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 "Describe the input method currently in use."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 (if current-input-method
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 (if (and (symbolp describe-current-input-method-function)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 (fboundp describe-current-input-method-function))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 (funcall describe-current-input-method-function)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 (message "No way to describe the current input method `%s'"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 current-input-method)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 (ding))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 (error "No input method is activated now")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 (defun read-multilingual-string (prompt &optional initial-input input-method)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 "Read a multilingual string from minibuffer, prompting with string PROMPT.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 The input method selected last time is activated in minibuffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 If optional second arg INITIAL-INPUT is non-nil, insert it in the minibuffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 initially.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 Optional 3rd argument INPUT-METHOD specifies the input method
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 to be activated instead of the one selected last time. It is a symbol
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 or a string."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544 (setq input-method
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 (or input-method
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 current-input-method
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 default-input-method
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 (read-input-method-name "Input method: " nil t)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 (if (and input-method (symbolp input-method))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 (setq input-method (symbol-name input-method)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 (let ((prev-input-method current-input-method))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 (unwind-protect
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 (activate-input-method input-method)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 ;; FSF Emacs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 ;; (read-string prompt initial-input nil nil t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 (read-string prompt initial-input nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 (activate-input-method prev-input-method))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 ;; Variables to control behavior of input methods. All input methods
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 ;; should react to these variables.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 (defcustom input-method-verbose-flag 'default
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 "*A flag to control extra guidance given by input methods.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 The value should be nil, t, `complex-only', or `default'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 The extra guidance is done by showing list of available keys in echo
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 area. When you use the input method in the minibuffer, the guidance
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 is shown at the bottom short window (split from the existing window).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 If the value is t, extra guidance is always given, if the value is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572 nil, extra guidance is always suppressed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
573
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 If the value is `complex-only', only complex input methods such as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575 `chinese-py' and `japanese' give extra guidance.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 If the value is `default', complex input methods always give extra
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578 guidance, but simple input methods give it only when you are not in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 the minibuffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 See also the variable `input-method-highlight-flag'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582 :type '(choice (const t) (const nil) (const complex-only) (const default))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 :group 'mule)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 (defcustom input-method-highlight-flag t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 "*If this flag is non-nil, input methods highlight partially-entered text.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 For instance, while you are in the middle of a Quail input method sequence,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 the text inserted so far is temporarily underlined.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 The underlining goes away when you finish or abort the input method sequence.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 See also the variable `input-method-verbose-flag'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 :type 'boolean
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 :group 'mule)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 (defvar input-method-activate-hook nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 "Normal hook run just after an input method is activated.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 The variable `current-input-method' keeps the input method name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 just activated.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 (defvar input-method-inactivate-hook nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 "Normal hook run just after an input method is inactivated.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 The variable `current-input-method' still keeps the input method name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 just inactivated.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606 (defvar input-method-after-insert-chunk-hook nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 "Normal hook run just after an input method insert some chunk of text.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 (defvar input-method-exit-on-first-char nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 "This flag controls a timing when an input method returns.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 Usually, the input method does not return while there's a possibility
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 that it may find a different translation if a user types another key.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613 But, it this flag is non-nil, the input method returns as soon as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 the current key sequence gets long enough to have some valid translation.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616 (defvar input-method-use-echo-area nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617 "This flag controls how an input method shows an intermediate key sequence.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618 Usually, the input method inserts the intermediate key sequence,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619 or candidate translations corresponding to the sequence,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 at point in the current buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621 But, if this flag is non-nil, it displays them in echo area instead.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623 (defvar input-method-exit-on-invalid-key nil
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
624 "This flag controls the behavior of an input method on invalid key input.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625 Usually, when a user types a key which doesn't start any character
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 handled by the input method, the key is handled by turning off the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627 input method temporarily. After that key, the input method is re-enabled.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
628 But, if this flag is non-nil, the input method is never back on.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
629
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
630
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
631 (defvar set-language-environment-hook nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632 "Normal hook run after some language environment is set.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634 When you set some hook function here, that effect usually should not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635 be inherited to another language environment. So, you had better set
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 another function in `exit-language-environment-hook' (which see) to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637 cancel the effect.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639 (defvar exit-language-environment-hook nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640 "Normal hook run after exiting from some language environment.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 When this hook is run, the variable `current-language-environment'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 is still bound to the language environment being exited.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 This hook is mainly used for canceling the effect of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 `set-language-environment-hook' (which-see).")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
647 ;; bogus FSF function setup-specified-language-support.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 (defcustom current-language-environment "English"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650 "The last language environment specified with `set-language-environment'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 This variable should be set only with \\[customize], which is equivalent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652 to using the function `set-language-environment'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653 :link '(custom-manual "(emacs)Language Environments")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 :set (lambda (symbol value) (set-language-environment value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655 :get (lambda (x)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 (or (car-safe (assoc-ignore-case
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 (if (symbolp current-language-environment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 (symbol-name current-language-environment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 current-language-environment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660 language-info-alist))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661 "English"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 :type (cons 'choice (mapcar (lambda (lang)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 (list 'const (car lang)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664 language-info-alist))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665 :initialize 'custom-initialize-default
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666 :group 'mule
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667 :type 'string)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
669 (defun set-language-environment (language-name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
670 "Set up multi-lingual environment for using LANGUAGE-NAME.
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
671 This sets the coding system autodetection priority, the default buffer
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
672 coding system, the default input method, the system locale, and other
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
673 relevant language properties. LANGUAGE-NAME should be a string, the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
674 name of a language environment. For example, \"Latin-1\" specifies
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
675 the language environment for the major languages of Western Europe."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676 (interactive (list (read-language-name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677 nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678 "Set language environment (default, English): ")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679 (if language-name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680 (if (symbolp language-name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681 (setq language-name (symbol-name language-name)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 (setq language-name "English"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
683 (or (assoc-ignore-case language-name language-info-alist)
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
684 (error 'invalid-argument "Language environment not defined"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
685 language-name))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
686 (if current-language-environment
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687 (let ((func (get-language-info current-language-environment
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688 'exit-function)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
689 (run-hooks 'exit-language-environment-hook)
4145
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4103
diff changeset
690 (if (functionp func) (funcall func))))
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
691 (setq current-language-environment language-name)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692 (let ((default-eol-type (coding-system-eol-type
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693 default-buffer-file-coding-system)))
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
694 (reset-coding-categories-to-default)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
695 (set-locale-for-language-environment language-name)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
696 (set-language-environment-coding-systems language-name default-eol-type))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
697
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
698 (finish-set-language-environment language-name))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
699
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
700 (defun finish-set-language-environment (language-name)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
701 ;; Internal function. Only what's here is called at startup, once the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
702 ;; first language environment is determined. The above stuff was already
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
703 ;; taken care of very early in the startup sequence, in a special
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
704 ;; fashion.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
705 (let ((input-method (get-language-info language-name 'input-method)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
706 (when input-method
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707 (setq default-input-method input-method)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708 (if input-method-history
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
709 (setq input-method-history
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
710 (cons input-method
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711 (delete input-method input-method-history))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712 ;; (let ((nonascii (get-language-info language-name 'nonascii-translation))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713 ;; (dos-table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
714 ;; (if (eq window-system 'pc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715 ;; (intern
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716 ;; (concat "cp" dos-codepage "-nonascii-translation-table")))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717 ;; (cond
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718 ;; ((char-table-p nonascii)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
719 ;; (setq nonascii-translation-table nonascii))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
720 ;; ((and (eq window-system 'pc) (boundp dos-table))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721 ;; ;; DOS terminals' default is to use a special non-ASCII translation
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722 ;; ;; table as appropriate for the installed codepage.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723 ;; (setq nonascii-translation-table (symbol-value dos-table)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724 ;; ((charsetp nonascii)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725 ;; (setq nonascii-insert-offset (- (make-char nonascii) 128)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727 ;; (setq charset-origin-alist
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
728 ;; (get-language-info language-name 'charset-origin-alist))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730 ;; Unibyte setups if necessary.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731 ;; (unless default-enable-multibyte-characters
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
732 ;; ;; Syntax and case table.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733 ;; (let ((syntax (get-language-info language-name 'unibyte-syntax)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734 ;; (if syntax
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735 ;; (let ((set-case-syntax-set-multibyte nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
736 ;; (load syntax nil t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737 ;; ;; No information for syntax and case. Reset to the defaults.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738 ;; (let ((syntax-table (standard-syntax-table))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739 ;; (case-table (standard-case-table))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
740 ;; (ch (if (eq window-system 'pc) 128 160)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
741 ;; (while (< ch 256)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
742 ;; (modify-syntax-entry ch " " syntax-table)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743 ;; (aset case-table ch ch)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
744 ;; (setq ch (1+ ch)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
745 ;; (set-char-table-extra-slot case-table 0 nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746 ;; (set-char-table-extra-slot case-table 1 nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
747 ;; (set-char-table-extra-slot case-table 2 nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
748 ;; (set-standard-case-table (standard-case-table))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
749 ;; (let ((list (buffer-list)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
750 ;; (while list
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
751 ;; (with-current-buffer (car list)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752 ;; (set-case-table (standard-case-table)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
753 ;; (setq list (cdr list))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
754 ;; ;; Display table and coding system for terminal.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
755 ;; (let ((coding (get-language-info language-name 'unibyte-display)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
756 ;; (if coding
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
757 ;; (standard-display-european-internal)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
758 ;; (standard-display-default (if (eq window-system 'pc) 128 160) 255)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
759 ;; (aset standard-display-table 146 nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
760 ;; (or (eq window-system 'pc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
761 ;; (set-terminal-coding-system coding))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
762
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
763 (let ((required-features (get-language-info language-name 'features)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
764 (while required-features
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
765 (require (car required-features))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
766 (setq required-features (cdr required-features))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
767 (let ((func (get-language-info language-name 'setup-function)))
4145
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4103
diff changeset
768 (if (functionp func)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
769 (funcall func)))
952
c10d0c3f965f [xemacs-hg @ 2002-08-02 16:54:11 by youngs]
youngs
parents: 801
diff changeset
770
4490
67fbcaf3dbdc error-sequence -> invalid-sequence
Aidan Kehoe <kehoea@parhasard.net>
parents: 4489
diff changeset
771 (let ((invalid-sequence-coding-system
67fbcaf3dbdc error-sequence -> invalid-sequence
Aidan Kehoe <kehoea@parhasard.net>
parents: 4489
diff changeset
772 (get-language-info language-name 'invalid-sequence-coding-system))
4489
b75b075a9041 Support displaying invalid UTF-8 in language-environment-specific ways.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4468
diff changeset
773 (disp-table (specifier-instance current-display-table))
4687
02b7c7189041 Random (minimal) performance improvements at startup.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4621
diff changeset
774 glyph string unicode-error-lookup first-char)
4490
67fbcaf3dbdc error-sequence -> invalid-sequence
Aidan Kehoe <kehoea@parhasard.net>
parents: 4489
diff changeset
775 (when (consp invalid-sequence-coding-system)
67fbcaf3dbdc error-sequence -> invalid-sequence
Aidan Kehoe <kehoea@parhasard.net>
parents: 4489
diff changeset
776 (setq invalid-sequence-coding-system
67fbcaf3dbdc error-sequence -> invalid-sequence
Aidan Kehoe <kehoea@parhasard.net>
parents: 4489
diff changeset
777 (car invalid-sequence-coding-system)))
4489
b75b075a9041 Support displaying invalid UTF-8 in language-environment-specific ways.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4468
diff changeset
778 (map-char-table
b75b075a9041 Support displaying invalid UTF-8 in language-environment-specific ways.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4468
diff changeset
779 #'(lambda (key entry)
4590
c83cab5a4f04 Display control characters using carets, invalid-sequence-coding-system
Aidan Kehoe <kehoea@parhasard.net>
parents: 4576
diff changeset
780 (setq string (decode-coding-string (string entry)
c83cab5a4f04 Display control characters using carets, invalid-sequence-coding-system
Aidan Kehoe <kehoea@parhasard.net>
parents: 4576
diff changeset
781 invalid-sequence-coding-system))
4604
e0a8715fdb1f Support new IGNORE-INVALID-SEQUENCESP argument, #'query-coding-region.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4590
diff changeset
782 (when (= 1 (length string))
4621
127dbf03e1af Correct a test failure uncovered by the last commit.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4615
diff changeset
783 ;; Treat Unicode error sequence chars as the octets
127dbf03e1af Correct a test failure uncovered by the last commit.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4615
diff changeset
784 ;; corresponding to those on disk:
127dbf03e1af Correct a test failure uncovered by the last commit.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4615
diff changeset
785 (setq unicode-error-lookup
127dbf03e1af Correct a test failure uncovered by the last commit.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4615
diff changeset
786 (get-char-table (aref string 0)
127dbf03e1af Correct a test failure uncovered by the last commit.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4615
diff changeset
787 unicode-error-default-translation-table))
127dbf03e1af Correct a test failure uncovered by the last commit.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4615
diff changeset
788 (when unicode-error-lookup
127dbf03e1af Correct a test failure uncovered by the last commit.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4615
diff changeset
789 (setq string (format "%c" unicode-error-lookup)))
4604
e0a8715fdb1f Support new IGNORE-INVALID-SEQUENCESP argument, #'query-coding-region.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4590
diff changeset
790 ;; Treat control characters specially:
4687
02b7c7189041 Random (minimal) performance improvements at startup.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4621
diff changeset
791 (setq first-char (aref string 0))
02b7c7189041 Random (minimal) performance improvements at startup.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4621
diff changeset
792 (when (or (and (>= #x00 first-char) (<= first-char #x1f))
02b7c7189041 Random (minimal) performance improvements at startup.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4621
diff changeset
793 (and (>= #x80 first-char) (<= first-char #x9f)))
4621
127dbf03e1af Correct a test failure uncovered by the last commit.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4615
diff changeset
794 (setq string (format "^%c" (+ ?@ (aref string 0))))))
4590
c83cab5a4f04 Display control characters using carets, invalid-sequence-coding-system
Aidan Kehoe <kehoea@parhasard.net>
parents: 4576
diff changeset
795 (setq glyph (make-glyph (vector 'string :data string)))
4490
67fbcaf3dbdc error-sequence -> invalid-sequence
Aidan Kehoe <kehoea@parhasard.net>
parents: 4489
diff changeset
796 (set-glyph-face glyph 'unicode-invalid-sequence-warning-face)
4489
b75b075a9041 Support displaying invalid UTF-8 in language-environment-specific ways.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4468
diff changeset
797 (put-char-table key glyph disp-table)
b75b075a9041 Support displaying invalid UTF-8 in language-environment-specific ways.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4468
diff changeset
798 nil)
b75b075a9041 Support displaying invalid UTF-8 in language-environment-specific ways.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4468
diff changeset
799 unicode-error-default-translation-table))
b75b075a9041 Support displaying invalid UTF-8 in language-environment-specific ways.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4468
diff changeset
800
952
c10d0c3f965f [xemacs-hg @ 2002-08-02 16:54:11 by youngs]
youngs
parents: 801
diff changeset
801 ;; Fit the charsets preferences in unicode conversions for the
c10d0c3f965f [xemacs-hg @ 2002-08-02 16:54:11 by youngs]
youngs
parents: 801
diff changeset
802 ;; language environment.
1285
c7f36e03a343 [xemacs-hg @ 2003-02-10 17:47:38 by stephent]
stephent
parents: 952
diff changeset
803 (set-language-unicode-precedence-list
c7f36e03a343 [xemacs-hg @ 2003-02-10 17:47:38 by stephent]
stephent
parents: 952
diff changeset
804 (get-language-info language-name 'charset))
952
c10d0c3f965f [xemacs-hg @ 2002-08-02 16:54:11 by youngs]
youngs
parents: 801
diff changeset
805
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
806 (run-hooks 'set-language-environment-hook)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
807 (force-mode-line-update t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
808
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
809 ;; (defun standard-display-european-internal ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
810 ;; ;; Actually set up direct output of non-ASCII characters.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
811 ;; (standard-display-8bit (if (eq window-system 'pc) 128 160) 255)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
812 ;; ;; Unibyte Emacs on MS-DOS wants to display all 8-bit characters with
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
813 ;; ;; the native font, and codes 160 and 146 stand for something very
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
814 ;; ;; different there.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
815 ;; (or (and (eq window-system 'pc) (not default-enable-multibyte-characters))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
816 ;; (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
817 ;; ;; Make non-line-break space display as a plain space.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
818 ;; ;; Most X fonts do the wrong thing for code 160.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
819 ;; (aset standard-display-table 160 [32])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
820 ;; ;; Most Windows programs send out apostrophe's as \222. Most X fonts
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
821 ;; ;; don't contain a character at that position. Map it to the ASCII
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
822 ;; ;; apostrophe.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
823 ;; (aset standard-display-table 146 [39]))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
824
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
825 ;; bogus FSF function describe-specified-language-support.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
826
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
827 (defun describe-language-environment (language-name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
828 "Describe how Emacs supports language environment LANGUAGE-NAME."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
829 (interactive
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
830 (list (read-language-name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
831 'documentation
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
832 "Describe language environment (default, current choice): ")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
833 (if (null language-name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
834 (setq language-name current-language-environment))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
835 (if (or (null language-name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
836 (null (get-language-info language-name 'documentation)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
837 (error "No documentation for the specified language"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
838 (if (symbolp language-name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
839 (setq language-name (symbol-name language-name)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
840 (let ((doc (get-language-info language-name 'documentation)))
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
841 (flet ((princ-list (&rest args)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
842 (while args (princ (car args)) (setq args (cdr args)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
843 (princ "\n")))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
844 (with-output-to-temp-buffer "*Help*"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
845 (princ-list language-name " language environment" "\n")
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
846 (if (stringp doc)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
847 (progn
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
848 (princ-list doc)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
849 (terpri)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
850 (let ((str (get-language-info language-name 'sample-text)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
851 (if (stringp str)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
852 (progn
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
853 (princ "Sample text:\n")
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
854 (princ-list " " str)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
855 (terpri))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
856 (let ((input-method (get-language-info language-name 'input-method))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
857 (l (copy-sequence input-method-alist)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
858 (princ "Input methods")
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
859 (when input-method
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
860 (princ (format " (default, %s)" input-method))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
861 (setq input-method (assoc input-method input-method-alist))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
862 (setq l (cons input-method (delete input-method l))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
863 (princ ":\n")
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
864 (while l
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
865 (if (string= language-name (nth 1 (car l)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
866 (princ-list " " (car (car l))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
867 (format " (`%s' in mode line)" (nth 3 (car l)))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
868 (setq l (cdr l))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
869 (terpri)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
870 (princ "Character sets:\n")
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
871 (let ((l (get-language-info language-name 'charset)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
872 (if (null l)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
873 (princ-list " nothing specific to " language-name)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
874 (while l
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
875 (princ-list " " (car l) ": "
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
876 (charset-description (car l)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
877 (setq l (cdr l)))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
878 (terpri)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
879 (princ "Coding systems:\n")
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
880 (let ((l (get-language-info language-name 'coding-system)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
881 (if (null l)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
882 (princ-list " nothing specific to " language-name)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
883 (while l
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
884 (princ ; (format " %s (`%c' in mode line):\n\t%s\n"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
885 ;; In XEmacs, `coding-system-mnemonic' returns string.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
886 (format " %s (`%s' in English, `%s' in mode line):\n\t%s\n"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
887 (car l)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
888 (coding-system-description (car l))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
889 (coding-system-mnemonic (car l))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
890 (or (coding-system-documentation (car l))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
891 "Not documented.")) )
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
892 ;; (let ((aliases (coding-system-get (car l) 'alias-coding-systems)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
893 ;; (when aliases
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
894 ;; (princ "\t")
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
895 ;; (princ (cons 'alias: (cdr aliases)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
896 ;; (terpri)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
897 (setq l (cdr l)))))))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
898
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
899 ;;; Charset property
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
900
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
901 ;; (defsubst get-charset-property (charset propname)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
902 ;; "Return the value of CHARSET's PROPNAME property.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
903 ;; This is the last value stored with
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
904 ;; `(put-charset-property CHARSET PROPNAME VALUE)'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
905 ;; (plist-get (charset-plist charset) propname))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
906
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
907 ;; (defsubst put-charset-property (charset propname value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
908 ;; "Store CHARSETS's PROPNAME property with value VALUE.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
909 ;; It can be retrieved with `(get-charset-property CHARSET PROPNAME)'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
910 ;; (set-charset-plist charset
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
911 ;; (plist-put (charset-plist charset) propname value)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
912
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
913 (defvar char-code-property-table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
914 (make-char-table 'generic)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
915 "Char-table containing a property list of each character code.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
916
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
917 See also the documentation of `get-char-code-property' and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
918 `put-char-code-property'")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
919 ;; (let ((plist (aref char-code-property-table char)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
920 (defun get-char-code-property (char propname)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
921 "Return the value of CHAR's PROPNAME property in `char-code-property-table'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
922 (let ((plist (get-char-table char char-code-property-table)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
923 (if (listp plist)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
924 (car (cdr (memq propname plist))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
925
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
926 (defun put-char-code-property (char propname value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
927 "Store CHAR's PROPNAME property with VALUE in `char-code-property-table'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
928 It can be retrieved with `(get-char-code-property CHAR PROPNAME)'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
929 (let ((plist (get-char-table char char-code-property-table)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
930 (if plist
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
931 (let ((slot (memq propname plist)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
932 (if slot
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
933 (setcar (cdr slot) value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
934 (nconc plist (list propname value))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
935 (put-char-table char (list propname value) char-code-property-table)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
936 )))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
937
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
938
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
939 ;; Pretty description of encoded string
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
940
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
941 ;; Alist of ISO 2022 control code vs the corresponding mnemonic string.
4468
a78d697ccd2c Import and extend GNU's descr-text.el, supporting prefix argument for C-x =
Aidan Kehoe <kehoea@parhasard.net>
parents: 4292
diff changeset
942 (defvar iso-2022-control-alist
a78d697ccd2c Import and extend GNU's descr-text.el, supporting prefix argument for C-x =
Aidan Kehoe <kehoea@parhasard.net>
parents: 4292
diff changeset
943 '((?\x1b . "ESC")
a78d697ccd2c Import and extend GNU's descr-text.el, supporting prefix argument for C-x =
Aidan Kehoe <kehoea@parhasard.net>
parents: 4292
diff changeset
944 (?\x0e . "SO")
a78d697ccd2c Import and extend GNU's descr-text.el, supporting prefix argument for C-x =
Aidan Kehoe <kehoea@parhasard.net>
parents: 4292
diff changeset
945 (?\x0f . "SI")
a78d697ccd2c Import and extend GNU's descr-text.el, supporting prefix argument for C-x =
Aidan Kehoe <kehoea@parhasard.net>
parents: 4292
diff changeset
946 (?\x8e . "SS2")
a78d697ccd2c Import and extend GNU's descr-text.el, supporting prefix argument for C-x =
Aidan Kehoe <kehoea@parhasard.net>
parents: 4292
diff changeset
947 (?\x8f . "SS3")
a78d697ccd2c Import and extend GNU's descr-text.el, supporting prefix argument for C-x =
Aidan Kehoe <kehoea@parhasard.net>
parents: 4292
diff changeset
948 (?\x9b . "CSI")))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
949
4468
a78d697ccd2c Import and extend GNU's descr-text.el, supporting prefix argument for C-x =
Aidan Kehoe <kehoea@parhasard.net>
parents: 4292
diff changeset
950 (defun encoded-string-description (str coding-system)
a78d697ccd2c Import and extend GNU's descr-text.el, supporting prefix argument for C-x =
Aidan Kehoe <kehoea@parhasard.net>
parents: 4292
diff changeset
951 "Return a pretty description of STR that is encoded by CODING-SYSTEM."
4604
e0a8715fdb1f Support new IGNORE-INVALID-SEQUENCESP argument, #'query-coding-region.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4590
diff changeset
952 ;; XEmacs; no transformation to unibyte.
4468
a78d697ccd2c Import and extend GNU's descr-text.el, supporting prefix argument for C-x =
Aidan Kehoe <kehoea@parhasard.net>
parents: 4292
diff changeset
953 (mapconcat
a78d697ccd2c Import and extend GNU's descr-text.el, supporting prefix argument for C-x =
Aidan Kehoe <kehoea@parhasard.net>
parents: 4292
diff changeset
954 (if (and coding-system (eq (coding-system-type coding-system) 'iso2022))
a78d697ccd2c Import and extend GNU's descr-text.el, supporting prefix argument for C-x =
Aidan Kehoe <kehoea@parhasard.net>
parents: 4292
diff changeset
955 ;; Try to get a pretty description for ISO 2022 escape sequences.
a78d697ccd2c Import and extend GNU's descr-text.el, supporting prefix argument for C-x =
Aidan Kehoe <kehoea@parhasard.net>
parents: 4292
diff changeset
956 (function (lambda (x) (or (cdr (assq x iso-2022-control-alist))
a78d697ccd2c Import and extend GNU's descr-text.el, supporting prefix argument for C-x =
Aidan Kehoe <kehoea@parhasard.net>
parents: 4292
diff changeset
957 (format "#x%02X" x))))
a78d697ccd2c Import and extend GNU's descr-text.el, supporting prefix argument for C-x =
Aidan Kehoe <kehoea@parhasard.net>
parents: 4292
diff changeset
958 (function (lambda (x) (format "#x%02X" x))))
a78d697ccd2c Import and extend GNU's descr-text.el, supporting prefix argument for C-x =
Aidan Kehoe <kehoea@parhasard.net>
parents: 4292
diff changeset
959 str " "))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
960
4604
e0a8715fdb1f Support new IGNORE-INVALID-SEQUENCESP argument, #'query-coding-region.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4590
diff changeset
961 ;; XEmacs;
e0a8715fdb1f Support new IGNORE-INVALID-SEQUENCESP argument, #'query-coding-region.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4590
diff changeset
962 ;; (defun encode-coding-char (char coding-system) in coding.el.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
963
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
964
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
965 ;; #### The following section is utter junk from mule-misc.el.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
966 ;; I've deleted everything that's not referenced in mule-packages and
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
967 ;; not in FSF 20.6; there's no point in keeping old namespace-polluting
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
968 ;; Mule 2.3 crap around. --ben
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
969
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
970 (defvar self-insert-after-hook nil
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
971 "Hook to run when extended self insertion command exits. Should take
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
972 two arguments START and END corresponding to character position.")
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
973
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
974 (make-variable-buffer-local 'self-insert-after-hook)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
975
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
976 (defun delete-text-in-column (from to)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
977 "Delete the text between column FROM and TO (exclusive) of the current line.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
978 Nil of FORM or TO means the current column.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
979
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
980 If there's a character across the borders, the character is replaced
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
981 with the same width of spaces before deleting."
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
982 (save-excursion
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
983 (let (p1 p2)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
984 (if from
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
985 (progn
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
986 (setq p1 (move-to-column from))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
987 (if (> p1 from)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
988 (progn
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
989 (delete-char -1)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
990 (insert-char ? (- p1 (current-column)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
991 (forward-char (- from p1))))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
992 (setq p1 (point))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
993 (if to
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
994 (progn
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
995 (setq p2 (move-to-column to))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
996 (if (> p2 to)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
997 (progn
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
998 (delete-char -1)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
999 (insert-char ? (- p2 (current-column)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1000 (forward-char (- to p2))))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1001 (setq p2 (point))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1002 (delete-region p1 p2))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1003
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1004 (defun cancel-undo-boundary ()
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1005 "Cancel undo boundary."
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1006 (if (and (consp buffer-undo-list)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1007 (null (car buffer-undo-list)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1008 (setq buffer-undo-list (cdr buffer-undo-list))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1009
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1010 (defun define-egg-environment (env-sym doc-string enable-function)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1011 "Define a new language environment for egg, named by ENV-SYM.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1012 DOC-STRING should be a string describing the environment.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1013 ENABLE-FUNCTION should be a function of no arguments that will be called
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1014 when the language environment is made current."
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1015 (put env-sym 'egg-environ-doc-string doc-string)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1016 (put env-sym 'set-egg-environ enable-function))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1017
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1018
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1019 ;; Init code.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1020
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1021 ;; auto-language-alist deleted. We have a more sophisticated system,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1022 ;; with the locales stored in the language data.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1023
4145
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4103
diff changeset
1024 ;; Initialised in mule/general-late.el, which is compiled after all the
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4103
diff changeset
1025 ;; language support--and, thus, minority Chinese coding systems and so
edb00a8b4eff [xemacs-hg @ 2007-08-26 20:00:29 by aidan]
aidan
parents: 4103
diff changeset
1026 ;; on--has been loaded.
3707
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1027 (defvar posix-charset-to-coding-system-hash nil
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1028 "A map from the POSIX locale charset versions of the defined coding
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1029 systems' names, with all alpha-numeric characters removed, to the actual
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1030 coding system names. Used at startup when working out which coding system
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1031 should be the default for the locale. ")
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1032
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1033 (defun parse-posix-locale-string (locale-string)
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1034 "Return values \(LANGUAGE REGION CHARSET MODIFIERS\) given LOCALE-STRING.
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1035
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1036 LOCALE-STRING should be a POSIX locale. If it cannot be parsed as such, this
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1037 function returns nil. "
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1038 (let (language region charset modifiers locinfo)
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1039 (setq locale-string (downcase locale-string))
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1040 (cond ((string-match
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1041 #r"^\([a-z0-9]\{2,2\}\)\(_[a-z0-9]\{2,2\}\)?\(\.[^@]*\)?\(@.*\)?$"
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1042 locale-string)
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1043 (setq language (match-string 1 locale-string)
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1044 region (match-string 2 locale-string)
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1045 charset (match-string 3 locale-string)
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1046 modifiers (match-string 4 locale-string)
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1047 region (and region (replace-in-string region "^_" ""))
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1048 charset (and charset (replace-in-string charset #r"^\." ""))
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1049 modifiers (and modifiers
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1050 (replace-in-string modifiers "^@" "")))
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1051 (when (and modifiers (equal modifiers "euro") (null charset))
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1052 ;; Not ideal for Latvian, say, but I don't have any locales
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1053 ;; where the @euro modifier doesn't mean ISO-8859-15 in the 956
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1054 ;; I have.
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1055 (setq charset "iso-8859-15"))
4073
c098c0d9125f [xemacs-hg @ 2007-07-23 14:19:39 by aidan]
aidan
parents: 3999
diff changeset
1056 (when (and modifiers (equal modifiers "cyrillic") (null charset))
c098c0d9125f [xemacs-hg @ 2007-07-23 14:19:39 by aidan]
aidan
parents: 3999
diff changeset
1057 ;; Feedback wanted!
c098c0d9125f [xemacs-hg @ 2007-07-23 14:19:39 by aidan]
aidan
parents: 3999
diff changeset
1058 (setq charset "windows-1251"))
3707
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1059 (values language region charset modifiers))
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1060 ((and (string-match "^[a-z0-9]+$" locale-string)
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1061 (assoc-ignore-case locale-string language-info-alist))
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1062 (setq language (get-language-info locale-string 'locale)
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1063 language (if (listp language) (car language) language))
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1064 (values language region charset modifiers))
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1065 ((string-match #r"^\([a-z0-9]+\)\.\([a-z0-9]+\)$" locale-string)
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1066 (when (assoc-ignore-case
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1067 (setq locinfo (match-string 1 locale-string))
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1068 language-info-alist)
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1069 (setq language (get-language-info locinfo 'locale)
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1070 language (if (listp language) (car language) language)))
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1071 (setq charset (match-string 2 locale-string))
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1072 (values language region charset modifiers)))))
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1073
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1074 (defun create-variant-language-environment (langenv coding-system)
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1075 "Create a variant of LANGENV with CODING-SYSTEM as its coding systems.
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1076
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1077 The coding systems in question are those described in the
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1078 `set-language-info' docstring with the property names of
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1079 `native-coding-system' and `coding-system'. The name of the new language
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1080 environment is the name of the old language environment, followed by
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1081 CODING-SYSTEM in parentheses. Returns the name of the new language
3767
6b2ef948e140 [xemacs-hg @ 2006-12-29 18:09:38 by aidan]
aidan
parents: 3737
diff changeset
1082 environment.
6b2ef948e140 [xemacs-hg @ 2006-12-29 18:09:38 by aidan]
aidan
parents: 3737
diff changeset
1083
6b2ef948e140 [xemacs-hg @ 2006-12-29 18:09:38 by aidan]
aidan
parents: 3737
diff changeset
1084 This function also modifies the `coding-priority' of a language
3707
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1085 environment. "
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1086 (check-coding-system coding-system)
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1087 (if (symbolp langenv) (setq langenv (symbol-name langenv)))
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1088 (unless (setq langenv
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1089 (assoc-ignore-case langenv language-info-alist))
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1090 (error 'wrong-type-argument "Not a known language environment"))
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1091 (set-language-info-alist
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1092 (if (string-match " ([^)]+)$" (car langenv))
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1093 (replace-match (format " (%s)"
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1094 (upcase (symbol-name
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1095 (coding-system-name coding-system))))
3737
7a1c4c523603 [xemacs-hg @ 2006-12-11 12:39:55 by aidan]
aidan
parents: 3707
diff changeset
1096 nil nil (car langenv))
3707
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1097 (format "%s (%s)" (car langenv)
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1098 (upcase (symbol-name (coding-system-name coding-system)))))
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1099 (destructive-plist-to-alist
3767
6b2ef948e140 [xemacs-hg @ 2006-12-29 18:09:38 by aidan]
aidan
parents: 3737
diff changeset
1100 (plist-put
6b2ef948e140 [xemacs-hg @ 2006-12-29 18:09:38 by aidan]
aidan
parents: 3737
diff changeset
1101 (plist-put
4292
0194a744d2d3 [xemacs-hg @ 2007-11-28 21:17:45 by aidan]
aidan
parents: 4145
diff changeset
1102 (plist-put
0194a744d2d3 [xemacs-hg @ 2007-11-28 21:17:45 by aidan]
aidan
parents: 4145
diff changeset
1103 (plist-put (alist-to-plist (cdr langenv)) 'native-coding-system
0194a744d2d3 [xemacs-hg @ 2007-11-28 21:17:45 by aidan]
aidan
parents: 4145
diff changeset
1104 coding-system)
0194a744d2d3 [xemacs-hg @ 2007-11-28 21:17:45 by aidan]
aidan
parents: 4145
diff changeset
1105 'coding-system (cons coding-system
0194a744d2d3 [xemacs-hg @ 2007-11-28 21:17:45 by aidan]
aidan
parents: 4145
diff changeset
1106 (cdr (assoc 'coding-system (cdr langenv)))))
0194a744d2d3 [xemacs-hg @ 2007-11-28 21:17:45 by aidan]
aidan
parents: 4145
diff changeset
1107 'coding-priority (cons coding-system
0194a744d2d3 [xemacs-hg @ 2007-11-28 21:17:45 by aidan]
aidan
parents: 4145
diff changeset
1108 (cdr (assq 'coding-priority (cdr langenv)))))
0194a744d2d3 [xemacs-hg @ 2007-11-28 21:17:45 by aidan]
aidan
parents: 4145
diff changeset
1109 ;; The tutorial coding system is important; otherwise the tutorial file
0194a744d2d3 [xemacs-hg @ 2007-11-28 21:17:45 by aidan]
aidan
parents: 4145
diff changeset
1110 ;; gets loaded in the variant coding system.
0194a744d2d3 [xemacs-hg @ 2007-11-28 21:17:45 by aidan]
aidan
parents: 4145
diff changeset
1111 'tutorial-coding-system
0194a744d2d3 [xemacs-hg @ 2007-11-28 21:17:45 by aidan]
aidan
parents: 4145
diff changeset
1112 (or (car-safe (cdr-safe (assoc 'tutorial-coding-system (cdr langenv))))
0194a744d2d3 [xemacs-hg @ 2007-11-28 21:17:45 by aidan]
aidan
parents: 4145
diff changeset
1113 (car-safe (cdr-safe (assoc 'coding-system (cdr langenv)))))))))
801
2b676dc88c66 [xemacs-hg @ 2002-04-01 03:58:02 by ben]
ben
parents: 778
diff changeset
1114
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1115 (defun get-language-environment-from-locale (locale)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1116 "Convert LOCALE into a language environment.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1117 LOCALE is a C library locale string, as returned by `current-locale'.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1118 Uses the `locale' property of the language environment."
3707
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1119 (block langenv
4103
b4f4e0cc90f1 [xemacs-hg @ 2007-08-07 23:08:47 by aidan]
aidan
parents: 4073
diff changeset
1120 (multiple-value-bind (language ignored-arg charset ignored-arg)
3707
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1121 (parse-posix-locale-string locale)
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1122 (let ((case-fold-search t)
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1123 (desired-coding-system
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1124 (and charset (gethash (replace-in-string charset "[^a-z0-9]" "")
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1125 posix-charset-to-coding-system-hash)))
3767
6b2ef948e140 [xemacs-hg @ 2006-12-29 18:09:38 by aidan]
aidan
parents: 3737
diff changeset
1126 lang locs given-coding-system)
3707
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1127 (dolist (langcons language-info-alist)
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1128 (setq lang (car langcons)
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1129 locs (get-language-info lang 'locale))
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1130 (dolist (loc (if (listp locs) locs (list locs)))
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1131 (cond ((functionp loc)
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1132 (if (funcall loc locale)
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1133 (return-from langenv lang)))
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1134 ((stringp loc)
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1135 (when (or (equal loc language)
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1136 (string-match
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1137 (format "^%s\\([^A-Za-z0-9]\\|$\\)" loc)
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1138 locale))
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1139 (if (or (null desired-coding-system)
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1140 (and desired-coding-system
3767
6b2ef948e140 [xemacs-hg @ 2006-12-29 18:09:38 by aidan]
aidan
parents: 3737
diff changeset
1141 (or (eq desired-coding-system
6b2ef948e140 [xemacs-hg @ 2006-12-29 18:09:38 by aidan]
aidan
parents: 3737
diff changeset
1142 (setq given-coding-system
6b2ef948e140 [xemacs-hg @ 2006-12-29 18:09:38 by aidan]
aidan
parents: 3737
diff changeset
1143 (get-language-info
6b2ef948e140 [xemacs-hg @ 2006-12-29 18:09:38 by aidan]
aidan
parents: 3737
diff changeset
1144 lang
6b2ef948e140 [xemacs-hg @ 2006-12-29 18:09:38 by aidan]
aidan
parents: 3737
diff changeset
1145 'native-coding-system)))
6b2ef948e140 [xemacs-hg @ 2006-12-29 18:09:38 by aidan]
aidan
parents: 3737
diff changeset
1146 (and (listp given-coding-system)
6b2ef948e140 [xemacs-hg @ 2006-12-29 18:09:38 by aidan]
aidan
parents: 3737
diff changeset
1147 (memq desired-coding-system
6b2ef948e140 [xemacs-hg @ 2006-12-29 18:09:38 by aidan]
aidan
parents: 3737
diff changeset
1148 given-coding-system)))))
3707
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1149 (return-from langenv lang)
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1150 (return-from langenv
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1151 (create-variant-language-environment
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1152 lang desired-coding-system))))))))))))
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1153
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1154 (defun mswindows-get-language-environment-from-locale (ms-locale)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1155 "Convert MS-LOCALE (an MS Windows locale) into a language environment.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1156 MS-LOCALE is in the format recognized by `set-mswindows-current-locale' --
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1157 i.e. a language string or a cons (LANG . SUBLANG). Note: This is NOT the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1158 same as the C library locale format (see `set-current-locale')!
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1159
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1160 This looks up the `mswindows-locale' property of all language environments;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1161 if nothing matching is found, it looks for a language environment with the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1162 same name (modulo case differences) as the LANG part of the locale."
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1163 (or (consp ms-locale) (setq ms-locale (cons ms-locale "DEFAULT")))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1164 (or (block langenv
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1165 (dolist (langcons language-info-alist)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1166 (let* ((lang (car langcons))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1167 (mswlocs (get-language-info lang 'mswindows-locale))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1168 (mswlocs (if (and (consp mswlocs)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1169 (listp (cdr mswlocs)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1170 mswlocs (list mswlocs))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1171 (dolist (loc mswlocs)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1172 (or (consp loc) (setq loc (cons loc "DEFAULT")))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1173 (if (equalp loc ms-locale)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1174 (return-from langenv lang))))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1175 (dolist (langcons language-info-alist)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1176 (let* ((lang (car langcons)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1177 (if (equalp lang (car ms-locale))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1178 (return-from nil lang))))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1179
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1180 (defun get-native-coding-system-from-language-environment (langenv locale)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1181 "Return the native coding system appropriate for LANGENV.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1182 LANGENV is a string naming a language environment. May use the LOCALE
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1183 \(which should be the C library LOCALE corresponding to LANGENV) to
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1184 determine the correct coding system. (For example, in the Japanese language
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1185 environment, there are multiple encodings in use: euc-jp, shift-jis, jis7,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1186 jis8, iso-2022-jp, etc. The LOCALE may tell which one is correct.)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1187
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1188 Specifically: Under X, the returned value is determined from these two.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1189 Under MS Windows, the native coding system must be set from the default
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1190 system locale and is not influenced by LOCALE. (In other words, a program
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1191 can't set the text encoding used to communicate with the OS. To get around
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1192 this, we use Unicode whenever available, i.e. on Windows NT always and on
1318
b531bf8658e9 [xemacs-hg @ 2003-02-21 06:56:46 by ben]
ben
parents: 1285
diff changeset
1193 Windows 9x whenever a Unicode version of a system call is available.)"
4834
b3ea9c582280 Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents: 4687
diff changeset
1194 (cond ((eq system-type 'windows-nt)
b3ea9c582280 Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents: 4687
diff changeset
1195 ;; should not apply to Cygwin, I don't think
b3ea9c582280 Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents: 4687
diff changeset
1196 'mswindows-multibyte-system-default)
b3ea9c582280 Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents: 4687
diff changeset
1197 ((featurep 'cygwin-use-utf-8)
b3ea9c582280 Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents: 4687
diff changeset
1198 'utf-8)
b3ea9c582280 Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents: 4687
diff changeset
1199 (t
b3ea9c582280 Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents: 4687
diff changeset
1200 (let ((ncod (get-language-info langenv 'native-coding-system)))
b3ea9c582280 Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents: 4687
diff changeset
1201 (if (or (functionp ncod) (not (listp ncod)))
b3ea9c582280 Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents: 4687
diff changeset
1202 (setq ncod (list ncod)))
b3ea9c582280 Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents: 4687
diff changeset
1203 (let ((native
b3ea9c582280 Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents: 4687
diff changeset
1204 (dolist (try-native ncod)
b3ea9c582280 Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents: 4687
diff changeset
1205 (let ((result
b3ea9c582280 Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents: 4687
diff changeset
1206 (if (functionp try-native)
b3ea9c582280 Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents: 4687
diff changeset
1207 (funcall try-native locale)
b3ea9c582280 Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents: 4687
diff changeset
1208 try-native)))
b3ea9c582280 Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents: 4687
diff changeset
1209 (if result (return result))))))
b3ea9c582280 Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents: 4687
diff changeset
1210 (or native (car (get-language-info langenv 'coding-system))
b3ea9c582280 Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents: 4687
diff changeset
1211 'raw-text))))))
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1212
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1213 (defun get-coding-system-from-locale (locale)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1214 "Return the coding system corresponding to a locale string."
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1215 (get-native-coding-system-from-language-environment
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1216 (get-language-environment-from-locale locale) locale))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1217
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1218 (defvar mswindows-langenv-to-locale-table (make-hash-table)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1219 "Table mapping language environments to associated MS Windows locales.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1220 There may be more than one MS Windows locale that maps to a given language
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1221 environment, so once we've made the mapping, we record it here when we need
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1222 to make the reverse mapping. For example, all MS Windows locales with
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1223 language ENGLISH will map to language environment English, and when the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1224 user starts up in such a locale, switches to another language environment
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1225 and then back to English, we want the same locale again.")
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1226
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1227 (defun set-locale-for-language-environment (langenv)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1228 "Sets the current system locale as appropriate for LANGENV.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1229 LANGENV is a language environment. The locale is determined by looking at
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1230 the 'locale (or maybe 'mswindows-locale) property of LANGENV, and then
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1231 setting it using `set-current-locale' and maybe also
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1232 `mswindows-set-current-locale'. Also sets the LANG environment variable.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1233 Returns non-nil if successfully set the locale(s)."
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1234 (flet ((mswindows-get-and-set-locale-from-langenv (langenv)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1235 ;; find the mswindows locale for the langenv, make it current,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1236 ;; and return it. first we check the langenv-to-locale table
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1237 ;; ...
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1238 (let ((ms-locale
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1239 (gethash langenv mswindows-langenv-to-locale-table)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1240 (if ms-locale (progn
778
2923009caf47 [xemacs-hg @ 2002-03-16 10:38:59 by ben]
ben
parents: 771
diff changeset
1241 (declare-fboundp (mswindows-set-current-locale
2923009caf47 [xemacs-hg @ 2002-03-16 10:38:59 by ben]
ben
parents: 771
diff changeset
1242 ms-locale))
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1243 ms-locale)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1244 ;; ... if not, see if the langenv specifies any locale(s).
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1245 ;; if not, construct one from the langenv name.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1246 (let* ((mslocs (get-language-info langenv 'mswindows-locale))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1247 (mslocs (or mslocs (cons (upcase langenv) "DEFAULT")))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1248 (mslocs (if (and (consp mslocs)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1249 (listp (cdr mslocs)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1250 mslocs (list mslocs))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1251 (dolist (msloc mslocs)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1252 ;; Sometimes a language with DEFAULT is different from
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1253 ;; with SYS_DEFAULT, and on my system
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1254 ;; (set-current-locale "chinese") is NOT the same as
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1255 ;; (set-current-locale "chinese-default")! The latter
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1256 ;; gives Taiwan (DEFAULT), the former PRC (SYS_DEFAULT).
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1257 ;; In the interests of consistency, we always use DEFAULT.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1258 (or (consp msloc) (setq msloc (cons msloc "DEFAULT")))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1259 (when (condition-case nil
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1260 (progn
778
2923009caf47 [xemacs-hg @ 2002-03-16 10:38:59 by ben]
ben
parents: 771
diff changeset
1261 (declare-fboundp (mswindows-set-current-locale
2923009caf47 [xemacs-hg @ 2002-03-16 10:38:59 by ben]
ben
parents: 771
diff changeset
1262 msloc))
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1263 t)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1264 (error nil))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1265 (return msloc))))))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1266 (if (eq system-type 'windows-nt)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1267 (let ((ms-locale (mswindows-get-and-set-locale-from-langenv langenv)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1268 (when ms-locale
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1269 ;; also need to set the clib locale.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1270 (or (set-current-locale
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1271 ;; if the locale is '("DUTCH" . "DUTCH_BELGIAN"),
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1272 ;; try "DUTCH-BELGIAN". (Case is insignificant;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1273 ;; "dutch-belgian" works just as well.) This type
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1274 ;; of transformation should always work, and you
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1275 ;; get back the canonicalized version -- in this
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1276 ;; case "Dutch_Belgium.1252". Note the futility of
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1277 ;; trying to construct "Belgium" directly from
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1278 ;; "BELGIAN".
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1279 ;;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1280 ;; BUT ... We actually have to be trickier.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1281 ;; ("SPANISH" . "SPANISH_DOMINICAN_REPUBLIC") needs
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1282 ;; to end up as "SPANISH-DOMINICAN REPUBLIC"; any
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1283 ;; other punctuation makes it fail (you either get
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1284 ;; Spain for the country, or nil).
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1285 ;;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1286 ;; assume it's DEFAULT or NEUTRAL (or something else
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1287 ;; without the language in it?) and prepend the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1288 ;; language.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1289 (if (string-match "_" (cdr ms-locale))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1290 (replace-in-string
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1291 (replace-match "-" nil nil (cdr ms-locale)) "_" " ")
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1292 (format "%s-%s" (car ms-locale) (cdr ms-locale))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1293 ;; ???? huh ???? if failure, just try the language
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1294 ;; name.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1295 (set-current-locale (car ms-locale))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1296 ;; also set LANG, for the benefit of Cygwin subprocesses.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1297 (let* ((cygloc (or (get-language-info langenv 'cygwin-locale)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1298 (get-language-info langenv 'locale)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1299 (cygloc (if (listp cygloc) (car (last cygloc)) cygloc)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1300 (if (and cygloc (stringp cygloc)) (setenv "LANG" cygloc)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1301 (not (null ms-locale)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1302
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1303 ;; not MS Windows native.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1304
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1305 ;; Cygwin is as usual an unholy mixture -- C library locales
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1306 ;; that follow Unix conventions, but also MS Windows locales.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1307 ;; So set the MS Windows locale, and then try to find a Unix
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1308 ;; locale.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1309 (when (eq system-type 'cygwin32)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1310 (mswindows-get-and-set-locale-from-langenv langenv))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1311 (let ((locs (get-language-info langenv 'locale)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1312 (dolist (loc (if (listp locs) locs (list locs)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1313 (let ((retval
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1314 (cond ((functionp loc) (funcall loc nil))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1315 ((stringp loc) (set-current-locale loc))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1316 (t nil))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1317 (when retval
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1318 (setenv "LANG" retval)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1319 (return t))))))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1320
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1321 (defun set-language-environment-coding-systems (language-name
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1322 &optional eol-type)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1323 "Do various coding system setups for language environment LANGUAGE-NAME.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1324 This function assumes that the locale for LANGUAGE-NAME has been set using
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1325 `set-current-locale'.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1326
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1327 The optional arg EOL-TYPE specifies the eol-type of the default value
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1328 of buffer-file-coding-system set by this function."
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1329
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1330 ;; The following appeared as the third paragraph of the doc string for this
778
2923009caf47 [xemacs-hg @ 2002-03-16 10:38:59 by ben]
ben
parents: 771
diff changeset
1331 ;; function, but it's not in FSF 21.1, and it's not true, since we call
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1332 ;; reset-coding-categories-to-default before calling this function. ####
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1333 ;; Should we rethink this?
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1334
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1335 ; Note that `coding-priority-list' is not reset first; thus changing language
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1336 ; environment allows recognition of coding systems from previously set language
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1337 ; environments. (This will not work if the desired coding systems are from the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1338 ; same category. E.g., starting with a Hebrew language environment, ISO 8859-8
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1339 ; will be recognized. If you shift to Russian, ISO 8859-8 will be shadowed by
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1340 ; ISO 8859-5, and cannot be automatically recognized without resetting the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1341 ; language environment to Hebrew. However, if you shift from Japanese to
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1342 ; Russian, ISO-2022-JP will continue to be automatically recognized, since
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1343 ; ISO-8859-5 and ISO-2022-JP are different coding categories.)"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1344
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1345 (flet ((maybe-change-coding-system-with-eol (codesys eol-type)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1346 ;; if the EOL type specifies a specific type of ending,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1347 ;; then add that ending onto the given CODESYS; otherwise,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1348 ;; return CODESYS unchanged.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1349 (if (memq eol-type '(lf crlf cr unix dos mac))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1350 (coding-system-change-eol-conversion codesys eol-type)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1351 codesys)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1352
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1353 ;; initialize category mappings and priority list.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1354 (let* ((priority (get-language-info language-name 'coding-priority))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1355 (default-coding (car priority)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1356 (if priority
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1357 (let ((categories (mapcar 'coding-system-category priority))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1358 category checked-categories)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1359 (while priority
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1360 (unless (memq (setq category (car categories)) checked-categories)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1361 (set-coding-category-system category (car priority))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1362 (setq checked-categories (cons category checked-categories)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1363 (setq priority (cdr priority)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1364 categories (cdr categories)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1365 (set-coding-priority-list (nreverse checked-categories))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1366 ))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1367
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1368 ;; set the default buffer coding system from the first element of the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1369 ;; list in the `coding-priority' property, under Unix. Under Windows, it
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1370 ;; should stay at `mswindows-multibyte', which will reference the current
3707
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1371 ;; code page. ([Does it really make sense to set the Unix default
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1372 ;; that way? NOTE also that it's not the same as the native coding
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1373 ;; system for the locale, which is correct -- the form we choose for text
3707
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1374 ;; files should not necessarily have any relevance to whether we're in a
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1375 ;; Shift-JIS, EUC-JP, JIS, or other Japanese locale.])
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1376 ;;
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1377 ;; On Unix--with the exception of Mac OS X--there is no way to
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1378 ;; know for certain what coding system to use for file names, and
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1379 ;; the environment is the best guess. If a particular user's
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1380 ;; preferences differ from this, then that particular user needs
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1381 ;; to edit ~/.xemacs/init.el. Aidan Kehoe, Sun Nov 26 18:11:31 CET
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1382 ;; 2006. OS X uses an almost-normal-form version of UTF-8.
f6f6fc9eb269 [xemacs-hg @ 2006-11-28 21:20:22 by aidan]
aidan
parents: 3173
diff changeset
1383
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1384 (unless (memq system-type '(windows-nt cygwin32))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1385 (set-default-buffer-file-coding-system
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1386 (maybe-change-coding-system-with-eol default-coding eol-type))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1387 ;; (setq default-sendmail-coding-system default-coding)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1388
1318
b531bf8658e9 [xemacs-hg @ 2003-02-21 06:56:46 by ben]
ben
parents: 1285
diff changeset
1389 ;; set the native coding system and the default process-output system.
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1390 (let ((native (get-native-coding-system-from-language-environment
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1391 language-name (current-locale))))
1318
b531bf8658e9 [xemacs-hg @ 2003-02-21 06:56:46 by ben]
ben
parents: 1285
diff changeset
1392
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1393 (condition-case nil
1318
b531bf8658e9 [xemacs-hg @ 2003-02-21 06:56:46 by ben]
ben
parents: 1285
diff changeset
1394 (define-coding-system-alias 'native
b531bf8658e9 [xemacs-hg @ 2003-02-21 06:56:46 by ben]
ben
parents: 1285
diff changeset
1395 (maybe-change-coding-system-with-eol native eol-type))
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1396 (error
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1397 (warn "Invalid native-coding-system %s in language environment %s"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1398 native language-name)))
4576
774e5c7522bf Preserve the relation btw. file-name-coding-system & the 'file-name c-s alias.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4490
diff changeset
1399 ;; These variables have magic handlers to make setting them equivalent
774e5c7522bf Preserve the relation btw. file-name-coding-system & the 'file-name c-s alias.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4490
diff changeset
1400 ;; to setting the file-name, terminal and keyboard coding system
774e5c7522bf Preserve the relation btw. file-name-coding-system & the 'file-name c-s alias.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4490
diff changeset
1401 ;; aliases. See coding.el.
774e5c7522bf Preserve the relation btw. file-name-coding-system & the 'file-name c-s alias.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4490
diff changeset
1402 (setq file-name-coding-system
774e5c7522bf Preserve the relation btw. file-name-coding-system & the 'file-name c-s alias.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4490
diff changeset
1403 (or
774e5c7522bf Preserve the relation btw. file-name-coding-system & the 'file-name c-s alias.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4490
diff changeset
1404 (let ((fncs (assq system-type system-type-file-name-coding)))
774e5c7522bf Preserve the relation btw. file-name-coding-system & the 'file-name c-s alias.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4490
diff changeset
1405 (and fncs (cdr fncs)))
774e5c7522bf Preserve the relation btw. file-name-coding-system & the 'file-name c-s alias.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4490
diff changeset
1406 native)
774e5c7522bf Preserve the relation btw. file-name-coding-system & the 'file-name c-s alias.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4490
diff changeset
1407 ;; Set the default keyboard and terminal coding systems to the
774e5c7522bf Preserve the relation btw. file-name-coding-system & the 'file-name c-s alias.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4490
diff changeset
1408 ;; native coding system of the language environment.
774e5c7522bf Preserve the relation btw. file-name-coding-system & the 'file-name c-s alias.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4490
diff changeset
1409 keyboard-coding-system native
3142
77f5a5135b3a [xemacs-hg @ 2005-12-17 19:46:57 by aidan]
aidan
parents: 2970
diff changeset
1410 terminal-coding-system native)
77f5a5135b3a [xemacs-hg @ 2005-12-17 19:46:57 by aidan]
aidan
parents: 2970
diff changeset
1411
77f5a5135b3a [xemacs-hg @ 2005-12-17 19:46:57 by aidan]
aidan
parents: 2970
diff changeset
1412 ;; And do the same for any TTYs.
77f5a5135b3a [xemacs-hg @ 2005-12-17 19:46:57 by aidan]
aidan
parents: 2970
diff changeset
1413 (dolist (con (console-list))
77f5a5135b3a [xemacs-hg @ 2005-12-17 19:46:57 by aidan]
aidan
parents: 2970
diff changeset
1414 (when (eq 'tty (device-type (car (console-device-list con))))
77f5a5135b3a [xemacs-hg @ 2005-12-17 19:46:57 by aidan]
aidan
parents: 2970
diff changeset
1415 ;; Calling set-input-mode at the same time would be a sane thing
77f5a5135b3a [xemacs-hg @ 2005-12-17 19:46:57 by aidan]
aidan
parents: 2970
diff changeset
1416 ;; to do here. I would prefer to default to accepting eight bit
77f5a5135b3a [xemacs-hg @ 2005-12-17 19:46:57 by aidan]
aidan
parents: 2970
diff changeset
1417 ;; input and not using the top bit for Meta.
77f5a5135b3a [xemacs-hg @ 2005-12-17 19:46:57 by aidan]
aidan
parents: 2970
diff changeset
1418 (set-console-tty-coding-system con native)))
77f5a5135b3a [xemacs-hg @ 2005-12-17 19:46:57 by aidan]
aidan
parents: 2970
diff changeset
1419
1318
b531bf8658e9 [xemacs-hg @ 2003-02-21 06:56:46 by ben]
ben
parents: 1285
diff changeset
1420 ;; process output should not have EOL conversion. under MS Windows
b531bf8658e9 [xemacs-hg @ 2003-02-21 06:56:46 by ben]
ben
parents: 1285
diff changeset
1421 ;; and Cygwin, this screws things up (`cmd' is fine with just LF and
b531bf8658e9 [xemacs-hg @ 2003-02-21 06:56:46 by ben]
ben
parents: 1285
diff changeset
1422 ;; `bash' chokes on CR-LF).
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1423 (setq default-process-coding-system
1318
b531bf8658e9 [xemacs-hg @ 2003-02-21 06:56:46 by ben]
ben
parents: 1285
diff changeset
1424 (cons (car default-process-coding-system) native)))))
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1425
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1426 (defun init-locale-at-early-startup ()
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1427 "Don't call this."
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1428 ;; Called directly from the C code in intl.c, very early in the startup
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1429 ;; sequence. Don't call this!!! The main purpose is to set things up
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1430 ;; so that non-ASCII strings of all sorts (e.g. file names, command-line
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1431 ;; arguments, environment variables) can be correctly processed during
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1432 ;; the rest of the startup sequence. As a result, this will almost
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1433 ;; certainly be the FIRST Lisp code called when a dumped XEmacs is run,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1434 ;; and it's called before ANY of the external environment is initialized.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1435 ;; Thus, it cannot interact at all with the outside world, make any
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1436 ;; system calls, etc! (Except for `set-current-locale'.)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1437 ;;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1438 ;; NOTE: The following are the basic settings we have to deal with when
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1439 ;; changing the language environment;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1440 ;;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1441 ;; -- current C library locale
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1442 ;; -- under MS Windows, current MS Windows locale
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1443 ;; -- LANG environment variable
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1444 ;; -- native/file-name coding systems
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1445 ;; -- subprocess write coding system (cdr of default-process-coding-system)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1446 ;; -- coding categories (for detection)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1447
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1448 (let (langenv)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1449 ;; under ms windows (any):
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1450 (if (memq system-type '(windows-nt cygwin32))
778
2923009caf47 [xemacs-hg @ 2002-03-16 10:38:59 by ben]
ben
parents: 771
diff changeset
1451 (let ((userdef (declare-fboundp (mswindows-user-default-locale)))
2923009caf47 [xemacs-hg @ 2002-03-16 10:38:59 by ben]
ben
parents: 771
diff changeset
1452 (sysdef (declare-fboundp (mswindows-system-default-locale))))
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1453 ;; (1) current langenv comes from user-default locale.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1454 (setq langenv (mswindows-get-language-environment-from-locale
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1455 userdef))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1456 ;; (2) init the langenv-to-locale table.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1457 (puthash (mswindows-get-language-environment-from-locale sysdef)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1458 sysdef mswindows-langenv-to-locale-table)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1459 ;; user-default second in langenv-to-locale table so it will
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1460 ;; override the system-default if the two are different but both
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1461 ;; map to the same language environment
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1462 (puthash langenv userdef mswindows-langenv-to-locale-table)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1463 ;; (3) setup C lib locale, MS Windows locale, LANG environment
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1464 ;; variable. Note that under Cygwin we are ignoring the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1465 ;; passed-in LANG environment variable for the moment -- it's
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1466 ;; usually wrong anyway and just says "C". #### Perhaps we
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1467 ;; should reconsider.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1468 (and langenv (set-locale-for-language-environment langenv))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1469 ;; (4) override current MS Windows locale with the user-default
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1470 ;; locale. Always init the MS Windows locale from the
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1471 ;; user-default locale even if the langenv doesn't correspond;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1472 ;; we might not be able to find a langenv for the user-default
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1473 ;; locale but we should still use the right code page, etc.
778
2923009caf47 [xemacs-hg @ 2002-03-16 10:38:59 by ben]
ben
parents: 771
diff changeset
1474 (declare-fboundp (mswindows-set-current-locale userdef)))
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1475 ;; Unix:
3173
a2331a8fccb5 [xemacs-hg @ 2005-12-24 21:59:18 by aidan]
aidan
parents: 3142
diff changeset
1476 (let (locstring)
a2331a8fccb5 [xemacs-hg @ 2005-12-24 21:59:18 by aidan]
aidan
parents: 3142
diff changeset
1477 ;; Init the POSIX locale from the environment--this calls the C
a2331a8fccb5 [xemacs-hg @ 2005-12-24 21:59:18 by aidan]
aidan
parents: 3142
diff changeset
1478 ;; library's setlocale(3).
a2331a8fccb5 [xemacs-hg @ 2005-12-24 21:59:18 by aidan]
aidan
parents: 3142
diff changeset
1479 (set-current-locale "")
a2331a8fccb5 [xemacs-hg @ 2005-12-24 21:59:18 by aidan]
aidan
parents: 3142
diff changeset
1480 ;; Can't let locstring be the result of (set-current-locale "")
a2331a8fccb5 [xemacs-hg @ 2005-12-24 21:59:18 by aidan]
aidan
parents: 3142
diff changeset
1481 ;; because that can return a more detailed string than we know how
a2331a8fccb5 [xemacs-hg @ 2005-12-24 21:59:18 by aidan]
aidan
parents: 3142
diff changeset
1482 ;; to handle.
a2331a8fccb5 [xemacs-hg @ 2005-12-24 21:59:18 by aidan]
aidan
parents: 3142
diff changeset
1483 (setq locstring (current-locale)
a2331a8fccb5 [xemacs-hg @ 2005-12-24 21:59:18 by aidan]
aidan
parents: 3142
diff changeset
1484 ;; assume C lib locale and LANG env var are set correctly.
a2331a8fccb5 [xemacs-hg @ 2005-12-24 21:59:18 by aidan]
aidan
parents: 3142
diff changeset
1485 ;; use them to find the langenv.
a2331a8fccb5 [xemacs-hg @ 2005-12-24 21:59:18 by aidan]
aidan
parents: 3142
diff changeset
1486 langenv
a2331a8fccb5 [xemacs-hg @ 2005-12-24 21:59:18 by aidan]
aidan
parents: 3142
diff changeset
1487 (and locstring (get-language-environment-from-locale
a2331a8fccb5 [xemacs-hg @ 2005-12-24 21:59:18 by aidan]
aidan
parents: 3142
diff changeset
1488 locstring)))))
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1489 ;; All systems:
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1490 (unless langenv (setq langenv "English"))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1491 (setq current-language-environment langenv)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1492 ;; Setup various coding systems and categories.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1493 (let ((default-eol-type (coding-system-eol-type
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1494 default-buffer-file-coding-system)))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1495 (reset-language-environment)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1496 (set-language-environment-coding-systems langenv default-eol-type))))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1497
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1498 (defun init-mule-at-startup ()
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1499 "Initialize MULE environment at startup. Don't call this."
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1500
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1318
diff changeset
1501 (when (not load-unicode-tables-at-dump-time)
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1318
diff changeset
1502 (load-unicode-tables))
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1503
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1318
diff changeset
1504 ;; This is called (currently; might be moved earlier) from startup.el,
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1318
diff changeset
1505 ;; after the basic GUI systems have been initialized, and just before the
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1318
diff changeset
1506 ;; init file gets read in. It needs to finish up initializing the
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1318
diff changeset
1507 ;; current language environment. Very early in the startup procedure we
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1318
diff changeset
1508 ;; determined the default language environment from the locale, and
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1318
diff changeset
1509 ;; bootstrapped the native, file-name and process I/O coding systems.
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1318
diff changeset
1510 ;; Now we need to do it over `the right away'.
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1511 (finish-set-language-environment current-language-environment)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1512
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1513 ;; Load a (localizable) locale-specific init file, if it exists.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1514 ;; We now use the language environment name, NOT the locale,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1515 ;; whose name varies from system to system.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1516 (load (format "%s%s/locale-start"
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1517 (locate-data-directory "start-files")
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1518 current-language-environment)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1519 t t)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1520
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1521 ;; #### the rest is junk that should be deleted.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1522
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1523 (when current-language-environment
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1524 ;; rman seems to be incompatible with encoded text
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1525 (setq Manual-use-rosetta-man nil))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1526
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1527 ;; Register available input methods by loading LEIM list file.
4615
ba06a6cae484 Actually use leim-list-file-name, #'init-mule-at-startup.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4604
diff changeset
1528 (load leim-list-file-name 'noerror 'nomessage 'nosuffix))
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1529
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
1530 ;; Code deleted: init-mule-tm (Enable the tm package by default)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1531
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1532 ;;; mule-cmds.el ends here