Mercurial > emacs
comparison lisp/international/mule-cmds.el @ 89483:2f877ed80fa6
*** empty log message ***
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Mon, 08 Sep 2003 12:53:41 +0000 |
parents | 375f2633d815 523daff56a65 |
children | 6f848cbaeb52 |
comparison
equal
deleted
inserted
replaced
88123:375f2633d815 | 89483:2f877ed80fa6 |
---|---|
1 ;;; mule-cmds.el --- commands for mulitilingual environment | 1 ;;; mule-cmds.el --- commands for mulitilingual environment |
2 ;; Copyright (C) 1995, 2003 Electrotechnical Laboratory, JAPAN. | 2 ;; Copyright (C) 1995, 2003 Electrotechnical Laboratory, JAPAN. |
3 ;; Licensed to the Free Software Foundation. | 3 ;; Licensed to the Free Software Foundation. |
4 ;; Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc. | 4 ;; Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc. |
5 | 5 ;; Copyright (C) 2003 |
6 ;; Keywords: mule, multilingual | 6 ;; National Institute of Advanced Industrial Science and Technology (AIST) |
7 ;; Registration Number H13PRO009 | |
8 | |
9 ;; Keywords: mule, i18n | |
7 | 10 |
8 ;; This file is part of GNU Emacs. | 11 ;; This file is part of GNU Emacs. |
9 | 12 |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | 13 ;; GNU Emacs is free software; you can redistribute it and/or modify |
11 ;; it under the terms of the GNU General Public License as published by | 14 ;; it under the terms of the GNU General Public License as published by |
24 | 27 |
25 ;;; Commentary: | 28 ;;; Commentary: |
26 | 29 |
27 ;;; Code: | 30 ;;; Code: |
28 | 31 |
29 (eval-when-compile (defvar dos-codepage)) | 32 (eval-when-compile |
33 (defvar dos-codepage) | |
34 (require 'wid-edit)) | |
30 | 35 |
31 ;;; MULE related key bindings and menus. | 36 ;;; MULE related key bindings and menus. |
32 | 37 |
33 (defvar mule-keymap (make-sparse-keymap) | 38 (defvar mule-keymap (make-sparse-keymap) |
34 "Keymap for Mule (Multilingual environment) specific commands.") | 39 "Keymap for Mule (Multilingual environment) specific commands.") |
264 (defun universal-coding-system-argument (coding-system) | 269 (defun universal-coding-system-argument (coding-system) |
265 "Execute an I/O command using the specified coding system." | 270 "Execute an I/O command using the specified coding system." |
266 (interactive | 271 (interactive |
267 (let ((default (and buffer-file-coding-system | 272 (let ((default (and buffer-file-coding-system |
268 (not (eq (coding-system-type buffer-file-coding-system) | 273 (not (eq (coding-system-type buffer-file-coding-system) |
269 t)) | 274 'undecided)) |
270 buffer-file-coding-system))) | 275 buffer-file-coding-system))) |
271 (list (read-coding-system | 276 (list (read-coding-system |
272 (if default | 277 (if default |
273 (format "Coding system for following command (default, %s): " default) | 278 (format "Coding system for following command (default, %s): " default) |
274 "Coding system for following command: ") | 279 "Coding system for following command: ") |
291 ;; `digit-argument', for isntance, can compute the | 296 ;; `digit-argument', for isntance, can compute the |
292 ;; prefix arg. | 297 ;; prefix arg. |
293 (last-command-char (aref keyseq 0))) | 298 (last-command-char (aref keyseq 0))) |
294 (call-interactively cmd))) | 299 (call-interactively cmd))) |
295 | 300 |
296 ;; This is the final call to `univeral-argument-other-key', which | 301 ;; This is the final call to `universal-argument-other-key', which |
297 ;; set's the final `prefix-arg. | 302 ;; set's the final `prefix-arg. |
298 (let ((current-prefix-arg prefix-arg)) | 303 (let ((current-prefix-arg prefix-arg)) |
299 (call-interactively cmd)) | 304 (call-interactively cmd)) |
300 | 305 |
301 ;; Read the command to execute with the given prefix arg. | 306 ;; Read the command to execute with the given prefix arg. |
362 for MS-DOS terminal, because DOS terminals only support a single coding | 367 for MS-DOS terminal, because DOS terminals only support a single coding |
363 system, and Emacs automatically sets the default to that coding system at | 368 system, and Emacs automatically sets the default to that coding system at |
364 startup. | 369 startup. |
365 | 370 |
366 A coding system that requires automatic detection of text | 371 A coding system that requires automatic detection of text |
367 encoding (e.g. undecided, unix) can't be preferred. | 372 +encoding (e.g. undecided, unix) can't be preferred.." |
368 | |
369 See also `coding-category-list' and `coding-system-category'." | |
370 (interactive "zPrefer coding system: ") | 373 (interactive "zPrefer coding system: ") |
371 (if (not (and coding-system (coding-system-p coding-system))) | 374 (if (not (and coding-system (coding-system-p coding-system))) |
372 (error "Invalid coding system `%s'" coding-system)) | 375 (error "Invalid coding system `%s'" coding-system)) |
373 (let ((coding-category (coding-system-category coding-system)) | 376 (if (memq (coding-system-type coding-system) '(raw-text undecided)) |
374 (base (coding-system-base coding-system)) | 377 (error "Can't prefer the coding system `%s'" coding-system)) |
378 (let ((base (coding-system-base coding-system)) | |
375 (eol-type (coding-system-eol-type coding-system))) | 379 (eol-type (coding-system-eol-type coding-system))) |
376 (if (not coding-category) | 380 (set-coding-system-priority base) |
377 ;; CODING-SYSTEM is no-conversion or undecided. | 381 (and (interactive-p) |
378 (error "Can't prefer the coding system `%s'" coding-system)) | 382 (or (eq base coding-system) |
379 (set coding-category (or base coding-system)) | 383 (message "Highest priority is set to %s (base of %s)" |
380 (update-coding-systems-internal) | 384 base coding-system))) |
381 (or (eq coding-category (car coding-category-list)) | |
382 ;; We must change the order. | |
383 (set-coding-priority (list coding-category))) | |
384 (if (and base (interactive-p)) | |
385 (message "Highest priority is set to %s (base of %s)" | |
386 base coding-system)) | |
387 ;; If they asked for specific EOL conversion, honor that. | 385 ;; If they asked for specific EOL conversion, honor that. |
388 (if (memq eol-type '(0 1 2)) | 386 (if (memq eol-type '(0 1 2)) |
389 (setq coding-system | 387 (setq base |
390 (coding-system-change-eol-conversion base eol-type)) | 388 (coding-system-change-eol-conversion base eol-type))) |
391 (setq coding-system base)) | 389 (set-default-coding-systems base))) |
392 (set-default-coding-systems coding-system))) | |
393 | 390 |
394 (defvar sort-coding-systems-predicate nil | 391 (defvar sort-coding-systems-predicate nil |
395 "If non-nil, a predicate function to sort coding systems. | 392 "If non-nil, a predicate function to sort coding systems. |
396 | 393 |
397 It is called with two coding systems, and should return t if the first | 394 It is called with two coding systems, and should return t if the first |
410 | 407 |
411 If the variable `sort-coding-systems-predicate' (which see) is | 408 If the variable `sort-coding-systems-predicate' (which see) is |
412 non-nil, it is used to sort CODINGS in the different way than above." | 409 non-nil, it is used to sort CODINGS in the different way than above." |
413 (if sort-coding-systems-predicate | 410 (if sort-coding-systems-predicate |
414 (sort codings sort-coding-systems-predicate) | 411 (sort codings sort-coding-systems-predicate) |
415 (let* ((from-categories (mapcar #'(lambda (x) (symbol-value x)) | 412 (let* ((from-priority (coding-system-priority-list)) |
416 coding-category-list)) | 413 (most-preferred (car from-priority)) |
417 (most-preferred (car from-categories)) | |
418 (lang-preferred (get-language-info current-language-environment | 414 (lang-preferred (get-language-info current-language-environment |
419 'coding-system)) | 415 'coding-system)) |
420 (func (function | 416 (func (function |
421 (lambda (x) | 417 (lambda (x) |
422 (let ((base (coding-system-base x))) | 418 (let ((base (coding-system-base x))) |
429 ;; E: 1 iff not XXX-with-esc | 425 ;; E: 1 iff not XXX-with-esc |
430 ;; II: if iso-2022 based, 0..3, else 1. | 426 ;; II: if iso-2022 based, 0..3, else 1. |
431 (logior | 427 (logior |
432 (lsh (if (eq base most-preferred) 1 0) 7) | 428 (lsh (if (eq base most-preferred) 1 0) 7) |
433 (lsh | 429 (lsh |
434 (let ((mime (coding-system-get base 'mime-charset))) | 430 (let ((mime (coding-system-get base :mime-charset))) |
435 ;; Prefer coding systems corresponding to a | 431 ;; Prefer coding systems corresponding to a |
436 ;; MIME charset. | 432 ;; MIME charset. |
437 (if mime | 433 (if mime |
438 ;; Lower utf-16 priority so that we | 434 ;; Lower utf-16 priority so that we |
439 ;; normally prefer utf-8 to it, and put | 435 ;; normally prefer utf-8 to it, and put |
445 1) | 441 1) |
446 (t 3)) | 442 (t 3)) |
447 0)) | 443 0)) |
448 5) | 444 5) |
449 (lsh (if (memq base lang-preferred) 1 0) 4) | 445 (lsh (if (memq base lang-preferred) 1 0) 4) |
450 (lsh (if (memq base from-categories) 1 0) 3) | 446 (lsh (if (memq base from-priority) 1 0) 3) |
451 (lsh (if (string-match "-with-esc\\'" | 447 (lsh (if (string-match "-with-esc\\'" |
452 (symbol-name base)) | 448 (symbol-name base)) |
453 0 1) 2) | 449 0 1) 2) |
454 (if (eq (coding-system-type base) 2) | 450 (if (eq (coding-system-type base) 'iso-2022) |
455 ;; For ISO based coding systems, prefer | 451 (let ((category (coding-system-category base))) |
456 ;; one that doesn't use escape sequences. | 452 ;; For ISO based coding systems, prefer |
457 (let ((flags (coding-system-flags base))) | 453 ;; one that doesn't use designation nor |
458 (if (or (consp (aref flags 0)) | 454 ;; locking/single shifting. |
459 (consp (aref flags 1)) | 455 (cond |
460 (consp (aref flags 2)) | 456 ((or (eq category 'coding-category-iso-8-1) |
461 (consp (aref flags 3))) | 457 (eq category 'coding-category-iso-8-2)) |
462 (if (or (aref flags 8) (aref flags 9)) | 458 2) |
463 0 | 459 ((or (eq category 'coding-category-iso-7-tight) |
464 1) | 460 (eq category 'coding-category-iso-7)) |
465 2)) | 461 1) |
466 1))))))) | 462 (t |
463 0))) | |
464 1) | |
465 )))))) | |
467 (sort codings (function (lambda (x y) | 466 (sort codings (function (lambda (x y) |
468 (> (funcall func x) (funcall func y)))))))) | 467 (> (funcall func x) (funcall func y)))))))) |
469 | 468 |
470 (defun find-coding-systems-region (from to) | 469 (defun find-coding-systems-region (from to) |
471 "Return a list of proper coding systems to encode a text between FROM and TO. | 470 "Return a list of proper coding systems to encode a text between FROM and TO. |
471 | |
472 If FROM is a string, find coding systems in that instead of the buffer. | 472 If FROM is a string, find coding systems in that instead of the buffer. |
473 All coding systems in the list can safely encode any multibyte characters | 473 All coding systems in the list can safely encode any multibyte characters |
474 in the text. | 474 in the text. |
475 | 475 |
476 If the text contains no multibyte characters, return a list of a single | 476 If the text contains no multibyte characters, return a list of a single |
493 (find-coding-systems-region string nil)) | 493 (find-coding-systems-region string nil)) |
494 | 494 |
495 (defun find-coding-systems-for-charsets (charsets) | 495 (defun find-coding-systems-for-charsets (charsets) |
496 "Return a list of proper coding systems to encode characters of CHARSETS. | 496 "Return a list of proper coding systems to encode characters of CHARSETS. |
497 CHARSETS is a list of character sets. | 497 CHARSETS is a list of character sets. |
498 It actually checks at most the first 96 characters of each charset. | 498 |
499 So, if a charset of dimension two is included in CHARSETS, the value may | 499 This only finds coding systems of type `charset', whose |
500 contain a coding system that can't encode all characters of the charset." | 500 `:charset-list' property includes all of CHARSETS (plus `ascii' for |
501 ascii-compatible coding systems). It was used in older versions of | |
502 Emacs, but is unlikely to be what you really want now." | |
503 ;; Deal with aliases. | |
504 (setq charsets (mapcar (lambda (c) | |
505 (get-charset-property c :name)) | |
506 charsets)) | |
501 (cond ((or (null charsets) | 507 (cond ((or (null charsets) |
502 (and (= (length charsets) 1) | 508 (and (= (length charsets) 1) |
503 (eq 'ascii (car charsets)))) | 509 (eq 'ascii (car charsets)))) |
504 '(undecided)) | 510 '(undecided)) |
505 ((or (memq 'eight-bit-control charsets) | 511 ((or (memq 'eight-bit-control charsets) |
506 (memq 'eight-bit-graphic charsets)) | 512 (memq 'eight-bit-graphic charsets)) |
507 '(raw-text emacs-mule)) | 513 '(raw-text utf-8-emacs)) |
508 (t | 514 (t |
509 (let ((codings t) | 515 (let (codings) |
510 charset l str) | 516 (dolist (cs (coding-system-list t)) |
511 (while (and codings charsets) | 517 (let ((cs-charsets (and (eq (coding-system-type cs) 'charset) |
512 (setq charset (car charsets) charsets (cdr charsets)) | 518 (coding-system-charset-list cs))) |
513 (unless (eq charset 'ascii) | 519 (charsets charsets)) |
514 (setq str (make-string 96 32)) | 520 (if (coding-system-get cs :ascii-compatible-p) |
515 (if (= (charset-dimension charset) 1) | 521 (add-to-list 'cs-charsets 'ascii)) |
516 (if (= (charset-chars charset) 96) | 522 (if (catch 'ok |
517 (dotimes (i 96) | 523 (when cs-charsets |
518 (aset str i (make-char charset (+ i 32)))) | 524 (while charsets |
519 (dotimes (i 94) | 525 (unless (memq (pop charsets) cs-charsets) |
520 (aset str i (make-char charset (+ i 33))))) | 526 (throw 'ok nil))) |
521 (if (= (charset-chars charset) 96) | 527 t)) |
522 (dotimes (i 96) | 528 (push cs codings)))) |
523 (aset str i (make-char charset 32 (+ i 32)))) | 529 (nreverse codings))))) |
524 (dotimes (i 94) | |
525 (aset str i (make-char charset 33 (+ i 33)))))) | |
526 (setq l (find-coding-systems-string str)) | |
527 (if (eq codings t) | |
528 (setq codings l) | |
529 (let ((ll nil)) | |
530 (dolist (elt codings) | |
531 (if (memq elt l) | |
532 (setq ll (cons elt ll)))) | |
533 (setq codings ll))))) | |
534 codings)))) | |
535 | 530 |
536 (defun find-multibyte-characters (from to &optional maxcount excludes) | 531 (defun find-multibyte-characters (from to &optional maxcount excludes) |
537 "Find multibyte characters in the region specified by FROM and TO. | 532 "Find multibyte characters in the region specified by FROM and TO. |
538 If FROM is a string, find multibyte characters in the string. | 533 If FROM is a string, find multibyte characters in the string. |
539 The return value is an alist of the following format: | 534 The return value is an alist of the following format: |
540 ((CHARSET COUNT CHAR ...) ...) | 535 ((CHARSET COUNT CHAR ...) ...) |
541 where | 536 where |
542 CHARSET is a character set, | 537 CHARSET is a character set, |
543 COUNT is a number of characters, | 538 COUNT is a number of characters, |
544 CHARs are found characters of the character set. | 539 CHARs are the characters found from the character set. |
545 Optional 3rd arg MAXCOUNT limits how many CHARs are put in the above list. | 540 Optional 3rd arg MAXCOUNT limits how many CHARs are put in the above list. |
546 Optional 4th arg EXCLUDE is a list of character sets to be ignored. | 541 Optional 4th arg EXCLUDE is a list of character sets to be ignored." |
547 | |
548 For invalid characters, CHARs are actually strings." | |
549 (let ((chars nil) | 542 (let ((chars nil) |
550 charset char) | 543 charset char) |
551 (if (stringp from) | 544 (if (stringp from) |
552 (let ((idx 0)) | 545 (if (multibyte-string-p from) |
553 (while (setq idx (string-match "[^\000-\177]" from idx)) | 546 (let ((idx 0)) |
554 (setq char (aref from idx) | 547 (while (setq idx (string-match "[^\000-\177]" from idx)) |
555 charset (char-charset char)) | 548 (setq char (aref from idx) |
556 (if (eq charset 'unknown) | 549 charset (char-charset char)) |
557 (setq char (match-string 0))) | 550 (unless (memq charset excludes) |
558 (if (or (memq charset '(unknown | 551 (let ((slot (assq charset chars))) |
559 eight-bit-control eight-bit-graphic)) | 552 (if slot |
560 (not (or (eq excludes t) (memq charset excludes)))) | 553 (if (not (memq char (nthcdr 2 slot))) |
554 (let ((count (nth 1 slot))) | |
555 (setcar (cdr slot) (1+ count)) | |
556 (if (or (not maxcount) (< count maxcount)) | |
557 (nconc slot (list char))))) | |
558 (setq chars (cons (list charset 1 char) chars))))) | |
559 (setq idx (1+ idx))))) | |
560 (if enable-multibyte-characters | |
561 (save-excursion | |
562 (goto-char from) | |
563 (while (re-search-forward "[^\000-\177]" to t) | |
564 (setq char (preceding-char) | |
565 charset (char-charset char)) | |
566 (unless (memq charset excludes) | |
561 (let ((slot (assq charset chars))) | 567 (let ((slot (assq charset chars))) |
562 (if slot | 568 (if slot |
563 (if (not (memq char (nthcdr 2 slot))) | 569 (if (not (member char (nthcdr 2 slot))) |
564 (let ((count (nth 1 slot))) | 570 (let ((count (nth 1 slot))) |
565 (setcar (cdr slot) (1+ count)) | 571 (setcar (cdr slot) (1+ count)) |
566 (if (or (not maxcount) (< count maxcount)) | 572 (if (or (not maxcount) (< count maxcount)) |
567 (nconc slot (list char))))) | 573 (nconc slot (list char))))) |
568 (setq chars (cons (list charset 1 char) chars))))) | 574 (setq chars (cons (list charset 1 char) chars))))))))) |
569 (setq idx (1+ idx)))) | |
570 (save-excursion | |
571 (goto-char from) | |
572 (while (re-search-forward "[^\000-\177]" to t) | |
573 (setq char (preceding-char) | |
574 charset (char-charset char)) | |
575 (if (eq charset 'unknown) | |
576 (setq char (match-string 0))) | |
577 (if (or (memq charset '(unknown eight-bit-control eight-bit-graphic)) | |
578 (not (or (eq excludes t) (memq charset excludes)))) | |
579 (let ((slot (assq charset chars))) | |
580 (if slot | |
581 (if (not (member char (nthcdr 2 slot))) | |
582 (let ((count (nth 1 slot))) | |
583 (setcar (cdr slot) (1+ count)) | |
584 (if (or (not maxcount) (< count maxcount)) | |
585 (nconc slot (list char))))) | |
586 (setq chars (cons (list charset 1 char) chars)))))))) | |
587 (nreverse chars))) | 575 (nreverse chars))) |
588 | |
589 | 576 |
590 (defun search-unencodable-char (coding-system) | 577 (defun search-unencodable-char (coding-system) |
591 "Search forward from point for a character that is not encodable. | 578 "Search forward from point for a character that is not encodable. |
592 It asks which coding system to check. | 579 It asks which coding system to check. |
593 If such a character is found, set point after that character. | 580 If such a character is found, set point after that character. |
604 (if pos | 591 (if pos |
605 (goto-char (1+ pos)) | 592 (goto-char (1+ pos)) |
606 (message "All following characters are encodable by %s" coding-system)) | 593 (message "All following characters are encodable by %s" coding-system)) |
607 pos)) | 594 pos)) |
608 | 595 |
609 | |
610 (defvar last-coding-system-specified nil | 596 (defvar last-coding-system-specified nil |
611 "Most recent coding system explicitly specified by the user when asked. | 597 "Most recent coding system explicitly specified by the user when asked. |
612 This variable is set whenever Emacs asks the user which coding system | 598 This variable is set whenever Emacs asks the user which coding system |
613 to use in order to write a file. If you set it to nil explicitly, | 599 to use in order to write a file. If you set it to nil explicitly, |
614 then call `write-region', then afterward this variable will be non-nil | 600 then call `write-region', then afterward this variable will be non-nil |
698 (push (cons default-buffer-file-coding-system base) | 684 (push (cons default-buffer-file-coding-system base) |
699 default-coding-system)))) | 685 default-coding-system)))) |
700 | 686 |
701 ;; If the most preferred coding system has the property mime-charset, | 687 ;; If the most preferred coding system has the property mime-charset, |
702 ;; append it to the defaults. | 688 ;; append it to the defaults. |
703 (let ((tail coding-category-list) | 689 (let ((preferred (coding-system-priority-list t)) |
704 preferred base) | 690 base) |
705 (while (and tail (not (setq preferred (symbol-value (car tail))))) | |
706 (setq tail (cdr tail))) | |
707 (and (coding-system-p preferred) | 691 (and (coding-system-p preferred) |
708 (setq base (coding-system-base preferred)) | 692 (setq base (coding-system-base preferred)) |
709 (coding-system-get preferred 'mime-charset) | 693 (coding-system-get preferred :mime-charset) |
710 (not (rassq base default-coding-system)) | 694 (not (rassq base default-coding-system)) |
711 (push (cons preferred base) | 695 (push (cons preferred base) |
712 default-coding-system))))) | 696 default-coding-system))))) |
713 | 697 |
714 (if select-safe-coding-system-accept-default-p | 698 (if select-safe-coding-system-accept-default-p |
763 ;; mime-charset name if it is also a coding system. Such a name | 747 ;; mime-charset name if it is also a coding system. Such a name |
764 ;; is more friendly to users. | 748 ;; is more friendly to users. |
765 (let ((l codings) | 749 (let ((l codings) |
766 mime-charset) | 750 mime-charset) |
767 (while l | 751 (while l |
768 (setq mime-charset (coding-system-get (car l) 'mime-charset)) | 752 (setq mime-charset (coding-system-get (car l) :mime-charset)) |
769 (if (and mime-charset (coding-system-p mime-charset)) | 753 (if (and mime-charset (coding-system-p mime-charset) |
754 (coding-system-equal (car l) mime-charset)) | |
770 (setcar l mime-charset)) | 755 (setcar l mime-charset)) |
771 (setq l (cdr l)))) | 756 (setq l (cdr l)))) |
772 | 757 |
773 ;; Don't offer variations with locking shift, which you | 758 ;; Don't offer variations with locking shift, which you |
774 ;; basically never want. | 759 ;; basically never want. |
957 ;; We should never use no-conversion for outgoing mail. | 942 ;; We should never use no-conversion for outgoing mail. |
958 (setq coding nil)) | 943 (setq coding nil)) |
959 (if (fboundp select-safe-coding-system-function) | 944 (if (fboundp select-safe-coding-system-function) |
960 (funcall select-safe-coding-system-function | 945 (funcall select-safe-coding-system-function |
961 (point-min) (point-max) coding | 946 (point-min) (point-max) coding |
962 (function (lambda (x) (coding-system-get x 'mime-charset)))) | 947 (function (lambda (x) (coding-system-get x :mime-charset)))) |
963 coding))) | 948 coding))) |
964 | 949 |
965 ;;; Language support stuff. | 950 ;;; Language support stuff. |
966 | 951 |
967 (defvar language-info-alist nil | 952 (defvar language-info-alist nil |
973 INFO is the data associated with KEY. | 958 INFO is the data associated with KEY. |
974 Meaningful values for KEY include | 959 Meaningful values for KEY include |
975 | 960 |
976 documentation value is documentation of what this language environment | 961 documentation value is documentation of what this language environment |
977 is meant for, and how to use it. | 962 is meant for, and how to use it. |
978 charset value is a list of the character sets used by this | 963 charset value is a list of the character sets mainly used |
979 language environment. | 964 by this language environment. |
980 sample-text value is an expression which is evalled to generate | 965 sample-text value is an expression which is evalled to generate |
981 a line of text written using characters appropriate | 966 a line of text written using characters appropriate |
982 for this language environment. | 967 for this language environment. |
983 setup-function value is a function to call to switch to this | 968 setup-function value is a function to call to switch to this |
984 language environment. | 969 language environment. |
991 coding-priority value is a list of coding systems for this language | 976 coding-priority value is a list of coding systems for this language |
992 environment, in order of decreasing priority. | 977 environment, in order of decreasing priority. |
993 This is used to set up the coding system priority | 978 This is used to set up the coding system priority |
994 list when you switch to this language environment. | 979 list when you switch to this language environment. |
995 nonascii-translation | 980 nonascii-translation |
996 value is a translation table to be set in the | 981 value is a charset of dimension one to use for |
997 variable `nonascii-translation-table' in this | 982 converting a unibyte character to multibyte |
998 language environment, or a character set from | 983 and vice versa. |
999 which `nonascii-insert-offset' is calculated. | |
1000 input-method value is a default input method for this language | 984 input-method value is a default input method for this language |
1001 environment. | 985 environment. |
1002 features value is a list of features requested in this | 986 features value is a list of features requested in this |
1003 language environment. | 987 language environment. |
1004 | 988 |
1005 The following keys take effect only when multibyte characters are | 989 The following keys take effect only when multibyte characters are |
1006 globally disabled, i.e. the value of `default-enable-multibyte-characters' | 990 globally disabled, i.e. the value of `default-enable-multibyte-characters' |
1007 is nil. | 991 is nil. |
1008 | |
1009 unibyte-syntax value is a library name to load to set | |
1010 unibyte 8-bit character syntaxes for this | |
1011 language environment. | |
1012 | 992 |
1013 unibyte-display value is a coding system to encode characters | 993 unibyte-display value is a coding system to encode characters |
1014 for the terminal. Characters in the range | 994 for the terminal. Characters in the range |
1015 of 160 to 255 display not as octal escapes, | 995 of 160 to 255 display not as octal escapes, |
1016 but as non-ASCII characters in this language | 996 but as non-ASCII characters in this language |
1189 | 1169 |
1190 (defcustom default-input-method nil | 1170 (defcustom default-input-method nil |
1191 "*Default input method for multilingual text (a string). | 1171 "*Default input method for multilingual text (a string). |
1192 This is the input method activated automatically by the command | 1172 This is the input method activated automatically by the command |
1193 `toggle-input-method' (\\[toggle-input-method])." | 1173 `toggle-input-method' (\\[toggle-input-method])." |
1174 :link '(custom-manual "(emacs)Input Methods") | |
1194 :group 'mule | 1175 :group 'mule |
1195 :type '(choice (const nil) string) | 1176 :type '(choice (const nil) (string |
1177 :completion-ignore-case t | |
1178 :complete-function widget-string-complete | |
1179 :completion-alist input-method-alist | |
1180 :prompt-history input-method-history)) | |
1196 :set-after '(current-language-environment)) | 1181 :set-after '(current-language-environment)) |
1197 | 1182 |
1198 (put 'input-method-function 'permanent-local t) | 1183 (put 'input-method-function 'permanent-local t) |
1199 | 1184 |
1200 (defvar input-method-history nil | 1185 (defvar input-method-history nil |
1385 (prog1 | 1370 (prog1 |
1386 (setq default-input-method current-input-method) | 1371 (setq default-input-method current-input-method) |
1387 (when (interactive-p) | 1372 (when (interactive-p) |
1388 (customize-mark-as-set 'default-input-method))))))) | 1373 (customize-mark-as-set 'default-input-method))))))) |
1389 | 1374 |
1375 (eval-when-compile (autoload 'help-buffer "help-mode")) | |
1376 | |
1390 (defun describe-input-method (input-method) | 1377 (defun describe-input-method (input-method) |
1391 "Describe input method INPUT-METHOD." | 1378 "Describe input method INPUT-METHOD." |
1392 (interactive | 1379 (interactive |
1393 (list (read-input-method-name | 1380 (list (read-input-method-name |
1394 "Describe input method (default, current choice): "))) | 1381 "Describe input method (default, current choice): "))) |
1484 The underlining goes away when you finish or abort the input method sequence. | 1471 The underlining goes away when you finish or abort the input method sequence. |
1485 See also the variable `input-method-verbose-flag'." | 1472 See also the variable `input-method-verbose-flag'." |
1486 :type 'boolean | 1473 :type 'boolean |
1487 :group 'mule) | 1474 :group 'mule) |
1488 | 1475 |
1489 (defvar input-method-activate-hook nil | 1476 (defcustom input-method-activate-hook nil |
1490 "Normal hook run just after an input method is activated. | 1477 "Normal hook run just after an input method is activated. |
1491 | 1478 |
1492 The variable `current-input-method' keeps the input method name | 1479 The variable `current-input-method' keeps the input method name |
1493 just activated.") | 1480 just activated." |
1494 | 1481 :type 'hook |
1495 (defvar input-method-inactivate-hook nil | 1482 :group 'mule) |
1483 | |
1484 (defcustom input-method-inactivate-hook nil | |
1496 "Normal hook run just after an input method is inactivated. | 1485 "Normal hook run just after an input method is inactivated. |
1497 | 1486 |
1498 The variable `current-input-method' still keeps the input method name | 1487 The variable `current-input-method' still keeps the input method name |
1499 just inactivated.") | 1488 just inactivated." |
1500 | 1489 :type 'hook |
1501 (defvar input-method-after-insert-chunk-hook nil | 1490 :group 'mule) |
1502 "Normal hook run just after an input method insert some chunk of text.") | 1491 |
1492 (defcustom input-method-after-insert-chunk-hook nil | |
1493 "Normal hook run just after an input method insert some chunk of text." | |
1494 :type 'hook | |
1495 :group 'mule) | |
1503 | 1496 |
1504 (defvar input-method-exit-on-first-char nil | 1497 (defvar input-method-exit-on-first-char nil |
1505 "This flag controls when an input method returns. | 1498 "This flag controls when an input method returns. |
1506 Usually, the input method does not return while there's a possibility | 1499 Usually, the input method does not return while there's a possibility |
1507 that it may find a different translation if a user types another key. | 1500 that it may find a different translation if a user types another key. |
1508 But, it this flag is non-nil, the input method returns as soon as | 1501 But, it this flag is non-nil, the input method returns as soon as |
1509 the current key sequence gets long enough to have some valid translation.") | 1502 the current key sequence gets long enough to have some valid translation.") |
1510 | 1503 |
1511 (defvar input-method-use-echo-area nil | 1504 (defcustom input-method-use-echo-area nil |
1512 "This flag controls how an input method shows an intermediate key sequence. | 1505 "This flag controls how an input method shows an intermediate key sequence. |
1513 Usually, the input method inserts the intermediate key sequence, | 1506 Usually, the input method inserts the intermediate key sequence, |
1514 or candidate translations corresponding to the sequence, | 1507 or candidate translations corresponding to the sequence, |
1515 at point in the current buffer. | 1508 at point in the current buffer. |
1516 But, if this flag is non-nil, it displays them in echo area instead.") | 1509 But, if this flag is non-nil, it displays them in echo area instead." |
1510 :type 'hook | |
1511 :group 'mule) | |
1517 | 1512 |
1518 (defvar input-method-exit-on-invalid-key nil | 1513 (defvar input-method-exit-on-invalid-key nil |
1519 "This flag controls the behaviour of an input method on invalid key input. | 1514 "This flag controls the behaviour of an input method on invalid key input. |
1520 Usually, when a user types a key which doesn't start any character | 1515 Usually, when a user types a key which doesn't start any character |
1521 handled by the input method, the key is handled by turning off the | 1516 handled by the input method, the key is handled by turning off the |
1522 input method temporarily. After that key, the input method is re-enabled. | 1517 input method temporarily. After that key, the input method is re-enabled. |
1523 But, if this flag is non-nil, the input method is never back on.") | 1518 But, if this flag is non-nil, the input method is never back on.") |
1524 | 1519 |
1525 | 1520 |
1526 (defvar set-language-environment-hook nil | 1521 (defcustom set-language-environment-hook nil |
1527 "Normal hook run after some language environment is set. | 1522 "Normal hook run after some language environment is set. |
1528 | 1523 |
1529 When you set some hook function here, that effect usually should not | 1524 When you set some hook function here, that effect usually should not |
1530 be inherited to another language environment. So, you had better set | 1525 be inherited to another language environment. So, you had better set |
1531 another function in `exit-language-environment-hook' (which see) to | 1526 another function in `exit-language-environment-hook' (which see) to |
1532 cancel the effect.") | 1527 cancel the effect." |
1533 | 1528 :type 'hook |
1534 (defvar exit-language-environment-hook nil | 1529 :group 'mule) |
1530 | |
1531 (defcustom exit-language-environment-hook nil | |
1535 "Normal hook run after exiting from some language environment. | 1532 "Normal hook run after exiting from some language environment. |
1536 When this hook is run, the variable `current-language-environment' | 1533 When this hook is run, the variable `current-language-environment' |
1537 is still bound to the language environment being exited. | 1534 is still bound to the language environment being exited. |
1538 | 1535 |
1539 This hook is mainly used for canceling the effect of | 1536 This hook is mainly used for canceling the effect of |
1540 `set-language-environment-hook' (which-see).") | 1537 `set-language-environment-hook' (which-see)." |
1538 :type 'hook | |
1539 :group 'mule) | |
1541 | 1540 |
1542 (put 'setup-specified-language-environment 'apropos-inhibit t) | 1541 (put 'setup-specified-language-environment 'apropos-inhibit t) |
1543 | 1542 |
1544 (defun setup-specified-language-environment () | 1543 (defun setup-specified-language-environment () |
1545 "Switch to a specified language environment." | 1544 "Switch to a specified language environment." |
1585 The default value of `buffer-file-coding-system' is nil. | 1584 The default value of `buffer-file-coding-system' is nil. |
1586 The default coding system for process I/O is nil. | 1585 The default coding system for process I/O is nil. |
1587 The default value for the command `set-terminal-coding-system' is nil. | 1586 The default value for the command `set-terminal-coding-system' is nil. |
1588 The default value for the command `set-keyboard-coding-system' is nil. | 1587 The default value for the command `set-keyboard-coding-system' is nil. |
1589 | 1588 |
1590 The order of priorities of coding categories and the coding system | 1589 The order of priorities of coding systems are as follows: |
1591 bound to each category are as follows | 1590 utf-8 |
1592 coding category coding system | 1591 iso-2022-7bit |
1593 -------------------------------------------------- | 1592 iso-latin-1 |
1594 coding-category-iso-8-1 iso-latin-1 | 1593 iso-2022-7bit-lock |
1595 coding-category-iso-8-2 iso-latin-1 | 1594 iso-2022-8bit-ss2 |
1596 coding-category-utf-8 mule-utf-8 | 1595 emacs-mule |
1597 coding-category-utf-16-be mule-utf-16be-with-signature | 1596 raw-text" |
1598 coding-category-utf-16-le mule-utf-16le-with-signature | |
1599 coding-category-iso-7-tight iso-2022-jp | |
1600 coding-category-iso-7 iso-2022-7bit | |
1601 coding-category-iso-7-else iso-2022-7bit-lock | |
1602 coding-category-iso-8-else iso-2022-8bit-ss2 | |
1603 coding-category-emacs-mule emacs-mule | |
1604 coding-category-raw-text raw-text | |
1605 coding-category-sjis japanese-shift-jis | |
1606 coding-category-big5 chinese-big5 | |
1607 coding-category-ccl nil | |
1608 coding-category-binary no-conversion" | |
1609 (interactive) | 1597 (interactive) |
1610 ;; This function formerly set default-enable-multibyte-characters to t, | 1598 ;; This function formerly set default-enable-multibyte-characters to t, |
1611 ;; but that is incorrect. It should not alter the unibyte/multibyte choice. | 1599 ;; but that is incorrect. It should not alter the unibyte/multibyte choice. |
1612 | 1600 |
1613 (setq coding-category-iso-7-tight 'iso-2022-jp | 1601 (set-coding-system-priority |
1614 coding-category-iso-7 'iso-2022-7bit | 1602 'utf-8 |
1615 coding-category-iso-8-1 'iso-latin-1 | 1603 'iso-2022-7bit |
1616 coding-category-iso-8-2 'iso-latin-1 | 1604 'iso-latin-1 |
1617 coding-category-iso-7-else 'iso-2022-7bit-lock | 1605 'iso-2022-7bit-lock |
1618 coding-category-iso-8-else 'iso-2022-8bit-ss2 | 1606 'iso-2022-8bit-ss2 |
1619 coding-category-emacs-mule 'emacs-mule | 1607 'emacs-mule |
1620 coding-category-raw-text 'raw-text | 1608 'raw-text) |
1621 coding-category-sjis 'japanese-shift-jis | |
1622 coding-category-big5 'chinese-big5 | |
1623 coding-category-utf-16-be 'mule-utf-16be-with-signature | |
1624 coding-category-utf-16-le 'mule-utf-16le-with-signature | |
1625 coding-category-utf-8 'mule-utf-8 | |
1626 coding-category-ccl nil | |
1627 coding-category-binary 'no-conversion) | |
1628 | |
1629 (set-coding-priority | |
1630 '(coding-category-iso-8-1 | |
1631 coding-category-iso-8-2 | |
1632 coding-category-utf-8 | |
1633 coding-category-utf-16-be | |
1634 coding-category-utf-16-le | |
1635 coding-category-iso-7-tight | |
1636 coding-category-iso-7 | |
1637 coding-category-iso-7-else | |
1638 coding-category-iso-8-else | |
1639 coding-category-emacs-mule | |
1640 coding-category-raw-text | |
1641 coding-category-sjis | |
1642 coding-category-big5 | |
1643 coding-category-ccl | |
1644 coding-category-binary)) | |
1645 | |
1646 (update-coding-systems-internal) | |
1647 | 1609 |
1648 (set-default-coding-systems nil) | 1610 (set-default-coding-systems nil) |
1649 (setq default-sendmail-coding-system 'iso-latin-1) | 1611 (setq default-sendmail-coding-system 'iso-latin-1) |
1650 (setq default-file-name-coding-system 'iso-latin-1) | 1612 (setq default-file-name-coding-system 'iso-latin-1) |
1651 ;; Preserve eol-type from existing default-process-coding-systems. | 1613 ;; Preserve eol-type from existing default-process-coding-systems. |
1672 ;; The terminal still supports the same coding system | 1634 ;; The terminal still supports the same coding system |
1673 ;; that it supported a minute ago. | 1635 ;; that it supported a minute ago. |
1674 ;; (set-terminal-coding-system-internal nil) | 1636 ;; (set-terminal-coding-system-internal nil) |
1675 ;; (set-keyboard-coding-system-internal nil) | 1637 ;; (set-keyboard-coding-system-internal nil) |
1676 | 1638 |
1677 (setq nonascii-translation-table nil | 1639 (set-unibyte-charset 'iso-8859-1)) |
1678 nonascii-insert-offset 0)) | |
1679 | 1640 |
1680 (reset-language-environment) | 1641 (reset-language-environment) |
1681 | 1642 |
1682 (defun set-display-table-and-terminal-coding-system (language-name) | 1643 (defun set-display-table-and-terminal-coding-system (language-name) |
1683 "Set up the display table and terminal coding system for LANGUAGE-NAME." | 1644 "Set up the display table and terminal coding system for LANGUAGE-NAME." |
1734 (setq default-input-method input-method) | 1695 (setq default-input-method input-method) |
1735 (if input-method-history | 1696 (if input-method-history |
1736 (setq input-method-history | 1697 (setq input-method-history |
1737 (cons input-method | 1698 (cons input-method |
1738 (delete input-method input-method-history)))))) | 1699 (delete input-method input-method-history)))))) |
1739 (let ((nonascii (get-language-info language-name 'nonascii-translation)) | 1700 |
1740 (dos-table | 1701 ;; Put higher priorities to such charsets that are supported by the |
1741 (if (eq window-system 'pc) | 1702 ;; coding systems of higher priorities in this environment. |
1742 (intern | 1703 (let ((charsets nil)) |
1743 (format "cp%d-nonascii-translation-table" dos-codepage))))) | 1704 (dolist (coding (get-language-info language-name 'coding-priority)) |
1744 (cond | 1705 (setq charsets (append charsets (coding-system-charset-list coding)))) |
1745 ((char-table-p nonascii) | 1706 (if charsets |
1746 (setq nonascii-translation-table nonascii)) | 1707 (apply 'set-charset-priority charsets))) |
1747 ((and (eq window-system 'pc) (boundp dos-table)) | 1708 |
1748 ;; DOS terminals' default is to use a special non-ASCII translation | 1709 ;; Note: For DOS, we assumed that the charset cpXXX is already |
1749 ;; table as appropriate for the installed codepage. | 1710 ;; defined. |
1750 (setq nonascii-translation-table (symbol-value dos-table))) | 1711 (let ((nonascii (get-language-info language-name 'nonascii-translation))) |
1751 ((charsetp nonascii) | 1712 (if (eq window-system 'pc) |
1752 (setq nonascii-insert-offset (- (make-char nonascii) 128))))) | 1713 (setq nonascii (intern "cp%d" dos-codepage))) |
1714 (or (and (charsetp nonascii) | |
1715 (= (charset-dimension nonascii) 1)) | |
1716 (setq nonascii 'iso-8859-1)) | |
1717 (set-unibyte-charset nonascii)) | |
1753 | 1718 |
1754 ;; Unibyte setups if necessary. | 1719 ;; Unibyte setups if necessary. |
1755 (unless default-enable-multibyte-characters | 1720 (or default-enable-multibyte-characters |
1756 ;; Syntax and case table. | 1721 (set-display-table-and-terminal-coding-system language-name)) |
1757 (let ((syntax (get-language-info language-name 'unibyte-syntax))) | |
1758 (if syntax | |
1759 (let ((set-case-syntax-set-multibyte nil)) | |
1760 (load syntax nil t)) | |
1761 ;; No information for syntax and case. Reset to the defaults. | |
1762 (let ((syntax-table (standard-syntax-table)) | |
1763 (case-table (standard-case-table)) | |
1764 (ch (if (eq window-system 'pc) 128 160))) | |
1765 (while (< ch 256) | |
1766 (modify-syntax-entry ch " " syntax-table) | |
1767 (aset case-table ch ch) | |
1768 (setq ch (1+ ch))) | |
1769 (set-char-table-extra-slot case-table 0 nil) | |
1770 (set-char-table-extra-slot case-table 1 nil) | |
1771 (set-char-table-extra-slot case-table 2 nil)) | |
1772 (set-standard-case-table (standard-case-table)) | |
1773 (let ((list (buffer-list))) | |
1774 (while list | |
1775 (with-current-buffer (car list) | |
1776 (set-case-table (standard-case-table))) | |
1777 (setq list (cdr list)))))) | |
1778 (set-display-table-and-terminal-coding-system language-name)) | |
1779 | 1722 |
1780 (let ((required-features (get-language-info language-name 'features))) | 1723 (let ((required-features (get-language-info language-name 'features))) |
1781 (while required-features | 1724 (while required-features |
1782 (require (car required-features)) | 1725 (require (car required-features)) |
1783 (setq required-features (cdr required-features)))) | 1726 (setq required-features (cdr required-features)))) |
1784 (let ((func (get-language-info language-name 'setup-function))) | 1727 (let ((func (get-language-info language-name 'setup-function))) |
1785 (if (functionp func) | 1728 (if (functionp func) |
1786 (funcall func))) | 1729 (funcall func))) |
1787 (run-hooks 'set-language-environment-hook) | 1730 (run-hooks 'set-language-environment-hook) |
1788 (force-mode-line-update t)) | 1731 (force-mode-line-update t)) |
1732 | |
1733 (define-widget 'charset 'symbol | |
1734 "An Emacs charset." | |
1735 :tag "Charset" | |
1736 :complete-function (lambda () | |
1737 (interactive) | |
1738 (lisp-complete-symbol 'charsetp)) | |
1739 :completion-ignore-case t | |
1740 :value 'ascii | |
1741 :validate (lambda (widget) | |
1742 (unless (charsetp (widget-value widget)) | |
1743 (widget-put widget :error (format "Invalid charset: %S" | |
1744 (widget-value widget))) | |
1745 widget)) | |
1746 :prompt-history 'charset-history) | |
1747 | |
1748 (defcustom language-info-custom-alist nil | |
1749 "Customizations of language environment parameters. | |
1750 Value is an alist with elements like those of `language-info-alist'. | |
1751 These are used to set values in `language-info-alist' which replace | |
1752 the defaults. A typical use is replacing the default input method for | |
1753 the environment. Use \\[describe-language-environment] to find the environment's settings. | |
1754 | |
1755 This option is intended for use at startup. Removing items doesn't | |
1756 remove them from the language info until you next restart Emacs. | |
1757 | |
1758 Setting this variable directly does not take effect. See | |
1759 `set-language-info-alist' for use in programs." | |
1760 :group 'mule | |
1761 :version "22.1" | |
1762 :set (lambda (s v) | |
1763 (custom-set-default s v) | |
1764 ;; Can't do this before language environments are set up. | |
1765 (when v | |
1766 ;; modify language-info-alist | |
1767 (dolist (elt v) | |
1768 (set-language-info-alist (car elt) (cdr elt))) | |
1769 ;; re-set the environment in case its parameters changed | |
1770 (set-language-environment current-language-environment))) | |
1771 :type `(alist | |
1772 :key-type (string :tag "Language environment" | |
1773 :completion-ignore-case t | |
1774 :complete-function widget-string-complete | |
1775 :completion-alist language-info-alist) | |
1776 :value-type | |
1777 (alist :key-type symbol | |
1778 :options ((documentation string) | |
1779 (charset (repeat charset)) | |
1780 (sample-text string) | |
1781 (setup-function function) | |
1782 (exit-function function) | |
1783 (coding-system (repeat coding-system)) | |
1784 (coding-priority (repeat coding-system)) | |
1785 (nonascii-translation charset) | |
1786 (input-method | |
1787 (string | |
1788 :completion-ignore-case t | |
1789 :complete-function widget-string-complete | |
1790 :completion-alist input-method-alist | |
1791 :prompt-history input-method-history)) | |
1792 (features (repeat symbol)) | |
1793 (unibyte-display coding-system))))) | |
1789 | 1794 |
1790 (defun standard-display-european-internal () | 1795 (defun standard-display-european-internal () |
1791 ;; Actually set up direct output of non-ASCII characters. | 1796 ;; Actually set up direct output of non-ASCII characters. |
1792 (standard-display-8bit (if (eq window-system 'pc) 128 160) 255) | 1797 (standard-display-8bit (if (eq window-system 'pc) 128 160) 255) |
1793 ;; Unibyte Emacs on MS-DOS wants to display all 8-bit characters with | 1798 ;; Unibyte Emacs on MS-DOS wants to display all 8-bit characters with |
1816 | 1821 |
1817 The optional arg EOL-TYPE specifies the eol-type of the default value | 1822 The optional arg EOL-TYPE specifies the eol-type of the default value |
1818 of `buffer-file-coding-system' set by this function." | 1823 of `buffer-file-coding-system' set by this function." |
1819 (let* ((priority (get-language-info language-name 'coding-priority)) | 1824 (let* ((priority (get-language-info language-name 'coding-priority)) |
1820 (default-coding (car priority))) | 1825 (default-coding (car priority))) |
1821 (if priority | 1826 (when priority |
1822 (let ((categories (mapcar 'coding-system-category priority))) | 1827 (set-default-coding-systems |
1823 (set-default-coding-systems | 1828 (if (memq eol-type '(0 1 2 unix dos mac)) |
1824 (if (memq eol-type '(0 1 2 unix dos mac)) | 1829 (coding-system-change-eol-conversion default-coding eol-type) |
1825 (coding-system-change-eol-conversion default-coding eol-type) | 1830 default-coding)) |
1826 default-coding)) | 1831 (setq default-sendmail-coding-system default-coding) |
1827 (setq default-sendmail-coding-system default-coding) | 1832 (apply 'set-coding-system-priority priority)))) |
1828 (set-coding-priority categories) | |
1829 (while priority | |
1830 (set (car categories) (car priority)) | |
1831 (setq priority (cdr priority) categories (cdr categories))) | |
1832 (update-coding-systems-internal))))) | |
1833 | 1833 |
1834 (defsubst princ-list (&rest args) | 1834 (defsubst princ-list (&rest args) |
1835 "Print all arguments with `princ', then print \"\n\"." | 1835 "Print all arguments with `princ', then print \"\n\"." |
1836 (while args (princ (car args)) (setq args (cdr args))) | 1836 (while args (princ (car args)) (setq args (cdr args))) |
1837 (princ "\n")) | 1837 (princ "\n")) |
1891 (insert " (default, " input-method ")") | 1891 (insert " (default, " input-method ")") |
1892 (setq input-method (assoc input-method input-method-alist)) | 1892 (setq input-method (assoc input-method input-method-alist)) |
1893 (setq l (cons input-method (delete input-method l)))) | 1893 (setq l (cons input-method (delete input-method l)))) |
1894 (insert ":\n") | 1894 (insert ":\n") |
1895 (while l | 1895 (while l |
1896 (when (string= language-name (nth 1 (car l))) | 1896 (when (eq t (compare-strings language-name nil nil |
1897 (nth 1 (car l)) nil nil t)) | |
1897 (insert " " (car (car l))) | 1898 (insert " " (car (car l))) |
1898 (search-backward (car (car l))) | 1899 (search-backward (car (car l))) |
1899 (help-xref-button 0 'help-input-method (car (car l))) | 1900 (help-xref-button 0 'help-input-method (car (car l))) |
1900 (goto-char (point-max)) | 1901 (goto-char (point-max)) |
1901 (insert " (\"" | 1902 (insert " (\"" |
1929 (insert " (`" | 1930 (insert " (`" |
1930 (coding-system-mnemonic (car l)) | 1931 (coding-system-mnemonic (car l)) |
1931 "' in mode line):\n\t" | 1932 "' in mode line):\n\t" |
1932 (coding-system-doc-string (car l)) | 1933 (coding-system-doc-string (car l)) |
1933 "\n") | 1934 "\n") |
1934 (let ((aliases (coding-system-get (car l) | 1935 (let ((aliases (coding-system-aliases (car l)))) |
1935 'alias-coding-systems))) | |
1936 (when aliases | 1936 (when aliases |
1937 (insert "\t(alias:") | 1937 (insert "\t(alias:") |
1938 (while aliases | 1938 (while aliases |
1939 (insert " " (symbol-name (car aliases))) | 1939 (insert " " (symbol-name (car aliases))) |
1940 (setq aliases (cdr aliases))) | 1940 (setq aliases (cdr aliases))) |
2061 ("pt" . "Latin-1") ; Portuguese | 2061 ("pt" . "Latin-1") ; Portuguese |
2062 ; qu Quechua | 2062 ; qu Quechua |
2063 ("rm" . "Latin-1") ; Rhaeto-Romanic | 2063 ("rm" . "Latin-1") ; Rhaeto-Romanic |
2064 ; rn Kirundi | 2064 ; rn Kirundi |
2065 ("ro" . "Romanian") | 2065 ("ro" . "Romanian") |
2066 ("ru.*[_.]koi8" . "Russian") | 2066 ("ru.*[_.]koi8\\(?:-r\\)?\\'" . "Cyrillic-KOI8") ; Russian |
2067 ("ru" . "Cyrillic-ISO") ; Russian | 2067 ("ru" . "Cyrillic-ISO") ; Russian |
2068 ; rw Kinyarwanda | 2068 ; rw Kinyarwanda |
2069 ("sa" . "Devanagari") ; Sanskrit | 2069 ("sa" . "Devanagari") ; Sanskrit |
2070 ; sd Sindhi | 2070 ; sd Sindhi |
2071 ; se Northern Sami | 2071 ; se Northern Sami |
2077 ; sm Samoan | 2077 ; sm Samoan |
2078 ; sn Shona | 2078 ; sn Shona |
2079 ; so Somali | 2079 ; so Somali |
2080 ("sq" . "Latin-1") ; Albanian | 2080 ("sq" . "Latin-1") ; Albanian |
2081 ("sr" . "Latin-2") ; Serbian (Latin alphabet) | 2081 ("sr" . "Latin-2") ; Serbian (Latin alphabet) |
2082 ("sr_YU@cyrillic" . "Cyrillic-ISO") ; per glibc | 2082 ("sr.*@cyrillic" . "Cyrillic-ISO") ; per glibc |
2083 ; ss Siswati | 2083 ; ss Siswati |
2084 ; st Sesotho | 2084 ; st Sesotho |
2085 ; su Sundanese | 2085 ; su Sundanese |
2086 ("sv" . "Swedish") ; Swedish | 2086 ("sv" . "Swedish") ; Swedish |
2087 ("sw" . "Latin-1") ; Swahili | 2087 ("sw" . "Latin-1") ; Swahili |
2110 ("yi" . "Windows-1255") ; Yiddish | 2110 ("yi" . "Windows-1255") ; Yiddish |
2111 ; yo Yoruba | 2111 ; yo Yoruba |
2112 ; za Zhuang | 2112 ; za Zhuang |
2113 | 2113 |
2114 ; glibc: | 2114 ; glibc: |
2115 ; zh_CN.GB18030/GB18030 \ | |
2116 ; zh_CN.GBK/GBK \ | |
2117 ; zh_HK/BIG5-HKSCS \ | 2115 ; zh_HK/BIG5-HKSCS \ |
2118 | 2116 |
2119 ("zh.*[._]big5" . "Chinese-BIG5") | 2117 ("zh.*[._]big5" . "Chinese-BIG5") |
2120 ("zh.*[._]gbk" . nil) ; Solaris 2.7; has gbk-0 as well as GB 2312.1980-0 | 2118 ("zh.*[._].gb18030" . "Chinese-GB18030") ; zh_CN.GB18030/GB18030 in glibc |
2119 ("zh.*[._].gbk" . "Chinese-GBK") | |
2120 ;; glibc has zh_TW.EUC-TW, with zh_TW defaulting to Big5 | |
2121 ("zh_tw" . "Chinese-CNS") ; glibc uses big5 | 2121 ("zh_tw" . "Chinese-CNS") ; glibc uses big5 |
2122 ("zh_tw[._]euc-tw" . "Chinese-EUC-TW") | 2122 ("zh_tw[._]euc-tw" . "Chinese-EUC-TW") |
2123 ("zh" . "Chinese-GB") | 2123 ("zh" . "Chinese-GB") |
2124 ; zu Zulu | 2124 ; zu Zulu |
2125 | 2125 |
2154 (".*8859[-_]?4\\>" . "Latin-4") | 2154 (".*8859[-_]?4\\>" . "Latin-4") |
2155 (".*8859[-_]?9\\>" . "Latin-5") | 2155 (".*8859[-_]?9\\>" . "Latin-5") |
2156 (".*8859[-_]?14\\>" . "Latin-8") | 2156 (".*8859[-_]?14\\>" . "Latin-8") |
2157 (".*8859[-_]?15\\>" . "Latin-9") | 2157 (".*8859[-_]?15\\>" . "Latin-9") |
2158 (".*utf\\(-?8\\)\\>" . "UTF-8") | 2158 (".*utf\\(-?8\\)\\>" . "UTF-8") |
2159 ;; utf-8@euro exists, so put this last. (@euro really specifies | 2159 ;; @euro actually indicates the monetary component, but it |
2160 ;; the currency, rather than the charset.) | 2160 ;; probably implies a Latin-9 codeset component. |
2161 ;; utf-8@euro exists, so put this last. | |
2161 (".*@euro\\>" . "Latin-9"))) | 2162 (".*@euro\\>" . "Latin-9"))) |
2162 "List of pairs of locale regexps and charset language names. | 2163 "List of pairs of locale regexps and charset language names. |
2163 The first element whose locale regexp matches the start of a downcased locale | 2164 The first element whose locale regexp matches the start of a downcased locale |
2164 specifies the language name whose charsets corresponds to that locale. | 2165 specifies the language name whose charsets corresponds to that locale. |
2165 This language name is used if its charsets disagree with the charsets of | 2166 This language name is used if its charsets disagree with the charsets of |
2186 (if (string-match (concat "\\`\\(?:" (car (car alist)) "\\)") key) | 2187 (if (string-match (concat "\\`\\(?:" (car (car alist)) "\\)") key) |
2187 (setq element (car alist))) | 2188 (setq element (car alist))) |
2188 (setq alist (cdr alist))) | 2189 (setq alist (cdr alist))) |
2189 (cdr element))) | 2190 (cdr element))) |
2190 | 2191 |
2192 (defun locale-charset-match-p (charset1 charset2) | |
2193 "Whether charset names (strings) CHARSET1 and CHARSET2 are equivalent. | |
2194 Matching is done ignoring case and any hyphens and underscores in the | |
2195 names. E.g. `ISO_8859-1' and `iso88591' both match `iso-8859-1'." | |
2196 (setq charset1 (replace-regexp-in-string "[-_]" "" charset1)) | |
2197 (setq charset2 (replace-regexp-in-string "[-_]" "" charset2)) | |
2198 (eq t (compare-strings charset1 nil nil charset2 nil nil t))) | |
2199 | |
2191 (defun set-locale-environment (&optional locale-name) | 2200 (defun set-locale-environment (&optional locale-name) |
2192 "Set up multi-lingual environment for using LOCALE-NAME. | 2201 "Set up multi-lingual environment for using LOCALE-NAME. |
2193 This sets the language environment, the coding system priority, | 2202 This sets the language environment, the coding system priority, |
2194 the default input method and sometimes other things. | 2203 the default input method and sometimes other things. |
2195 | 2204 |
2196 LOCALE-NAME should be a string | 2205 LOCALE-NAME should be a string which is the name of a locale supported |
2197 which is the name of a locale supported by the system; | 2206 by the system; often it is of the form xx_XX.CODE, where xx is a |
2198 often it is of the form xx_XX.CODE, where xx is a language, | 2207 language, XX is a country, and CODE specifies a character set and |
2199 XX is a country, and CODE specifies a character set and coding system. | 2208 coding system. For example, the locale name \"ja_JP.EUC\" might name |
2200 For example, the locale name \"ja_JP.EUC\" might name a locale | 2209 a locale for Japanese in Japan using the `japanese-iso-8bit' |
2201 for Japanese in Japan using the `japanese-iso-8bit' coding-system. | 2210 coding-system. The name may also have a modifier suffix, e.g. `@euro' |
2211 or `@cyrillic'. | |
2202 | 2212 |
2203 If LOCALE-NAME is nil, its value is taken from the environment | 2213 If LOCALE-NAME is nil, its value is taken from the environment |
2204 variables LC_ALL, LC_CTYPE and LANG (the first one that is set). | 2214 variables LC_ALL, LC_CTYPE and LANG (the first one that is set). |
2205 | 2215 |
2206 The locale names supported by your system can typically be found in a | 2216 The locale names supported by your system can typically be found in a |
2297 (setq locale-coding-system | 2307 (setq locale-coding-system |
2298 (car (get-language-info language-name 'coding-priority)))) | 2308 (car (get-language-info language-name 'coding-priority)))) |
2299 | 2309 |
2300 (when coding-system | 2310 (when coding-system |
2301 (prefer-coding-system coding-system) | 2311 (prefer-coding-system coding-system) |
2302 (setq locale-coding-system coding-system)))) | 2312 (setq locale-coding-system coding-system)) |
2313 (when (get-language-info current-language-environment 'coding-priority) | |
2314 (let ((codeset (locale-info 'codeset)) | |
2315 (coding-system (car (coding-system-priority-list)))) | |
2316 (when codeset | |
2317 (let ((cs (coding-system-aliases coding-system)) | |
2318 result) | |
2319 (while (and cs (not result)) | |
2320 (setq result | |
2321 (locale-charset-match-p (symbol-name (pop cs)) | |
2322 (locale-info 'codeset)))) | |
2323 (unless result | |
2324 (message "Warning: Default coding system `%s' disagrees with | |
2325 system codeset `%s' for this locale." coding-system codeset)))))))) | |
2303 | 2326 |
2304 ;; Default to A4 paper if we're not in a C, POSIX or US locale. | 2327 ;; Default to A4 paper if we're not in a C, POSIX or US locale. |
2305 ;; (See comments in Flocale_info.) | 2328 ;; (See comments in Flocale_info.) |
2306 (let ((locale locale) | 2329 (let ((locale locale) |
2307 (paper (locale-info 'paper))) | 2330 (paper (locale-info 'paper))) |
2325 (".._pr" . letter) | 2348 (".._pr" . letter) |
2326 (".._ca" . letter))) | 2349 (".._ca" . letter))) |
2327 'a4)))))) | 2350 'a4)))))) |
2328 nil) | 2351 nil) |
2329 | 2352 |
2330 ;;; Charset property | |
2331 | |
2332 (defun get-charset-property (charset propname) | |
2333 "Return the value of CHARSET's PROPNAME property. | |
2334 This is the last value stored with | |
2335 (put-charset-property CHARSET PROPNAME VALUE)." | |
2336 (and (not (eq charset 'composition)) | |
2337 (plist-get (charset-plist charset) propname))) | |
2338 | |
2339 (defun put-charset-property (charset propname value) | |
2340 "Store CHARSETS's PROPNAME property with value VALUE. | |
2341 It can be retrieved with `(get-charset-property CHARSET PROPNAME)'." | |
2342 (or (eq charset 'composition) | |
2343 (set-charset-plist charset | |
2344 (plist-put (charset-plist charset) propname value)))) | |
2345 | |
2346 ;;; Character code property | 2353 ;;; Character code property |
2347 (put 'char-code-property-table 'char-table-extra-slots 0) | 2354 (put 'char-code-property-table 'char-table-extra-slots 0) |
2348 | 2355 |
2349 (defvar char-code-property-table | 2356 (defvar char-code-property-table |
2350 (make-char-table 'char-code-property-table) | 2357 (make-char-table 'char-code-property-table) |
2384 | 2391 |
2385 (defun encoded-string-description (str coding-system) | 2392 (defun encoded-string-description (str coding-system) |
2386 "Return a pretty description of STR that is encoded by CODING-SYSTEM." | 2393 "Return a pretty description of STR that is encoded by CODING-SYSTEM." |
2387 (setq str (string-as-unibyte str)) | 2394 (setq str (string-as-unibyte str)) |
2388 (mapconcat | 2395 (mapconcat |
2389 (if (and coding-system (eq (coding-system-type coding-system) 2)) | 2396 (if (and coding-system (eq (coding-system-type coding-system) 'iso-2022)) |
2390 ;; Try to get a pretty description for ISO 2022 escape sequences. | 2397 ;; Try to get a pretty description for ISO 2022 escape sequences. |
2391 (function (lambda (x) (or (cdr (assq x iso-2022-control-alist)) | 2398 (function (lambda (x) (or (cdr (assq x iso-2022-control-alist)) |
2392 (format "%02X" x)))) | 2399 (format "%02X" x)))) |
2393 (function (lambda (x) (format "0x%02X" x)))) | 2400 (function (lambda (x) (format "0x%02X" x)))) |
2394 str " ")) | 2401 str " ")) |
2395 | 2402 |
2396 (defun encode-coding-char (char coding-system) | 2403 (defun encode-coding-char (char coding-system) |
2397 "Encode CHAR by CODING-SYSTEM and return the resulting string. | 2404 "Encode CHAR by CODING-SYSTEM and return the resulting string. |
2398 If CODING-SYSTEM can't safely encode CHAR, return nil." | 2405 If CODING-SYSTEM can't safely encode CHAR, return nil." |
2399 (let ((str1 (string-as-multibyte (char-to-string char))) | 2406 (let ((str1 (string-as-multibyte (string char))) |
2400 (str2 (string-as-multibyte (make-string 2 char))) | 2407 (str2 (string-as-multibyte (string char char))) |
2401 (safe-chars (and coding-system | |
2402 (coding-system-get coding-system 'safe-chars))) | |
2403 (charset (char-charset char)) | |
2404 enc1 enc2 i1 i2) | 2408 enc1 enc2 i1 i2) |
2405 (when (or (eq safe-chars t) | 2409 (when (memq (coding-system-base coding-system) |
2406 (eq charset 'ascii) | 2410 (find-coding-systems-string str1)) |
2407 (and safe-chars (aref safe-chars char))) | |
2408 ;; We must find the encoded string of CHAR. But, just encoding | 2411 ;; We must find the encoded string of CHAR. But, just encoding |
2409 ;; CHAR will put extra control sequences (usually to designate | 2412 ;; CHAR will put extra control sequences (usually to designate |
2410 ;; ASCII charaset) at the tail if type of CODING is ISO 2022. | 2413 ;; ASCII charset) at the tail if type of CODING is ISO 2022. |
2411 ;; To exclude such tailing bytes, we at first encode one-char | 2414 ;; To exclude such tailing bytes, we at first encode one-char |
2412 ;; string and two-char string, then check how many bytes at the | 2415 ;; string and two-char string, then check how many bytes at the |
2413 ;; tail of both encoded strings are the same. | 2416 ;; tail of both encoded strings are the same. |
2414 | 2417 |
2415 (setq enc1 (encode-coding-string str1 coding-system) | 2418 (setq enc1 (encode-coding-string str1 coding-system) |
2422 ;; Now (substring enc1 i1) and (substring enc2 i2) are the same, | 2425 ;; Now (substring enc1 i1) and (substring enc2 i2) are the same, |
2423 ;; and they are the extra control sequences at the tail to | 2426 ;; and they are the extra control sequences at the tail to |
2424 ;; exclude. | 2427 ;; exclude. |
2425 (substring enc2 0 i2)))) | 2428 (substring enc2 0 i2)))) |
2426 | 2429 |
2430 ;; Backwards compatibility. These might be better with :init-value t, | |
2431 ;; but that breaks loadup. | |
2432 (define-minor-mode unify-8859-on-encoding-mode | |
2433 "Obsolete." | |
2434 :group 'mule | |
2435 :global t) | |
2436 (define-minor-mode unify-8859-on-decoding-mode | |
2437 "Obsolete." | |
2438 :group 'mule | |
2439 :global t) | |
2440 | |
2441 (defvar nonascii-insert-offset 0 "This variable is obsolete.") | |
2442 (defvar nonascii-translation-table nil "This variable is obsolete.") | |
2443 | |
2427 | 2444 |
2428 ;;; mule-cmds.el ends here | 2445 ;;; mule-cmds.el ends here |