Mercurial > hg > xemacs-beta
annotate lisp/code-init.el @ 5057:742b7a124d6c
Automated merge with file:///home/aidan/xemacs-21.5-checked-out
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Mon, 22 Feb 2010 20:09:23 +0000 |
parents | d2ec55325515 |
children | 308d34e9f07d |
rev | line source |
---|---|
771 | 1 ;;; code-init.el --- Handle coding system default values |
2 | |
4989
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
3 ;; Copyright (C) 2001, 2002, 2003, 2010 Ben Wing. |
771 | 4 |
5 ;; This file is part of XEmacs. | |
6 | |
7 ;; XEmacs is free software; you can redistribute it and/or modify it | |
8 ;; under the terms of the GNU General Public License as published by | |
9 ;; the Free Software Foundation; either version 2, or (at your option) | |
10 ;; any later version. | |
11 | |
12 ;; XEmacs is distributed in the hope that it will be useful, but | |
13 ;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 ;; General Public License for more details. | |
16 | |
17 ;; You should have received a copy of the GNU General Public License | |
18 ;; along with XEmacs; see the file COPYING. If not, write to the | |
19 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
20 ;; Boston, MA 02111-1307, USA. | |
21 | |
22 ;;; Commentary: | |
23 | |
4989
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
24 ;; Author: Ben wing, 2001? |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
25 |
771 | 26 ;; Placed in a separate file so it can be loaded after the various |
27 ;; coding systems have been created, because we'll be using them at | |
28 ;; load time. | |
29 | |
2297 | 30 ;; #### Issues (this discussion probably belongs elsewhere) |
31 ;; 1. "Big" characters are unrepresentable. Should give error, warning, | |
32 ;; not just substitute "~". | |
33 ;; 2. 21.4 compatibility? | |
34 ;; 3. make-char: non-mule barfs on non-iso8859-1. | |
35 | |
771 | 36 ;;; Code: |
37 | |
38 (defcustom eol-detection-enabled-p (or (featurep 'mule) | |
39 (memq system-type '(windows-nt | |
40 cygwin32)) | |
41 (featurep 'unix-default-eol-detection)) | |
42 "True if XEmacs automatically detects the EOL type when reading files. | |
43 Normally, this is always the case on Windows or when international (Mule) | |
44 support is compiled into this XEmacs. Otherwise, it is currently off by | |
45 default, but this may change. Don't set this; nothing will happen. Instead, | |
46 use the Options menu or `set-eol-detection'." | |
47 :group 'encoding | |
48 :type 'boolean | |
49 ;; upon initialization, we don't want the whole business of | |
50 ;; set-eol-detection to be called. We will init everything appropriately | |
51 ;; later in the same file, when reset-language-environment is called. | |
52 :initialize #'(lambda (var val) | |
1698 | 53 (setq eol-detection-enabled-p (eval val))) |
771 | 54 :set #'(lambda (var val) |
55 (set-eol-detection val) | |
56 (setq eol-detection-enabled-p val))) | |
57 | |
58 (defun set-eol-detection (flag) | |
59 "Enable (if FLAG is non-nil) or disable automatic EOL detection of files. | |
60 EOL detection is enabled by default on Windows or when international (Mule) | |
61 support is compiled into this XEmacs. Otherwise, it is currently off by | |
62 default, but this may change. NOTE: You *REALLY* should not turn off EOL | |
63 detection on Windows! Your files will have lots of annoying ^M's in them | |
64 if you do this." | |
4989
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
65 (dolist (x '(bfcs-for-read |
771 | 66 keyboard |
4989
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
67 process-read |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
68 no-conv-cs)) |
771 | 69 (set-coding-system-variable |
70 x (coding-system-change-eol-conversion (get-coding-system-variable x) | |
2508 | 71 (if flag nil 'lf))))) |
771 | 72 |
73 (defun coding-system-current-system-configuration () | |
4989
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
74 "Function to decide which default coding system configuration applies." |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
75 (cond ((featurep 'cygwin-use-utf-8) 'cygwin-utf-8) |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
76 ((memq system-type '(windows-nt cygwin32)) |
771 | 77 (if (featurep 'mule) 'windows-mule 'windows-no-mule)) |
4989
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
78 ((featurep 'mule) 'mule) |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
79 (eol-detection-enabled-p 'no-mule-eol-detection) |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
80 (t 'no-mule-no-eol-detection))) |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
81 |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
82 (defvar coding-system-default-configuration-table (make-hash-table)) |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
83 |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
84 (defun define-coding-system-default-configuration (name doc props) |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
85 (puthash name (nconc `(doc ,doc) props) |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
86 coding-system-default-configuration-table)) |
771 | 87 |
1318 | 88 ;; NOTE NOTE NOTE: These values may get overridden when the language |
89 ;; environment is initialized (set-language-environment-coding-systems). | |
4989
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
90 (define-coding-system-default-configuration |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
91 'no-mule-no-eol-detection |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
92 "No Mule support, EOL detection not enabled." |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
93 '(bfcs-for-read binary |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
94 default-bfcs binary |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
95 process-read binary |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
96 process-write binary |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
97 keyboard binary |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
98 native binary |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
99 no-conv-cs binary |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
100 terminal binary)) |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
101 |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
102 (define-coding-system-default-configuration |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
103 'no-mule-eol-detection |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
104 "No Mule support, EOL detection enabled." |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
105 '(bfcs-for-read raw-text |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
106 default-bfcs binary |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
107 process-read raw-text |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
108 process-write binary |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
109 keyboard raw-text |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
110 native binary |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
111 no-conv-cs raw-text |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
112 terminal binary)) |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
113 |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
114 (define-coding-system-default-configuration |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
115 'mule |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
116 "Mule support enabled." |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
117 '(bfcs-for-read undecided |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
118 default-bfcs iso-2022-8 |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
119 process-read undecided |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
120 process-write binary |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
121 keyboard undecided-unix |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
122 native binary |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
123 no-conv-cs raw-text |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
124 terminal binary)) |
771 | 125 |
4989
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
126 (define-coding-system-default-configuration |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
127 'windows-no-mule |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
128 "Microsoft Windows, no Mule support." |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
129 '(bfcs-for-read raw-text |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
130 default-bfcs raw-text-dos |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
131 process-read raw-text |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
132 process-write raw-text |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
133 keyboard raw-text |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
134 native raw-text-dos |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
135 no-conv-cs raw-text |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
136 terminal binary)) |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
137 |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
138 (define-coding-system-default-configuration |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
139 'windows-mule |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
140 "Microsoft Windows, Mule support enabled." |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
141 '(bfcs-for-read undecided |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
142 default-bfcs mswindows-multibyte-dos |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
143 process-read undecided |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
144 process-write mswindows-multibyte-system-default |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
145 keyboard undecided-unix |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
146 native mswindows-multibyte-system-default-dos |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
147 no-conv-cs mswindows-multibyte |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
148 terminal mswindows-multibyte-unix)) |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
149 |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
150 (define-coding-system-default-configuration |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
151 'cygwin-utf-8 |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
152 "Mule support enabled." |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
153 '(bfcs-for-read undecided |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
154 default-bfcs utf-8 |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
155 process-read utf-8 |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
156 process-write utf-8 |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
157 keyboard utf-8 |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
158 native utf-8 |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
159 no-conv-cs utf-8 |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
160 terminal utf-8)) |
771 | 161 |
162 (defvar coding-system-default-variable-list | |
4989
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
163 '(bfcs-for-read |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
164 default-bfcs |
771 | 165 native |
166 keyboard | |
167 terminal | |
4989
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
168 process-read |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
169 process-write |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
170 no-conv-cs)) |
771 | 171 |
172 (defun get-coding-system-variable (var) | |
173 "Return the value of a basic coding system variable. | |
174 This is intended as a uniform interface onto the coding system settings that | |
175 control how encoding detection and conversion works. See | |
176 `coding-system-variable-default-value' for a list of the possible values of | |
177 VAR." | |
178 (case var | |
4989
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
179 (bfcs-for-read buffer-file-coding-system-for-read) |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
180 (default-bfcs |
771 | 181 (default-value 'buffer-file-coding-system)) |
182 (native (coding-system-aliasee 'native)) | |
183 (keyboard (coding-system-aliasee 'keyboard)) | |
184 (terminal (coding-system-aliasee 'terminal)) | |
4989
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
185 (process-read (car default-process-coding-system)) |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
186 (process-write (cdr default-process-coding-system)) |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
187 (no-conv-cs |
2508 | 188 (coding-category-system 'no-conversion)) |
771 | 189 (t (error 'invalid-constant "Invalid coding system variable" var)))) |
190 | |
191 (defun set-coding-system-variable (var value) | |
192 "Set a basic coding system variable to VALUE. | |
193 This is intended as a uniform interface onto the coding system settings that | |
194 control how encoding detection and conversion works. See | |
195 `coding-system-variable-default-value' for a list of the possible values of | |
196 VAR." | |
197 (case var | |
4989
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
198 (bfcs-for-read |
771 | 199 (set-buffer-file-coding-system-for-read value)) |
4989
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
200 (default-bfcs |
771 | 201 (set-default-buffer-file-coding-system value)) |
202 (native (define-coding-system-alias 'native value)) | |
203 (keyboard (set-keyboard-coding-system value)) | |
204 (terminal (set-terminal-coding-system value)) | |
4989
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
205 (process-read |
771 | 206 (setq default-process-coding-system |
207 (cons value (cdr default-process-coding-system)))) | |
4989
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
208 (process-write |
771 | 209 (setq default-process-coding-system |
210 (cons (car default-process-coding-system) value))) | |
4989
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
211 (no-conv-cs |
2508 | 212 (set-coding-category-system 'no-conversion value)) |
771 | 213 (t (error 'invalid-constant "Invalid coding system variable" var)))) |
214 | |
215 (defun coding-system-variable-default-value (var &optional config) | |
216 "Return the appropriate default value for a coding system variable. | |
217 | |
218 VAR specifies the variable, and CONFIG the configuration, defaulting | |
219 to the current system configuration (as returned by | |
220 `coding-system-current-system-configuration'). | |
221 | |
222 The table of default values looks like this: (see below for abbreviations) | |
223 | |
224 | |
4989
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
225 NoMule NoMuleEOL Mule MSW MSWMule CygUTF |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
226 ------------------------------------------------------------------------------ |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
227 bfcs-for-read binary raw-text undecided raw-text undecided undecided |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
228 default-bfcs binary binary iso-2022-8 raw-text-dos MSW-MB-dos utf-8 |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
229 native binary binary binary raw-text-dos MSW-MB-SD-dos utf-8 |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
230 keyboard binary raw-text undecided- raw-text undecided- utf-8 |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
231 unix unix |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
232 terminal binary binary binary binary MSW-MB-unix utf-8 |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
233 process-read binary raw-text undecided raw-text undecided utf-8 |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
234 process-write binary binary binary raw-text MSW-MB-SD utf-8 |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
235 no-conv-cs binary raw-text raw-text raw-text MSW-MB utf-8 |
771 | 236 |
237 | |
4989
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
238 VAR can be one of: |
771 | 239 |
4989
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
240 `bfcs-for-read' |
771 | 241 |
242 Lisp variable of the same name; the default coding system used when | |
243 reading in a file, in the absence of more specific settings. (See | |
244 `insert-file-contents' for a description of exactly how a file's | |
245 coding system is determined when it's read in.) | |
246 | |
4989
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
247 `default-bfcs' |
771 | 248 |
249 Default value of `buffer-file-coding-system', the buffer-local | |
250 variable specifying a file's coding system to be used when it is | |
251 written out. Set using `set-default-buffer-file-coding-system' (or | |
252 the primitive `setq-default'). When a file is read in, | |
253 `buffer-file-coding-system' for that file is set from the coding | |
254 system used to read the file in; the default value applies to newly | |
255 created files. | |
256 | |
4989
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
257 `native' |
771 | 258 |
259 The coding system named `native'. Changed using | |
260 `define-coding-system-alias'. Used internally when passing | |
1318 | 261 text to or from system API's, unless the particular |
771 | 262 API specifies another coding system. |
263 | |
4989
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
264 `keyboard' |
771 | 265 |
266 #### fill in | |
267 | |
4989
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
268 `terminal' |
771 | 269 |
270 #### fill in | |
271 | |
4989
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
272 `process-read' |
771 | 273 |
274 #### fill in | |
275 | |
4989
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
276 `process-write' |
771 | 277 |
278 #### fill in | |
279 | |
4989
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
280 `no-conv-cs' |
771 | 281 |
282 Coding system used when category `no-conversion' is detected. | |
283 | |
284 | |
285 CONFIG is one of: (abbreviations in parens) | |
286 | |
4989
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
287 `no-mule-no-eol-detection' (NoMule) |
771 | 288 |
4989
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
289 Non-Windows, no Mule support, no automatic EOL detection. (Controlled by |
771 | 290 `eol-detection-enabled-p', which is set by the command-line flag |
291 -enable-eol-detection or the configure flag --with-default-eol-detection.) | |
292 | |
4989
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
293 `unix-no-mule-eol-detection' (NoMuleEOL) |
771 | 294 |
4989
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
295 Non-Windows, no Mule support, automatic EOL detection. |
771 | 296 |
4989
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
297 `unix-mule' (Mule) |
771 | 298 |
4989
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
299 Non-Windows, Mule support. |
771 | 300 |
301 `windows-no-mule' (MSW) | |
302 | |
4989
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
303 MS Windows or old Cygwin, no Mule support. |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
304 |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
305 `windows-mule' (MSWMule) |
771 | 306 |
4989
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
307 MS Windows or old Cygwin, Mule support. |
771 | 308 |
4989
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
309 `cygwin-utf-8' (CygUTF) |
771 | 310 |
4989
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
311 Cygwin 1.7 or later, which uses UTF-8 consistently. |
771 | 312 |
313 The following coding system abbreviations are also used in the table: | |
314 | |
315 MSW-MB = mswindows-multibyte | |
316 MSW-MB = mswindows-multibyte-system-default | |
317 " | |
318 (setq config (or config (coding-system-current-system-configuration))) | |
4989
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
319 (or (memq var coding-system-default-variable-list) |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
320 (error 'invalid-constant "Invalid coding system variable" var)) |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
321 (let ((props (gethash config coding-system-default-configuration-table))) |
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
322 (or props (error 'invalid-constant "Invalid coding system configuration" |
771 | 323 config)) |
4989
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
324 (getf props var))) |
771 | 325 |
326 (defun reset-coding-system-defaults (&optional config) | |
327 "Reset all basic coding system variables are set to their default values. | |
328 See `coding-system-variable-default-value'." | |
329 (setq config (or config (coding-system-current-system-configuration))) | |
330 (mapcar #'(lambda (var) | |
331 (set-coding-system-variable | |
332 var (coding-system-variable-default-value var config))) | |
333 coding-system-default-variable-list)) | |
334 | |
335 (defun reset-coding-categories-to-default () | |
336 "Reset all coding categories (used for automatic detection) to their defaults. | |
337 | |
338 The order of priorities of coding categories and the coding system | |
339 bound to each category are as follows: | |
340 | |
341 coding category coding system | |
342 -------------------------------------------------- | |
343 utf-16-little-endian-bom utf-16-little-endian | |
344 utf-16-bom utf-16-bom | |
985 | 345 utf-8-bom utf-8-bom |
771 | 346 iso-7 iso-2022-7bit |
347 no-conversion raw-text | |
348 utf-8 utf-8 | |
349 iso-8-1 iso-8859-1 | |
350 iso-8-2 ctext (iso-8859-1 alias) | |
351 iso-8-designate ctext (iso-8859-1 alias) | |
352 iso-lock-shift iso-2022-lock | |
353 shift-jis shift-jis | |
354 big5 big5 | |
355 utf-16-little-endian utf-16-little-endian | |
356 utf-16 utf-16 | |
357 ucs-4 ucs-4 | |
358 " | |
359 ;; #### What a mess! This needs to be overhauled. | |
360 | |
361 ;; The old table (from FSF synch?) was not what we use (cf mule-coding.el), | |
362 ;; and as documented iso-8-designate is inconsistent with iso-2022-8bit-ss2. | |
363 ;; The order of priorities of coding categories and the coding system | |
364 ;; bound to each category are as follows: | |
365 ;; | |
366 ;; coding category coding system | |
367 ;; -------------------------------------------------- | |
368 ;; iso-8-2 iso-8859-1 | |
369 ;; iso-8-1 iso-8859-1 | |
370 ;; iso-7 iso-2022-7bit | |
371 ;; iso-lock-shift iso-2022-lock | |
372 ;; iso-8-designate iso-2022-8bit-ss2 | |
373 ;; no-conversion raw-text | |
374 ;; shift-jis shift_jis | |
375 ;; big5 big5 | |
376 ;; ucs-4 ---- | |
377 ;; utf-8 ---- | |
378 (when (featurep 'mule) | |
379 (set-coding-category-system 'iso-7 'iso-2022-7) | |
380 (set-coding-category-system 'iso-8-1 'iso-8859-1) | |
381 (set-coding-category-system 'iso-8-2 'ctext) | |
382 (set-coding-category-system 'iso-lock-shift 'iso-2022-lock) | |
383 (set-coding-category-system 'iso-8-designate 'ctext) | |
384 (if (find-coding-system 'shift-jis) | |
385 (set-coding-category-system 'shift-jis 'shift-jis)) | |
386 (if (find-coding-system 'big5) | |
387 (set-coding-category-system 'big5 'big5)) | |
388 ) | |
389 (set-coding-category-system | |
390 'no-conversion | |
4989
d2ec55325515
make utf-8 default for Cygwin 1.7, rewrite init code determining default coding systems
Ben Wing <ben@xemacs.org>
parents:
4568
diff
changeset
|
391 (coding-system-variable-default-value 'no-conv-cs)) |
771 | 392 (set-coding-category-system 'ucs-4 'ucs-4) |
393 (set-coding-category-system 'utf-8 'utf-8) | |
985 | 394 (set-coding-category-system 'utf-8-bom 'utf-8-bom) |
771 | 395 (set-coding-category-system 'utf-16-little-endian 'utf-16-little-endian) |
396 (set-coding-category-system 'utf-16 'utf-16) | |
397 (set-coding-category-system 'utf-16-little-endian-bom | |
398 'utf-16-little-endian-bom) | |
399 (set-coding-category-system 'utf-16-bom 'utf-16-bom) | |
400 (set-coding-priority-list | |
401 (if (featurep 'mule) | |
402 '(utf-16-little-endian-bom | |
403 utf-16-bom | |
985 | 404 utf-8-bom |
771 | 405 iso-7 |
406 no-conversion | |
407 utf-8 | |
408 iso-8-1 | |
409 iso-8-2 | |
410 iso-8-designate | |
411 iso-lock-shift | |
412 shift-jis | |
413 big5 | |
414 utf-16-little-endian | |
415 utf-16 | |
416 ucs-4) | |
417 '(utf-16-little-endian-bom | |
418 utf-16-bom | |
985 | 419 utf-8-bom |
771 | 420 no-conversion |
421 utf-8 | |
422 utf-16-little-endian | |
423 utf-16 | |
424 ucs-4)))) | |
425 | |
426 (defun reset-language-environment () | |
427 "Reset coding system environment of XEmacs to the default status. | |
428 All basic coding system variables are set to their default values, as | |
429 are the coding categories used for automatic detection and their | |
430 priority. | |
431 | |
432 BE VERY CERTAIN YOU WANT TO DO THIS BEFORE DOING IT! | |
433 | |
434 For more information, see `reset-coding-system-defaults' and | |
435 `reset-coding-categories-to-default'." | |
436 (reset-coding-system-defaults) | |
437 (reset-coding-categories-to-default)) | |
438 | |
439 ;; Initialize everything so that the remaining Lisp files can contain | |
440 ;; extended characters. (They will be in ISO-7 format) | |
441 | |
442 ;; !!####!! The Lisp files should all be in UTF-8!!! That way, all | |
443 ;; special characters appear as high bits and there's no problem with | |
444 ;; the Lisp parser trying to read a Mule file and getting all screwed | |
445 ;; up. The only other thing then would be characters; we just need to | |
446 ;; modify the Lisp parser to read the stuff directly after a ? as | |
447 ;; UTF-8 and return a 30-bit value directly, and modify the character | |
448 ;; routines a bit to allow such a beast to exist. MAKE IT A POINT TO | |
449 ;; IMPLEMENT THIS AS ONE OF MY FUTURE PROJECTS. --ben | |
450 | |
451 (reset-language-environment) | |
452 | |
4568
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
2508
diff
changeset
|
453 (coding-system-put 'raw-text 'safe-charsets '(ascii control-1 latin-iso8859-1)) |
1d74a1d115ee
Add #'query-coding-region tests; do the work necessary to get them running.
Aidan Kehoe <kehoea@parhasard.net>
parents:
2508
diff
changeset
|
454 |
771 | 455 ;;; code-init.el ends here |