diff options
| author | Kenichi Handa | 1997-10-23 12:05:45 +0000 |
|---|---|---|
| committer | Kenichi Handa | 1997-10-23 12:05:45 +0000 |
| commit | e481690d87f3ec2ff6938cf29b6fea0fdfb67e07 (patch) | |
| tree | 9a37943ba91e9b5a87fd6fede1788d06d88b3b44 | |
| parent | a6acd8a293c4099a1659ee43e8164585fd4cf4ed (diff) | |
| download | emacs-e481690d87f3ec2ff6938cf29b6fea0fdfb67e07.tar.gz emacs-e481690d87f3ec2ff6938cf29b6fea0fdfb67e07.zip | |
(find-safe-coding-system): New function.
| -rw-r--r-- | lisp/international/mule-util.el | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lisp/international/mule-util.el b/lisp/international/mule-util.el index 3fd3a57b68b..c6316358dac 100644 --- a/lisp/international/mule-util.el +++ b/lisp/international/mule-util.el | |||
| @@ -287,6 +287,38 @@ or one is an alias of the other." | |||
| 287 | (or (eq eol-type-1 eol-type-2) | 287 | (or (eq eol-type-1 eol-type-2) |
| 288 | (and (vectorp eol-type-1) (vectorp eol-type-2))))))) | 288 | (and (vectorp eol-type-1) (vectorp eol-type-2))))))) |
| 289 | 289 | ||
| 290 | ;;;###autoload | ||
| 291 | (defun find-safe-coding-system (from to) | ||
| 292 | "Return a list of proper coding systems to encode a text between FROM and TO. | ||
| 293 | All coding systems in the list can safely encode any multibyte characters | ||
| 294 | in the region. | ||
| 295 | |||
| 296 | If the region contains no multibyte charcters, the returned list | ||
| 297 | contains a single element `undecided'. | ||
| 298 | |||
| 299 | Kludgy feature: if FROM is a string, then that string is the target | ||
| 300 | for finding proper coding systems, and TO is ignored." | ||
| 301 | (let ((found (if (stringp from) | ||
| 302 | (find-charset-string from) | ||
| 303 | (find-charset-region from to))) | ||
| 304 | (l coding-system-list) | ||
| 305 | codings coding safe) | ||
| 306 | (if (and (= (length found) 1) | ||
| 307 | (eq 'ascii (car found))) | ||
| 308 | '(undecided) | ||
| 309 | (while l | ||
| 310 | (setq coding (car l) l (cdr l)) | ||
| 311 | (if (and (eq coding (coding-system-base coding)) | ||
| 312 | (setq safe (coding-system-get coding 'safe-charsets)) | ||
| 313 | (or (eq safe t) | ||
| 314 | (catch 'tag | ||
| 315 | (mapcar (function (lambda (x) | ||
| 316 | (if (not (memq x safe)) | ||
| 317 | (throw 'tag nil)))) | ||
| 318 | found)))) | ||
| 319 | (setq codings (cons coding codings)))) | ||
| 320 | codings))) | ||
| 321 | |||
| 290 | 322 | ||
| 291 | ;;; Composite charcater manipulations. | 323 | ;;; Composite charcater manipulations. |
| 292 | 324 | ||