comparison lisp/international/mule-cmds.el @ 20842:428831a6f4d1

(find-safe-coding-system): Return undecided if FROM == TO. (select-safe-coding-system): Doc-string modified.
author Kenichi Handa <handa@m17n.org>
date Wed, 04 Feb 1998 11:25:47 +0000
parents 237a0f70c61d
children 588dae3ae7cc
comparison
equal deleted inserted replaced
20841:ef5fd882ca63 20842:428831a6f4d1
245 245
246 Kludgy feature: if FROM is a string, the string is the target text, 246 Kludgy feature: if FROM is a string, the string is the target text,
247 and TO is ignored." 247 and TO is ignored."
248 (let ((charset-list (if (stringp from) (find-charset-string from) 248 (let ((charset-list (if (stringp from) (find-charset-string from)
249 (find-charset-region from to)))) 249 (find-charset-region from to))))
250 (if (and (= (length charset-list) 1) 250 (if (or (null charset-list)
251 (eq 'ascii (car charset-list))) 251 (and (= (length charset-list) 1)
252 (eq 'ascii (car charset-list))))
252 '(undecided) 253 '(undecided)
253 (let ((l coding-system-list) 254 (let ((l coding-system-list)
254 (prefered-codings 255 (prefered-codings
255 (mapcar (function 256 (mapcar (function
256 (lambda (x) 257 (lambda (x)
278 (mapcar 'cdr 279 (mapcar 'cdr
279 (sort codings (function (lambda (x y) (> (car x) (car y)))))) 280 (sort codings (function (lambda (x y) (> (car x) (car y))))))
280 )))) 281 ))))
281 282
282 (defun select-safe-coding-system (from to &optional default-coding-system) 283 (defun select-safe-coding-system (from to &optional default-coding-system)
283 "Return a coding system which can encode a text between FROM and TO. 284 "Ask a user to select a safe coding system from candidates.
285 The candidates of coding systems which can safely encode a text
286 between FROM and TO are shown in a popup window.
284 287
285 Optional arg DEFAULT-CODING-SYSTEM specifies a coding system to be 288 Optional arg DEFAULT-CODING-SYSTEM specifies a coding system to be
286 checked at first. If omitted, buffer-file-coding-system of the 289 checked at first. If omitted, buffer-file-coding-system of the
287 current buffer is used. 290 current buffer is used.
288 291
289 If the text contains some multibyte characters and 292 If the text can be encoded safely by DEFAULT-CODING-SYSTEM, it is
290 DEFAULT-CODING-SYSTEM can't encode them, ask a user to select one from 293 returned without any user interaction.
291 a list of coding systems which can encode the text, and return the
292 selected one.
293
294 In other cases, return DEFAULT-CODING-SYSTEM.
295 294
296 Kludgy feature: if FROM is a string, the string is the target text, 295 Kludgy feature: if FROM is a string, the string is the target text,
297 and TO is ignored." 296 and TO is ignored."
298 (or default-coding-system 297 (or default-coding-system
299 (setq default-coding-system buffer-file-coding-system)) 298 (setq default-coding-system buffer-file-coding-system))