aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa2002-03-01 02:12:40 +0000
committerKenichi Handa2002-03-01 02:12:40 +0000
commit97941b05253cdac11a83c12dd4fec72e82a189b0 (patch)
treea77c04b57ab1f72ed6a4e68226c2734b5fab879f
parent491d068e41eb0f9f1bd67ababc3457e3db2c2008 (diff)
downloademacs-97941b05253cdac11a83c12dd4fec72e82a189b0.tar.gz
emacs-97941b05253cdac11a83c12dd4fec72e82a189b0.zip
Don't use coding category. Call
set-coding-system-priority instead of set-coding-priority. (sort-coding-systems): Call coding-system-priority-list to get the most preferred one. (select-safe-coding-system): Likewise. (reset-language-environment): Order of coding system priority changed. Set primary charset to iso-8859-1. (set-language-environment-coding-systems): Call set-coding-system-priority instead of set-coding-priority. (get-charset-property, put-charset-property): Moved to mule.el.
-rw-r--r--lisp/international/mule-cmds.el182
1 files changed, 56 insertions, 126 deletions
diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el
index 418957ca345..ee63c68489a 100644
--- a/lisp/international/mule-cmds.el
+++ b/lisp/international/mule-cmds.el
@@ -3,6 +3,9 @@
3;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN. 3;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
4;; Licensed to the Free Software Foundation. 4;; Licensed to the Free Software Foundation.
5;; Copyright (C) 2000, 2001 Free Software Foundation, Inc. 5;; Copyright (C) 2000, 2001 Free Software Foundation, Inc.
6;; Copyright (C) 2001, 2002
7;; National Institute of Advanced Industrial Science and Technology (AIST)
8;; Registration Number H13PRO009
6 9
7;; Keywords: mule, multilingual 10;; Keywords: mule, multilingual
8 11
@@ -341,26 +344,20 @@ See also `coding-category-list' and `coding-system-category'."
341 (interactive "zPrefer coding system: ") 344 (interactive "zPrefer coding system: ")
342 (if (not (and coding-system (coding-system-p coding-system))) 345 (if (not (and coding-system (coding-system-p coding-system)))
343 (error "Invalid coding system `%s'" coding-system)) 346 (error "Invalid coding system `%s'" coding-system))
344 (let ((coding-category (coding-system-category coding-system)) 347 (if (memq (coding-system-type coding-system) '(raw-text undecided))
345 (base (coding-system-base coding-system)) 348 (error "Can't prefer the coding system `%s'" coding-system))
349 (let ((base (coding-system-base coding-system))
346 (eol-type (coding-system-eol-type coding-system))) 350 (eol-type (coding-system-eol-type coding-system)))
347 (if (not coding-category) 351 (set-coding-system-priority base)
348 ;; CODING-SYSTEM is no-conversion or undecided. 352 (and (interactive-p)
349 (error "Can't prefer the coding system `%s'" coding-system)) 353 (or (eq base coding-system)
350 (set coding-category (or base coding-system)) 354 (message "Highest priority is set to %s (base of %s)"
351 (update-coding-systems-internal) 355 base coding-system)))
352 (or (eq coding-category (car coding-category-list))
353 ;; We must change the order.
354 (set-coding-priority (list coding-category)))
355 (if (and base (interactive-p))
356 (message "Highest priority is set to %s (base of %s)"
357 base coding-system))
358 ;; If they asked for specific EOL conversion, honor that. 356 ;; If they asked for specific EOL conversion, honor that.
359 (if (memq eol-type '(0 1 2)) 357 (if (memq eol-type '(0 1 2))
360 (setq coding-system 358 (setq base
361 (coding-system-change-eol-conversion base eol-type)) 359 (coding-system-change-eol-conversion base eol-type)))
362 (setq coding-system base)) 360 (set-default-coding-systems base)))
363 (set-default-coding-systems coding-system)))
364 361
365(defvar sort-coding-systems-predicate nil 362(defvar sort-coding-systems-predicate nil
366 "If non-nil, a predicate function to sort coding systems. 363 "If non-nil, a predicate function to sort coding systems.
@@ -383,7 +380,7 @@ If the variable `sort-coding-systems-predicate' (which see) is
383non-nil, it is used to sort CODINGS in the different way than above." 380non-nil, it is used to sort CODINGS in the different way than above."
384 (if sort-coding-systems-predicate 381 (if sort-coding-systems-predicate
385 (sort codings sort-coding-systems-predicate) 382 (sort codings sort-coding-systems-predicate)
386 (let* ((most-preferred (symbol-value (car coding-category-list))) 383 (let* ((most-preferred (coding-system-priority-list t))
387 (lang-preferred (get-language-info current-language-environment 384 (lang-preferred (get-language-info current-language-environment
388 'coding-system)) 385 'coding-system))
389 (func (function 386 (func (function
@@ -401,12 +398,10 @@ non-nil, it is used to sort CODINGS in the different way than above."
401 (if (eq (coding-system-type base) 2) 398 (if (eq (coding-system-type base) 2)
402 ;; For ISO based coding systems, prefer 399 ;; For ISO based coding systems, prefer
403 ;; one that doesn't use escape sequences. 400 ;; one that doesn't use escape sequences.
404 (let ((flags (coding-system-flags base))) 401 (let* ((extra-spec (coding-system-spec base))
405 (if (or (consp (aref flags 0)) 402 (flags (aref extra-spec 3)))
406 (consp (aref flags 1)) 403 (if (/= (logand flags #x40) 0)
407 (consp (aref flags 2)) 404 (if (/= (logand flags #x30) 0)
408 (consp (aref flags 3)))
409 (if (or (aref flags 8) (aref flags 9))
410 0 405 0
411 1) 406 1)
412 2)) 407 2))
@@ -581,11 +576,8 @@ and TO is ignored."
581 576
582 ;; If the most preferred coding system has the property mime-charset, 577 ;; If the most preferred coding system has the property mime-charset,
583 ;; append it to the defaults. 578 ;; append it to the defaults.
584 (let ((tail coding-category-list) 579 (let ((preferred (coding-system-priority-list t))
585 preferred base) 580 base)
586 (while (and tail
587 (not (setq preferred (symbol-value (car tail)))))
588 (setq tail (cdr tail)))
589 (and (coding-system-p preferred) 581 (and (coding-system-p preferred)
590 (setq base (coding-system-base preferred)) 582 (setq base (coding-system-base preferred))
591 (coding-system-get preferred 'mime-charset) 583 (coding-system-get preferred 'mime-charset)
@@ -1339,64 +1331,27 @@ The default status is as follows:
1339 The default value for the command `set-terminal-coding-system' is nil. 1331 The default value for the command `set-terminal-coding-system' is nil.
1340 The default value for the command `set-keyboard-coding-system' is nil. 1332 The default value for the command `set-keyboard-coding-system' is nil.
1341 1333
1342 The order of priorities of coding categories and the coding system 1334 The order of priorities of coding systems are as follows:
1343 bound to each category are as follows 1335 utf-8
1344 coding category coding system 1336 iso-2022-7bit
1345 -------------------------------------------------- 1337 iso-latin-1
1346 coding-category-iso-8-2 iso-latin-1 1338 iso-2022-7bit-lock
1347 coding-category-iso-8-1 iso-latin-1 1339 iso-2022-8bit-ss2
1348 coding-category-iso-7-tight iso-2022-jp 1340 emacs-mule
1349 coding-category-iso-7 iso-2022-7bit 1341 raw-text"
1350 coding-category-iso-7-else iso-2022-7bit-lock
1351 coding-category-iso-8-else iso-2022-8bit-ss2
1352 coding-category-emacs-mule emacs-mule
1353 coding-category-raw-text raw-text
1354 coding-category-sjis japanese-shift-jis
1355 coding-category-big5 chinese-big5
1356 coding-category-ccl nil
1357 coding-category-binary no-conversion
1358 coding-category-utf-16-be nil
1359 coding-category-utf-16-le nil
1360 coding-category-utf-8 mule-utf-8"
1361 (interactive) 1342 (interactive)
1362 ;; This function formerly set default-enable-multibyte-characters to t, 1343 ;; This function formerly set default-enable-multibyte-characters to t,
1363 ;; but that is incorrect. It should not alter the unibyte/multibyte choice. 1344 ;; but that is incorrect. It should not alter the unibyte/multibyte choice.
1364 1345
1365 (setq coding-category-iso-7-tight 'iso-2022-jp 1346 (set-coding-system-priority
1366 coding-category-iso-7 'iso-2022-7bit 1347 'utf-8
1367 coding-category-iso-8-1 'iso-latin-1 1348 'iso-2022-7bit
1368 coding-category-iso-8-2 'iso-latin-1 1349 'iso-latin-1
1369 coding-category-iso-7-else 'iso-2022-7bit-lock 1350 'iso-2022-7bit-lock
1370 coding-category-iso-8-else 'iso-2022-8bit-ss2 1351 'iso-2022-8bit-ss2
1371 coding-category-emacs-mule 'emacs-mule 1352 'emacs-mule
1372 coding-category-raw-text 'raw-text 1353 'raw-text)
1373 coding-category-sjis 'japanese-shift-jis 1354
1374 coding-category-big5 'chinese-big5
1375 coding-category-utf-16-be nil
1376 coding-category-utf-16-le nil
1377 coding-category-utf-8 'mule-utf-8
1378 coding-category-ccl nil
1379 coding-category-binary 'no-conversion)
1380
1381 (set-coding-priority
1382 '(coding-category-iso-8-1
1383 coding-category-iso-8-2
1384 coding-category-iso-7-tight
1385 coding-category-iso-7
1386 coding-category-iso-7-else
1387 coding-category-iso-8-else
1388 coding-category-emacs-mule
1389 coding-category-raw-text
1390 coding-category-sjis
1391 coding-category-big5
1392 coding-category-ccl
1393 coding-category-binary
1394 coding-category-utf-16-be
1395 coding-category-utf-16-le
1396 coding-category-utf-8))
1397
1398 (update-coding-systems-internal)
1399
1400 (set-default-coding-systems nil) 1355 (set-default-coding-systems nil)
1401 (setq default-sendmail-coding-system 'iso-latin-1) 1356 (setq default-sendmail-coding-system 'iso-latin-1)
1402 (setq default-process-coding-system '(undecided . iso-latin-1)) 1357 (setq default-process-coding-system '(undecided . iso-latin-1))
@@ -1408,7 +1363,8 @@ The default status is as follows:
1408;;; (set-keyboard-coding-system-internal nil) 1363;;; (set-keyboard-coding-system-internal nil)
1409 1364
1410 (setq nonascii-translation-table nil 1365 (setq nonascii-translation-table nil
1411 nonascii-insert-offset 0)) 1366 nonascii-insert-offset 0)
1367 (set-primary-charset 'iso-8859-1))
1412 1368
1413(reset-language-environment) 1369(reset-language-environment)
1414 1370
@@ -1461,20 +1417,15 @@ specifies the character set for the major languages of Western Europe."
1461 (setq input-method-history 1417 (setq input-method-history
1462 (cons input-method 1418 (cons input-method
1463 (delete input-method input-method-history)))))) 1419 (delete input-method input-method-history))))))
1464 (let ((nonascii (get-language-info language-name 'nonascii-translation)) 1420
1465 (dos-table 1421 ;; Note: For DOS, we assumed that the charset cpXXX is already
1466 (if (eq window-system 'pc) 1422 ;; defined.
1467 (intern 1423 (let ((nonascii (get-language-info language-name 'nonascii-translation)))
1468 (format "cp%d-nonascii-translation-table" dos-codepage))))) 1424 (if (eq window-system 'pc)
1469 (cond 1425 (setq nonascii (intern "cp%d" dos-codepage)))
1470 ((char-table-p nonascii) 1426 (or (charsetp nonascii)
1471 (setq nonascii-translation-table nonascii)) 1427 (setq nonascii 'iso-8859-1))
1472 ((and (eq window-system 'pc) (boundp dos-table)) 1428 (set-primary-charset nonascii))
1473 ;; DOS terminals' default is to use a special non-ASCII translation
1474 ;; table as appropriate for the installed codepage.
1475 (setq nonascii-translation-table (symbol-value dos-table)))
1476 ((charsetp nonascii)
1477 (setq nonascii-insert-offset (- (make-char nonascii) 128)))))
1478 1429
1479 ;; Unibyte setups if necessary. 1430 ;; Unibyte setups if necessary.
1480 (unless default-enable-multibyte-characters 1431 (unless default-enable-multibyte-characters
@@ -1543,18 +1494,13 @@ The optional arg EOL-TYPE specifies the eol-type of the default value
1543of buffer-file-coding-system set by this function." 1494of buffer-file-coding-system set by this function."
1544 (let* ((priority (get-language-info language-name 'coding-priority)) 1495 (let* ((priority (get-language-info language-name 'coding-priority))
1545 (default-coding (car priority))) 1496 (default-coding (car priority)))
1546 (if priority 1497 (when priority
1547 (let ((categories (mapcar 'coding-system-category priority))) 1498 (set-default-coding-systems
1548 (set-default-coding-systems 1499 (if (memq eol-type '(0 1 2 unix dos mac))
1549 (if (memq eol-type '(0 1 2 unix dos mac)) 1500 (coding-system-change-eol-conversion default-coding eol-type)
1550 (coding-system-change-eol-conversion default-coding eol-type) 1501 default-coding))
1551 default-coding)) 1502 (setq default-sendmail-coding-system default-coding)
1552 (setq default-sendmail-coding-system default-coding) 1503 (apply 'set-coding-system-priority priority))))
1553 (set-coding-priority categories)
1554 (while priority
1555 (set (car categories) (car priority))
1556 (setq priority (cdr priority) categories (cdr categories)))
1557 (update-coding-systems-internal)))))
1558 1504
1559;; Print all arguments with `princ', then print "\n". 1505;; Print all arguments with `princ', then print "\n".
1560(defsubst princ-list (&rest args) 1506(defsubst princ-list (&rest args)
@@ -2022,22 +1968,6 @@ See also `locale-charset-language-names', `locale-language-names',
2022 (prefer-coding-system coding-system) 1968 (prefer-coding-system coding-system)
2023 (setq locale-coding-system coding-system)))))) 1969 (setq locale-coding-system coding-system))))))
2024 1970
2025;;; Charset property
2026
2027(defun get-charset-property (charset propname)
2028 "Return the value of CHARSET's PROPNAME property.
2029This is the last value stored with
2030 (put-charset-property CHARSET PROPNAME VALUE)."
2031 (and (not (eq charset 'composition))
2032 (plist-get (charset-plist charset) propname)))
2033
2034(defun put-charset-property (charset propname value)
2035 "Store CHARSETS's PROPNAME property with value VALUE.
2036It can be retrieved with `(get-charset-property CHARSET PROPNAME)'."
2037 (or (eq charset 'composition)
2038 (set-charset-plist charset
2039 (plist-put (charset-plist charset) propname value))))
2040
2041;;; Character code property 1971;;; Character code property
2042(put 'char-code-property-table 'char-table-extra-slots 0) 1972(put 'char-code-property-table 'char-table-extra-slots 0)
2043 1973