Mercurial > hg > xemacs-beta
comparison lisp/code-cmds.el @ 771:943eaba38521
[xemacs-hg @ 2002-03-13 08:51:24 by ben]
The big ben-mule-21-5 check-in!
Various files were added and deleted. See CHANGES-ben-mule.
There are still some test suite failures. No crashes, though.
Many of the failures have to do with problems in the test suite itself
rather than in the actual code. I'll be addressing these in the next
day or so -- none of the test suite failures are at all critical.
Meanwhile I'll be trying to address the biggest issues -- i.e. build
or run failures, which will almost certainly happen on various platforms.
All comments should be sent to ben@xemacs.org -- use a Cc: if necessary
when sending to mailing lists. There will be pre- and post- tags,
something like
pre-ben-mule-21-5-merge-in, and
post-ben-mule-21-5-merge-in.
author | ben |
---|---|
date | Wed, 13 Mar 2002 08:54:06 +0000 |
parents | 576fb035e263 |
children | b531bf8658e9 |
comparison
equal
deleted
inserted
replaced
770:336a418893b5 | 771:943eaba38521 |
---|---|
1 ;;; code-cmds.el --- Commands for manipulating coding systems.. | 1 ;;; code-cmds.el --- Commands for manipulating coding systems. |
2 | 2 |
3 ;; Copyright (C) 1995,1999 Electrotechnical Laboratory, JAPAN. | 3 ;; Copyright (C) 1995,1999 Electrotechnical Laboratory, JAPAN. |
4 ;; Licensed to the Free Software Foundation. | 4 ;; Licensed to the Free Software Foundation. |
5 ;; Copyright (C) 2000 Free Software Foundation | 5 ;; Copyright (C) 2000 Free Software Foundation |
6 ;; Copyright (C) 1997 MORIOKA Tomohiko | 6 ;; Copyright (C) 1997 MORIOKA Tomohiko |
7 ;; Copyright (C) 2001, 2002 Ben Wing. | |
7 | 8 |
8 | 9 |
9 ;; This file is part of XEmacs. | 10 ;; This file is part of XEmacs. |
10 | 11 |
11 ;; XEmacs is free software; you can redistribute it and/or modify it | 12 ;; XEmacs is free software; you can redistribute it and/or modify it |
32 | 33 |
33 ;;; Code: | 34 ;;; Code: |
34 | 35 |
35 ;;; Coding related key bindings and menus. | 36 ;;; Coding related key bindings and menus. |
36 | 37 |
37 (defvar coding-keymap (make-sparse-keymap "Mule/Conding") | 38 (defvar coding-keymap (make-sparse-keymap "Coding+Mule") |
38 "Keymap for Mule and Coding cystem specific commands.") | 39 "Keymap for coding-system-specific and (when available) Mule commands.") |
39 | 40 |
40 ;; Keep "C-x C-m ..." for mule specific commands. | 41 ;; Keep "C-x C-m ..." for coding/mule specific commands. |
41 (define-key ctl-x-map "\C-m" coding-keymap) | 42 (define-key ctl-x-map "\C-m" coding-keymap) |
42 | 43 |
43 (define-key coding-keymap "f" 'set-buffer-file-coding-system) | 44 (define-key coding-keymap "f" 'set-buffer-file-coding-system) |
44 (define-key coding-keymap "F" 'set-default-buffer-file-coding-system) ; XEmacs | 45 (define-key coding-keymap "F" 'set-default-buffer-file-coding-system) ; XEmacs |
45 (define-key coding-keymap "t" 'set-terminal-coding-system) | 46 (define-key coding-keymap "t" 'set-terminal-coding-system) |
46 (define-key coding-keymap "p" 'set-buffer-process-coding-system) | 47 (define-key coding-keymap "p" 'set-buffer-process-coding-system) |
47 ;(define-key coding-keymap "x" 'set-selection-coding-system) | |
48 ;(define-key coding-keymap "X" 'set-next-selection-coding-system) | |
49 (define-key coding-keymap "c" 'universal-coding-system-argument) | 48 (define-key coding-keymap "c" 'universal-coding-system-argument) |
50 ;;(define-key coding-keymap "c" 'list-coding-system-briefly) ; XEmacs | 49 ;;(define-key coding-keymap "c" 'list-coding-system-briefly) ; XEmacs |
51 ;;(define-key coding-keymap "C" 'describe-coding-system) ; XEmacs | 50 (when-fboundp 'describe-coding-system |
51 (define-key coding-keymap "C" 'describe-coding-system)) ; XEmacs | |
52 (when-fboundp 'set-selection-coding-system | |
53 (define-key coding-keymap "x" 'set-selection-coding-system) | |
54 (define-key coding-keymap "X" 'set-next-selection-coding-system)) | |
52 | 55 |
53 | 56 |
54 (defun coding-system-change-eol-conversion (coding-system eol-type) | 57 (defun coding-system-change-eol-conversion (coding-system eol-type) |
55 "Return a coding system which differs from CODING-SYSTEM in eol conversion. | 58 "Return a coding system which differs from CODING-SYSTEM in eol conversion. |
56 The returned coding system converts end-of-line by EOL-TYPE | 59 The returned coding system converts end-of-line by EOL-TYPE |
78 coding-system | 81 coding-system |
79 (coding-system-property coding-system eol-type)) | 82 (coding-system-property coding-system eol-type)) |
80 (let ((base (coding-system-base coding-system))) | 83 (let ((base (coding-system-base coding-system))) |
81 (if (not eol-type) | 84 (if (not eol-type) |
82 base | 85 base |
83 (if (= eol-type orig-eol-type) | 86 (if (eq eol-type orig-eol-type) |
84 coding-system | 87 coding-system |
85 (setq orig-eol-type (coding-system-eol-type base)) | 88 (setq orig-eol-type (coding-system-eol-type base)) |
86 (if (null orig-eol-type) | 89 (if (null orig-eol-type) |
87 (coding-system-property base eol-type)))))))) | 90 (coding-system-property base eol-type)))))))) |
88 | 91 |
92 ;; (defun coding-system-change-text-conversion (coding-system coding) | |
93 ;; "Return a coding system which differs from CODING-SYSTEM in text conversion. | |
94 ;; The returned coding system converts text by CODING | |
95 ;; but end-of-line as the same way as CODING-SYSTEM. | |
96 ;; If CODING is nil, the returned coding system detects | |
97 ;; how text is formatted automatically while decoding." | |
98 ;; (if (not coding) | |
99 ;; (coding-system-base coding-system) | |
100 ;; (let ((eol-type (coding-system-eol-type coding-system))) | |
101 ;; (coding-system-change-eol-conversion | |
102 ;; coding | |
103 ;; (if (numberp eol-type) (aref [unix dos mac] eol-type)))))) | |
89 | 104 |
90 (defun universal-coding-system-argument () | 105 (defun universal-coding-system-argument () |
91 "Execute an I/O command using the specified coding system." | 106 "Execute an I/O command using the specified coding system." |
92 (interactive) | 107 (interactive) |
93 (let* ((default (and buffer-file-coding-system | 108 (let* ((default (and buffer-file-coding-system |
107 (let ((coding-system-for-read coding-system) | 122 (let ((coding-system-for-read coding-system) |
108 (coding-system-for-write coding-system)) | 123 (coding-system-for-write coding-system)) |
109 (message "") | 124 (message "") |
110 (call-interactively cmd)))) | 125 (call-interactively cmd)))) |
111 | 126 |
112 (defun set-default-coding-systems (coding-system) | 127 (defun set-default-output-coding-systems (coding-system) |
113 "Set default value of various coding systems to CODING-SYSTEM. | 128 "Set default value for coding system output to CODING-SYSTEM. |
114 This sets the following coding systems: | 129 This sets the coding system of newly created buffers (the default value of |
115 o coding system of a newly created buffer | 130 `buffer-file-coding-system') and the default coding system for output to a |
116 o default coding system for terminal output | 131 subprocess (the CDR of `default-process-coding-system'). |
117 o default coding system for keyboard input | 132 |
118 o default coding system for subprocess I/O | 133 Other defaults are not changed; see `prefer-coding-system' for why." |
119 o default coding system for converting file names." | |
120 (check-coding-system coding-system) | 134 (check-coding-system coding-system) |
121 ;;(setq-default buffer-file-coding-system coding-system) | |
122 (set-default-buffer-file-coding-system coding-system) | 135 (set-default-buffer-file-coding-system coding-system) |
123 ;; (if default-enable-multibyte-characters | 136 (setq default-process-coding-system |
124 ;; (setq default-file-name-coding-system coding-system)) | 137 (cons (car default-process-coding-system) coding-system))) |
125 ;; If coding-system is nil, honor that on MS-DOS as well, so | |
126 ;; that they could reset the terminal coding system. | |
127 ;; (unless (and (eq window-system 'pc) coding-system) | |
128 ;; (setq default-terminal-coding-system coding-system)) | |
129 (set-terminal-coding-system coding-system) | |
130 ;;(setq default-keyboard-coding-system coding-system) | |
131 (set-keyboard-coding-system coding-system) | |
132 ;;(setq default-process-coding-system (cons coding-system coding-system)) | |
133 ;; Refer to coding-system-for-read and coding-system-for-write | |
134 ;; so that C-x RET c works. | |
135 (add-hook 'comint-exec-hook | |
136 `(lambda () | |
137 (let ((proc (get-buffer-process (current-buffer)))) | |
138 (set-process-input-coding-system | |
139 proc (or coding-system-for-read ',coding-system)) | |
140 (set-process-output-coding-system | |
141 proc (or coding-system-for-write ',coding-system)))) | |
142 'append) | |
143 (setq file-name-coding-system coding-system)) | |
144 | 138 |
145 (defun prefer-coding-system (coding-system) | 139 (defun prefer-coding-system (coding-system) |
146 "Add CODING-SYSTEM at the front of the priority list for automatic detection. | 140 "Add CODING-SYSTEM at the front of the priority list for automatic detection. |
147 This also sets the following coding systems: | 141 This also sets the coding system of newly created buffers (the default |
148 o coding system of a newly created buffer | 142 value of `buffer-file-coding-system') and the default coding system for |
149 o default coding system for terminal output | 143 output to a subprocess (the CDR of `default-process-coding-system'). |
150 o default coding system for keyboard input | |
151 o default coding system for converting file names. | |
152 | 144 |
153 If CODING-SYSTEM specifies a certain type of EOL conversion, the coding | 145 If CODING-SYSTEM specifies a certain type of EOL conversion, the coding |
154 systems set by this function will use that type of EOL conversion. | 146 systems set by this function will use that type of EOL conversion. |
155 | 147 |
156 This command does not change the default value of terminal coding system | 148 This does not change the default coding system for converting file names |
157 for MS-DOS terminal, because DOS terminals only support a single coding | 149 because that is dependent on the current locale; it's changed when |
158 system, and Emacs automatically sets the default to that coding system at | 150 `set-language-environment' is called. It does not change |
159 startup." | 151 `terminal-coding-system' or `keyboard-coding-system'; they should get set |
152 when the terminal is opened (and are typically an inherent property of the | |
153 terminal), and don't change afterward. It does not change the default | |
154 coding system for reading files or input from a subprocess; they should | |
155 remain as `undecided' so that automatic detection is done." | |
160 (interactive "zPrefer coding system: ") | 156 (interactive "zPrefer coding system: ") |
161 (if (not (and coding-system (find-coding-system coding-system))) | 157 (if (not (and coding-system (find-coding-system coding-system))) |
162 (error "Invalid coding system `%s'" coding-system)) | 158 (error "Invalid coding system `%s'" coding-system)) |
163 (let ((coding-category (coding-system-category coding-system)) | 159 (let ((coding-category (coding-system-category coding-system)) |
164 (base (coding-system-base coding-system)) | 160 (base (coding-system-base coding-system)) |
173 (set-coding-priority-list (list coding-category))) | 169 (set-coding-priority-list (list coding-category))) |
174 (if (and base (interactive-p)) | 170 (if (and base (interactive-p)) |
175 (message "Highest priority is set to %s (base of %s)" | 171 (message "Highest priority is set to %s (base of %s)" |
176 base coding-system)) | 172 base coding-system)) |
177 ;; If they asked for specific EOL conversion, honor that. | 173 ;; If they asked for specific EOL conversion, honor that. |
178 (if (memq eol-type '(lf crlf mac)) | 174 (if (memq eol-type '(lf crlf cr unix dos mac)) |
179 (setq coding-system | 175 (setq coding-system |
180 (coding-system-change-eol-conversion base eol-type)) | 176 (coding-system-change-eol-conversion base eol-type)) |
181 (setq coding-system base)) | 177 (setq coding-system base)) |
182 (set-default-coding-systems coding-system))) | 178 (set-default-output-coding-systems coding-system))) |
183 | 179 |
184 ;;; Commands | 180 ;; (defun find-coding-systems-region-subset-p (list1 list2) |
185 | 181 ;; "Return non-nil if all elements in LIST1 are included in LIST2. |
186 (defun set-buffer-process-coding-system (decoding encoding) | 182 ;; Comparison done with EQ." |
187 "Set coding systems for the process associated with the current buffer. | 183 ;; (catch 'tag |
188 DECODING is the coding system to be used to decode input from the process, | 184 ;; (while list1 |
189 ENCODING is the coding system to be used to encode output to the process. | 185 ;; (or (memq (car list1) list2) |
190 | 186 ;; (throw 'tag nil)) |
191 For a list of possible values of CODING-SYSTEM, use \\[list-coding-systems]." | 187 ;; (setq list1 (cdr list1))) |
192 (interactive | 188 ;; t)) |
193 "zCoding-system for process input: \nzCoding-system for process output: ") | 189 |
194 (let ((proc (get-buffer-process (current-buffer)))) | 190 ;; (defun find-coding-systems-region (from to) |
195 (if (null proc) | 191 ;; "Return a list of proper coding systems to encode a text between FROM and TO. |
196 (error "no process") | 192 ;; All coding systems in the list can safely encode any multibyte characters |
197 (check-coding-system decoding) | 193 ;; in the text. |
198 (check-coding-system encoding) | 194 ;; |
199 (set-process-coding-system proc decoding encoding))) | 195 ;; If the text contains no multibyte characters, return a list of a single |
200 (force-mode-line-update)) | 196 ;; element `undecided'." |
197 ;; (find-coding-systems-for-charsets (find-charset-region from to))) | |
198 | |
199 ;; (defun find-coding-systems-string (string) | |
200 ;; "Return a list of proper coding systems to encode STRING. | |
201 ;; All coding systems in the list can safely encode any multibyte characters | |
202 ;; in STRING. | |
203 ;; | |
204 ;; If STRING contains no multibyte characters, return a list of a single | |
205 ;; element `undecided'." | |
206 ;; (find-coding-systems-for-charsets (find-charset-string string))) | |
207 | |
208 ;; (defun find-coding-systems-for-charsets (charsets) | |
209 ;; "Return a list of proper coding systems to encode characters of CHARSETS. | |
210 ;; CHARSETS is a list of character sets." | |
211 ;; (if (or (null charsets) | |
212 ;; (and (= (length charsets) 1) | |
213 ;; (eq 'ascii (car charsets)))) | |
214 ;; '(undecided) | |
215 ;; (setq charsets (delq 'composition charsets)) | |
216 ;; (let ((l (coding-system-list 'base-only)) | |
217 ;; (charset-preferred-codings | |
218 ;; (mapcar (function | |
219 ;; (lambda (x) | |
220 ;; (if (eq x 'unknown) | |
221 ;; 'raw-text | |
222 ;; (get-charset-property x 'preferred-coding-system)))) | |
223 ;; charsets)) | |
224 ;; (priorities (mapcar (function (lambda (x) (symbol-value x))) | |
225 ;; coding-category-list)) | |
226 ;; codings coding safe) | |
227 ;; (if (memq 'unknown charsets) | |
228 ;; ;; The region contains invalid multibyte characters. | |
229 ;; (setq l '(raw-text))) | |
230 ;; (while l | |
231 ;; (setq coding (car l) l (cdr l)) | |
232 ;; (if (and (setq safe (coding-system-get coding 'safe-charsets)) | |
233 ;; (or (eq safe t) | |
234 ;; (find-coding-systems-region-subset-p charsets safe))) | |
235 ;; ;; We put the higher priority to coding systems included | |
236 ;; ;; in CHARSET-PREFERRED-CODINGS, and within them, put the | |
237 ;; ;; higher priority to coding systems which support smaller | |
238 ;; ;; number of charsets. | |
239 ;; (let ((priority | |
240 ;; (+ (if (coding-system-get coding 'mime-charset) 4096 0) | |
241 ;; (lsh (length (memq coding priorities)) 7) | |
242 ;; (if (memq coding charset-preferred-codings) 64 0) | |
243 ;; (if (> (coding-system-type coding) 0) 32 0) | |
244 ;; (if (consp safe) (- 32 (length safe)) 0)))) | |
245 ;; (setq codings (cons (cons priority coding) codings))))) | |
246 ;; (mapcar 'cdr | |
247 ;; (sort codings (function (lambda (x y) (> (car x) (car y)))))) | |
248 ;; ))) | |
249 | |
250 ;; (defun find-multibyte-characters (from to &optional maxcount excludes) | |
251 ;; "Find multibyte characters in the region specified by FROM and TO. | |
252 ;; If FROM is a string, find multibyte characters in the string. | |
253 ;; The return value is an alist of the following format: | |
254 ;; ((CHARSET COUNT CHAR ...) ...) | |
255 ;; where | |
256 ;; CHARSET is a character set, | |
257 ;; COUNT is a number of characters, | |
258 ;; CHARs are found characters of the character set. | |
259 ;; Optional 3rd arg MAXCOUNT limits how many CHARs are put in the above list. | |
260 ;; Optional 4th arg EXCLUDE is a list of character sets to be ignored. | |
261 ;; | |
262 ;; For invalid characters, CHARs are actually strings." | |
263 ;; (let ((chars nil) | |
264 ;; charset char) | |
265 ;; (if (stringp from) | |
266 ;; (let ((idx 0)) | |
267 ;; (while (setq idx (string-match "[^\000-\177]" from idx)) | |
268 ;; (setq char (aref from idx) | |
269 ;; charset (char-charset char)) | |
270 ;; (if (eq charset 'unknown) | |
271 ;; (setq char (match-string 0))) | |
272 ;; (if (or (eq charset 'unknown) | |
273 ;; (not (or (eq excludes t) (memq charset excludes)))) | |
274 ;; (let ((slot (assq charset chars))) | |
275 ;; (if slot | |
276 ;; (if (not (memq char (nthcdr 2 slot))) | |
277 ;; (let ((count (nth 1 slot))) | |
278 ;; (setcar (cdr slot) (1+ count)) | |
279 ;; (if (or (not maxcount) (< count maxcount)) | |
280 ;; (nconc slot (list char))))) | |
281 ;; (setq chars (cons (list charset 1 char) chars))))) | |
282 ;; (setq idx (1+ idx)))) | |
283 ;; (save-excursion | |
284 ;; (goto-char from) | |
285 ;; (while (re-search-forward "[^\000-\177]" to t) | |
286 ;; (setq char (preceding-char) | |
287 ;; charset (char-charset char)) | |
288 ;; (if (eq charset 'unknown) | |
289 ;; (setq char (match-string 0))) | |
290 ;; (if (or (eq charset 'unknown) | |
291 ;; (not (or (eq excludes t) (memq charset excludes)))) | |
292 ;; (let ((slot (assq charset chars))) | |
293 ;; (if slot | |
294 ;; (if (not (member char (nthcdr 2 slot))) | |
295 ;; (let ((count (nth 1 slot))) | |
296 ;; (setcar (cdr slot) (1+ count)) | |
297 ;; (if (or (not maxcount) (< count maxcount)) | |
298 ;; (nconc slot (list char))))) | |
299 ;; (setq chars (cons (list charset 1 char) chars)))))))) | |
300 ;; (nreverse chars))) | |
301 | |
302 ;; (defvar last-coding-system-specified nil | |
303 ;; "Most recent coding system explicitly specified by the user when asked. | |
304 ;; This variable is set whenever Emacs asks the user which coding system | |
305 ;; to use in order to write a file. If you set it to nil explicitly, | |
306 ;; then call `write-region', then afterward this variable will be non-nil | |
307 ;; only if the user was explicitly asked and specified a coding system.") | |
308 | |
309 ;; (defun select-safe-coding-system (from to &optional default-coding-system) | |
310 ;; "Ask a user to select a safe coding system from candidates. | |
311 ;; The candidates of coding systems which can safely encode a text | |
312 ;; between FROM and TO are shown in a popup window. | |
313 ;; | |
314 ;; Optional arg DEFAULT-CODING-SYSTEM specifies a coding system to be | |
315 ;; checked at first. If omitted, buffer-file-coding-system of the | |
316 ;; current buffer is used. | |
317 ;; | |
318 ;; If the text can be encoded safely by DEFAULT-CODING-SYSTEM, it is | |
319 ;; returned without any user interaction. | |
320 ;; | |
321 ;; Kludgy feature: if FROM is a string, the string is the target text, | |
322 ;; and TO is ignored." | |
323 ;; (or default-coding-system | |
324 ;; (setq default-coding-system buffer-file-coding-system)) | |
325 ;; (let* ((charsets (if (stringp from) (find-charset-string from) | |
326 ;; (find-charset-region from to))) | |
327 ;; (safe-coding-systems (find-coding-systems-for-charsets charsets))) | |
328 ;; (if (or (not enable-multibyte-characters) | |
329 ;; (eq (car safe-coding-systems) 'undecided) | |
330 ;; (eq default-coding-system 'no-conversion) | |
331 ;; (and default-coding-system | |
332 ;; (memq (coding-system-base default-coding-system) | |
333 ;; safe-coding-systems))) | |
334 ;; default-coding-system | |
335 ;; | |
336 ;; ;; At first, change each coding system to the corresponding | |
337 ;; ;; mime-charset name if it is also a coding system. | |
338 ;; (let ((l safe-coding-systems) | |
339 ;; mime-charset) | |
340 ;; (while l | |
341 ;; (setq mime-charset (coding-system-get (car l) 'mime-charset)) | |
342 ;; (if (and mime-charset (coding-system-p mime-charset)) | |
343 ;; (setcar l mime-charset)) | |
344 ;; (setq l (cdr l)))) | |
345 ;; | |
346 ;; (let ((non-safe-chars (find-multibyte-characters | |
347 ;; from to 3 | |
348 ;; (and default-coding-system | |
349 ;; (coding-system-get default-coding-system | |
350 ;; 'safe-charsets)))) | |
351 ;; show-position overlays) | |
352 ;; (save-excursion | |
353 ;; ;; Highlight characters that default-coding-system can't encode. | |
354 ;; (when (integerp from) | |
355 ;; (goto-char from) | |
356 ;; (let ((found nil)) | |
357 ;; (while (and (not found) | |
358 ;; (re-search-forward "[^\000-\177]" to t)) | |
359 ;; (setq found (assq (char-charset (preceding-char)) | |
360 ;; non-safe-chars)))) | |
361 ;; (forward-line -1) | |
362 ;; (setq show-position (point)) | |
363 ;; (save-excursion | |
364 ;; (while (and (< (length overlays) 256) | |
365 ;; (re-search-forward "[^\000-\177]" to t)) | |
366 ;; (let* ((char (preceding-char)) | |
367 ;; (charset (char-charset char))) | |
368 ;; (when (assq charset non-safe-chars) | |
369 ;; (setq overlays (cons (make-overlay (1- (point)) (point)) | |
370 ;; overlays)) | |
371 ;; (overlay-put (car overlays) 'face 'highlight)))))) | |
372 ;; | |
373 ;; ;; At last, ask a user to select a proper coding system. | |
374 ;; (unwind-protect | |
375 ;; (save-window-excursion | |
376 ;; (when show-position | |
377 ;; ;; At first, be sure to show the current buffer. | |
378 ;; (set-window-buffer (selected-window) (current-buffer)) | |
379 ;; (set-window-start (selected-window) show-position)) | |
380 ;; ;; Then, show a helpful message. | |
381 ;; (with-output-to-temp-buffer "*Warning*" | |
382 ;; (save-excursion | |
383 ;; (set-buffer standard-output) | |
384 ;; (insert "The target text contains the following non ASCII character(s):\n") | |
385 ;; (let ((len (length non-safe-chars)) | |
386 ;; (shown 0)) | |
387 ;; (while (and non-safe-chars (< shown 3)) | |
388 ;; (when (> (length (car non-safe-chars)) 2) | |
389 ;; (setq shown (1+ shown)) | |
390 ;; (insert (format "%25s: " (car (car non-safe-chars)))) | |
391 ;; (let ((l (nthcdr 2 (car non-safe-chars)))) | |
392 ;; (while l | |
393 ;; (if (or (stringp (car l)) (char-valid-p (car l))) | |
394 ;; (insert (car l))) | |
395 ;; (setq l (cdr l)))) | |
396 ;; (if (> (nth 1 (car non-safe-chars)) 3) | |
397 ;; (insert "...")) | |
398 ;; (insert "\n")) | |
399 ;; (setq non-safe-chars (cdr non-safe-chars))) | |
400 ;; (if (< shown len) | |
401 ;; (insert (format "%27s\n" "...")))) | |
402 ;; (insert (format "\ | |
403 ;; These can't be encoded safely by the coding system %s. | |
404 ;; | |
405 ;; Please select one from the following safe coding systems:\n" | |
406 ;; default-coding-system)) | |
407 ;; (let ((pos (point)) | |
408 ;; (fill-prefix " ")) | |
409 ;; (mapcar (function (lambda (x) (princ " ") (princ x))) | |
410 ;; safe-coding-systems) | |
411 ;; (fill-region-as-paragraph pos (point))))) | |
412 ;; | |
413 ;; ;; Read a coding system. | |
414 ;; (let* ((safe-names (mapcar (lambda (x) (list (symbol-name x))) | |
415 ;; safe-coding-systems)) | |
416 ;; (name (completing-read | |
417 ;; (format "Select coding system (default %s): " | |
418 ;; (car safe-coding-systems)) | |
419 ;; safe-names nil t nil nil | |
420 ;; (car (car safe-names))))) | |
421 ;; (setq last-coding-system-specified (intern name)) | |
422 ;; (if (integerp (coding-system-eol-type default-coding-system)) | |
423 ;; (setq last-coding-system-specified | |
424 ;; (coding-system-change-eol-conversion | |
425 ;; last-coding-system-specified | |
426 ;; (coding-system-eol-type default-coding-system)))) | |
427 ;; last-coding-system-specified)) | |
428 ;; (kill-buffer "*Warning*") | |
429 ;; (while overlays | |
430 ;; (delete-overlay (car overlays)) | |
431 ;; (setq overlays (cdr overlays))))))))) | |
432 | |
433 ;; (setq select-safe-coding-system-function 'select-safe-coding-system) | |
434 | |
435 ;; (defun select-message-coding-system () | |
436 ;; "Return a coding system to encode the outgoing message of the current buffer. | |
437 ;; It at first tries the first coding system found in these variables | |
438 ;; in this order: | |
439 ;; (1) local value of `buffer-file-coding-system' | |
440 ;; (2) value of `sendmail-coding-system' | |
441 ;; (3) value of `default-buffer-file-coding-system' | |
442 ;; (4) value of `default-sendmail-coding-system' | |
443 ;; If the found coding system can't encode the current buffer, | |
444 ;; or none of them are bound to a coding system, | |
445 ;; it asks the user to select a proper coding system." | |
446 ;; (let ((coding (or (and (local-variable-p 'buffer-file-coding-system) | |
447 ;; buffer-file-coding-system) | |
448 ;; sendmail-coding-system | |
449 ;; default-buffer-file-coding-system | |
450 ;; default-sendmail-coding-system))) | |
451 ;; (if (eq coding 'no-conversion) | |
452 ;; ;; We should never use no-conversion for outgoing mails. | |
453 ;; (setq coding nil)) | |
454 ;; (if (fboundp select-safe-coding-system-function) | |
455 ;; (funcall select-safe-coding-system-function | |
456 ;; (point-min) (point-max) coding) | |
457 ;; coding))) | |
201 | 458 |
202 (provide 'code-cmds) | 459 (provide 'code-cmds) |
203 | 460 |
204 ;;; code-cmds.el ends here | 461 ;;; code-cmds.el ends here |