aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Love2002-07-24 22:20:49 +0000
committerDave Love2002-07-24 22:20:49 +0000
commitd37ef0f64ee94a37a9ff959870699b84e8ae9773 (patch)
tree1d134a2bccd855f55a76811709d768efbef17d32
parent1fba791966c488f664d8989cc0ec661c8eef1ed3 (diff)
downloademacs-d37ef0f64ee94a37a9ff959870699b84e8ae9773.tar.gz
emacs-d37ef0f64ee94a37a9ff959870699b84e8ae9773.zip
Doc fixes.
(unencodable-char-position): New. (select-safe-coding-system): Use it to indicate problematic characters and add extra explanation. Avoid checking auto-coding for compressed files. (leim-list-header): Add coding cookie. (input-method-verbose-flag): Modify :type. (locale-language-names): Add bs, wa. Modify cy.
-rw-r--r--lisp/international/mule-cmds.el218
1 files changed, 141 insertions, 77 deletions
diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el
index f5820af3fc2..3d30d36a993 100644
--- a/lisp/international/mule-cmds.el
+++ b/lisp/international/mule-cmds.el
@@ -269,7 +269,7 @@ wrong, use this command again to toggle back to the right mode."
269 cmd (key-binding keyseq t)) 269 cmd (key-binding keyseq t))
270 (not (eq cmd 'universal-argument-other-key))) 270 (not (eq cmd 'universal-argument-other-key)))
271 (let ((current-prefix-arg prefix-arg) 271 (let ((current-prefix-arg prefix-arg)
272 ;; Have to bind `last-command-char' here so that 272 ;; Have to bind `last-command-char' here so that
273 ;; `digit-argument', for isntance, can compute the 273 ;; `digit-argument', for isntance, can compute the
274 ;; prefix arg. 274 ;; prefix arg.
275 (last-command-char (aref keyseq 0))) 275 (last-command-char (aref keyseq 0)))
@@ -297,7 +297,7 @@ This sets the following coding systems:
297 o coding system of a newly created buffer 297 o coding system of a newly created buffer
298 o default coding system for subprocess I/O 298 o default coding system for subprocess I/O
299This also sets the following values: 299This also sets the following values:
300 o default value used as file-name-coding-system for converting file names. 300 o default value used as `file-name-coding-system' for converting file names.
301 o default value for the command `set-terminal-coding-system' (not on MSDOS) 301 o default value for the command `set-terminal-coding-system' (not on MSDOS)
302 o default value for the command `set-keyboard-coding-system'." 302 o default value for the command `set-keyboard-coding-system'."
303 (check-coding-system coding-system) 303 (check-coding-system coding-system)
@@ -426,6 +426,7 @@ non-nil, it is used to sort CODINGS in the different way than above."
426 426
427(defun find-coding-systems-region (from to) 427(defun find-coding-systems-region (from to)
428 "Return a list of proper coding systems to encode a text between FROM and TO. 428 "Return a list of proper coding systems to encode a text between FROM and TO.
429If FROM is a string, find coding systems in that instead of the buffer.
429All coding systems in the list can safely encode any multibyte characters 430All coding systems in the list can safely encode any multibyte characters
430in the text. 431in the text.
431 432
@@ -552,8 +553,15 @@ proper one is suggested as the default.
552The list of `buffer-file-coding-system' of the current buffer and the 553The list of `buffer-file-coding-system' of the current buffer and the
553most preferred coding system (if it corresponds to a MIME charset) is 554most preferred coding system (if it corresponds to a MIME charset) is
554treated as the default coding system list. Among them, the first one 555treated as the default coding system list. Among them, the first one
555that safely encodes the text is silently selected and returned without 556that safely encodes the text is normally selected silently and
556any user interaction. See also the command `prefer-coding-system'. 557returned without any user interaction. See also the command
558`prefer-coding-system'.
559
560However, the user is queried if the chosen coding system is
561inconsistent with what would be selected by `set-auto-coding' from
562coding cookies &c. if the contents of the region were read from a
563file. (That could lead to data corruption in a file subsequently
564re-visited and edited.)
557 565
558Optional 3rd arg DEFAULT-CODING-SYSTEM specifies a coding system or a 566Optional 3rd arg DEFAULT-CODING-SYSTEM specifies a coding system or a
559list of coding systems to be prepended to the default coding system 567list of coding systems to be prepended to the default coding system
@@ -653,63 +661,72 @@ and TO is ignored."
653 ;; Make sure the offending buffer is displayed. 661 ;; Make sure the offending buffer is displayed.
654 (or (stringp from) 662 (or (stringp from)
655 (pop-to-buffer bufname)) 663 (pop-to-buffer bufname))
656 ;; Then ask users to select one form CODINGS. 664 (save-excursion
657 (unwind-protect 665 (goto-char (unencodable-char-position
658 (save-window-excursion 666 from to (mapcar #'car default-coding-system)))
659 (with-output-to-temp-buffer "*Warning*" 667 ;; Then ask users to select one form CODINGS.
660 (save-excursion 668 (unwind-protect
661 (set-buffer standard-output) 669 (save-window-excursion
662 (if (not default-coding-system) 670 (with-output-to-temp-buffer "*Warning*"
663 (insert "No default coding systems to try for " 671 (save-excursion
664 (if (stringp from) 672 (set-buffer standard-output)
665 (format "string \"%s\"." from) 673 (if (not default-coding-system)
666 (format "buffer `%s'." bufname))) 674 (insert "No default coding systems to try for "
667 (insert 675 (if (stringp from)
668 "These default coding systems were tried to encode" 676 (format "string \"%s\"." from)
669 (if (stringp from) 677 (format "buffer `%s'." bufname)))
670 (concat " \"" (if (> (length from) 10) 678 (insert
671 (concat (substring from 0 10) "...\"") 679 "These default coding systems were tried to encode"
672 (concat from "\""))) 680 (if (stringp from)
673 (format " text\nin the buffer `%s'" bufname)) 681 (concat " \"" (if (> (length from) 10)
674 ":\n") 682 (concat (substring from 0 10) "...\"")
683 (concat from "\"")))
684 (format " text\nin the buffer `%s'" bufname))
685 ":\n")
686 (let ((pos (point))
687 (fill-prefix " "))
688 (mapcar (function (lambda (x)
689 (princ " ") (princ (car x))))
690 default-coding-system)
691 (insert "\n")
692 (fill-region-as-paragraph pos (point)))
693 (if (consp coding-system)
694 (insert (format "%s safely encodes the target text,\n"
695 (car coding-system))
696 "\
697but it is not recommended for encoding text in this context,
698e.g., for sending an email message.\n")
699 (insert "\
700However, none of them safely encodes the target text.
701
702The first problematic character is at point in the displayed buffer,\n"
703 (substitute-command-keys "\
704and \\[universal-argument] \\[what-cursor-position] will give information about it.\n"))))
705 (insert (if (consp coding-system)
706 "\nSelect the above, or "
707 "\nSelect ")
708 "\
709one of the following safe coding systems, or edit the buffer:\n")
675 (let ((pos (point)) 710 (let ((pos (point))
676 (fill-prefix " ")) 711 (fill-prefix " "))
677 (mapcar (function (lambda (x) 712 (mapcar (function (lambda (x) (princ " ") (princ x)))
678 (princ " ") (princ (car x)))) 713 codings)
679 default-coding-system)
680 (insert "\n") 714 (insert "\n")
681 (fill-region-as-paragraph pos (point))) 715 (fill-region-as-paragraph pos (point)))))
682 (insert 716
683 (if (consp coding-system) 717 ;; Read a coding system.
684 (concat (format "%s safely encodes the target text,\n" 718 (if (consp coding-system)
685 (car coding-system)) 719 (setq codings (cons (car coding-system) codings)))
686 "but it is not recommended for encoding text in this context,\n" 720 (let* ((safe-names (mapcar (lambda (x) (list (symbol-name x)))
687 "e.g., for sending an email message.\n") 721 codings))
688 "However, none of them safely encodes the target text.\n"))) 722 (name (completing-read
689 (insert (if (consp coding-system) 723 (format "Select coding system (default %s): "
690 "\nSelect the above, or " 724 (car codings))
691 "\nSelect ") 725 safe-names nil t nil nil
692 "one of the following safe coding systems:\n") 726 (car (car safe-names)))))
693 (let ((pos (point)) 727 (setq last-coding-system-specified (intern name)
694 (fill-prefix " ")) 728 coding-system last-coding-system-specified)))
695 (mapcar (function (lambda (x) (princ " ") (princ x))) 729 (kill-buffer "*Warning*"))))
696 codings)
697 (insert "\n")
698 (fill-region-as-paragraph pos (point)))))
699
700 ;; Read a coding system.
701 (if (consp coding-system)
702 (setq codings (cons (car coding-system) codings)))
703 (let* ((safe-names (mapcar (lambda (x) (list (symbol-name x)))
704 codings))
705 (name (completing-read
706 (format "Select coding system (default %s): "
707 (car codings))
708 safe-names nil t nil nil
709 (car (car safe-names)))))
710 (setq last-coding-system-specified (intern name)
711 coding-system last-coding-system-specified)))
712 (kill-buffer "*Warning*")))
713 730
714 (if (vectorp (coding-system-eol-type coding-system)) 731 (if (vectorp (coding-system-eol-type coding-system))
715 (let ((eol (coding-system-eol-type buffer-file-coding-system))) 732 (let ((eol (coding-system-eol-type buffer-file-coding-system)))
@@ -732,6 +749,10 @@ and TO is ignored."
732 (set-auto-coding (or file buffer-file-name "") 749 (set-auto-coding (or file buffer-file-name "")
733 (buffer-size)))))) 750 (buffer-size))))))
734 (if (and auto-cs 751 (if (and auto-cs
752 ;; Don't barf if writing a compressed file, say.
753 ;; This check perhaps isn't ideal, but is probably
754 ;; the best thing to do.
755 (not (auto-coding-alist-lookup (or file buffer-file-name "")))
735 (not (coding-system-equal (coding-system-base coding-system) 756 (not (coding-system-equal (coding-system-base coding-system)
736 (coding-system-base auto-cs)))) 757 (coding-system-base auto-cs))))
737 (unless (yes-or-no-p 758 (unless (yes-or-no-p
@@ -741,6 +762,46 @@ and try again)? " coding-system auto-cs))
741 (error "Save aborted"))))) 762 (error "Save aborted")))))
742 coding-system)) 763 coding-system))
743 764
765(defun unencodable-char-position (start end coding-system)
766 "Return position of first un-encodable character in a region.
767START and END specfiy the region and CODING-SYSTEM specifies the
768encoding to check. Return nil if CODING-SYSTEM does encode the region.
769
770CODING-SYSTEM may also be a list of coding systems, in which case return
771the first position not encodable by any of them.
772
773This function is fairly slow."
774 ;; Use recursive calls in the binary chop below, since we're
775 ;; O(logN), and the call overhead shouldn't be a bottleneck.
776 (unless enable-multibyte-characters
777 (error "Unibyte buffer"))
778 ;; Recurse if list of coding systems.
779 (if (consp coding-system)
780 (let ((end end) res)
781 (dolist (elt coding-system (and res (>= res 0) res))
782 (let ((pos (unencodable-char-position start end elt)))
783 (if pos
784 (setq end pos
785 res pos)))))
786 ;; Skip ASCII initially.
787 (save-excursion
788 (goto-char start)
789 (skip-chars-forward "\000-\177" end)
790 (setq start (point))
791 (unless (= start end)
792 (setq coding-system (coding-system-base coding-system)) ; canonicalize
793 (let ((codings (find-coding-systems-region start end)))
794 (unless (or (equal codings '(undecided))
795 (memq coding-system
796 (find-coding-systems-region start end)))
797 ;; Binary chop.
798 (if (= start (1- end))
799 start
800 (or (unencodable-char-position start (/ (+ start end) 2)
801 coding-system)
802 (unencodable-char-position (/ (+ start end) 2) end
803 coding-system)))))))))
804
744(setq select-safe-coding-system-function 'select-safe-coding-system) 805(setq select-safe-coding-system-function 'select-safe-coding-system)
745 806
746(defun select-message-coding-system () 807(defun select-message-coding-system ()
@@ -760,7 +821,7 @@ it asks the user to select a proper coding system."
760 default-sendmail-coding-system 821 default-sendmail-coding-system
761 default-buffer-file-coding-system))) 822 default-buffer-file-coding-system)))
762 (if (eq coding 'no-conversion) 823 (if (eq coding 'no-conversion)
763 ;; We should never use no-conversion for outgoing mails. 824 ;; We should never use no-conversion for outgoing mail.
764 (setq coding nil)) 825 (setq coding nil))
765 (if (fboundp select-safe-coding-system-function) 826 (if (fboundp select-safe-coding-system-function)
766 (funcall select-safe-coding-system-function 827 (funcall select-safe-coding-system-function
@@ -783,9 +844,9 @@ Meaningful values for KEY include
783 is meant for, and how to use it. 844 is meant for, and how to use it.
784 charset value is a list of the character sets used by this 845 charset value is a list of the character sets used by this
785 language environment. 846 language environment.
786 sample-text value is one line of text, 847 sample-text value is an expression which is evalled to generate
787 written using those character sets, 848 a line of text written using characters appropriate
788 appropriate for this language environment. 849 for this language environment.
789 setup-function value is a function to call to switch to this 850 setup-function value is a function to call to switch to this
790 language environment. 851 language environment.
791 exit-function value is a function to call to leave this 852 exit-function value is a function to call to leave this
@@ -862,7 +923,7 @@ ALIST is an alist of KEY and INFO values. See the documentation of
862`language-info-alist' for the meanings of KEY and INFO. 923`language-info-alist' for the meanings of KEY and INFO.
863 924
864Optional arg PARENTS is a list of parent menu names; it specifies 925Optional arg PARENTS is a list of parent menu names; it specifies
865where to put this language environment in the 926where to put this language environment in the
866Describe Language Environment and Set Language Environment menus. 927Describe Language Environment and Set Language Environment menus.
867For example, (\"European\") means to put this language environment 928For example, (\"European\") means to put this language environment
868in the European submenu in each of those two menus." 929in the European submenu in each of those two menus."
@@ -929,7 +990,7 @@ This returns a language environment name as a string."
929 name))) 990 name)))
930 991
931;;; Multilingual input methods. 992;;; Multilingual input methods.
932(defgroup leim nil 993(defgroup leim nil
933 "LEIM: Libraries of Emacs Input Methods." 994 "LEIM: Libraries of Emacs Input Methods."
934 :group 'mule) 995 :group 'mule)
935 996
@@ -940,7 +1001,7 @@ in the format of Lisp expression for registering each input method.
940Emacs loads this file at startup time.") 1001Emacs loads this file at startup time.")
941 1002
942(defvar leim-list-header (format 1003(defvar leim-list-header (format
943";;; %s -- list of LEIM (Library of Emacs Input Method) 1004";;; %s -- list of LEIM (Library of Emacs Input Method) -*-coding: iso-2022-7bit;-*-
944;; 1005;;
945;; This file contains a list of LEIM (Library of Emacs Input Method) 1006;; This file contains a list of LEIM (Library of Emacs Input Method)
946;; methods in the same directory as this file. Loading this file 1007;; methods in the same directory as this file. Loading this file
@@ -1182,7 +1243,7 @@ and enable that one. The default is the most recent input method specified
1182 default t)) 1243 default t))
1183 default)) 1244 default))
1184 (unless default-input-method 1245 (unless default-input-method
1185 (prog1 1246 (prog1
1186 (setq default-input-method current-input-method) 1247 (setq default-input-method current-input-method)
1187 (when (interactive-p) 1248 (when (interactive-p)
1188 (customize-mark-as-set 'default-input-method))))))) 1249 (customize-mark-as-set 'default-input-method)))))))
@@ -1207,7 +1268,7 @@ and enable that one. The default is the most recent input method specified
1207 (activate-input-method input-method) 1268 (activate-input-method input-method)
1208 (describe-current-input-method)) 1269 (describe-current-input-method))
1209 (activate-input-method current)) 1270 (activate-input-method current))
1210 (error 1271 (error
1211 (activate-input-method current) 1272 (activate-input-method current)
1212 (help-setup-xref (list #'describe-input-method input-method) 1273 (help-setup-xref (list #'describe-input-method input-method)
1213 (interactive-p)) 1274 (interactive-p))
@@ -1273,7 +1334,8 @@ guidance, but simple input methods give it only when you are not in
1273the minibuffer. 1334the minibuffer.
1274 1335
1275See also the variable `input-method-highlight-flag'." 1336See also the variable `input-method-highlight-flag'."
1276 :type '(choice (const t) (const nil) (const complex-only) (const default)) 1337 :type '(choice (const :tag "Always" t) (const :tag "Never" nil)
1338 (const complex-only) (const default))
1277 :group 'mule) 1339 :group 'mule)
1278 1340
1279(defcustom input-method-highlight-flag t 1341(defcustom input-method-highlight-flag t
@@ -1378,7 +1440,7 @@ to using the function `set-language-environment'."
1378 1440
1379The default status is as follows: 1441The default status is as follows:
1380 1442
1381 The default value of buffer-file-coding-system is nil. 1443 The default value of `buffer-file-coding-system' is nil.
1382 The default coding system for process I/O is nil. 1444 The default coding system for process I/O is nil.
1383 The default value for the command `set-terminal-coding-system' is nil. 1445 The default value for the command `set-terminal-coding-system' is nil.
1384 The default value for the command `set-keyboard-coding-system' is nil. 1446 The default value for the command `set-keyboard-coding-system' is nil.
@@ -1429,7 +1491,7 @@ The default status is as follows:
1429 coding-category-iso-7 1491 coding-category-iso-7
1430 coding-category-iso-7-else 1492 coding-category-iso-7-else
1431 coding-category-iso-8-else 1493 coding-category-iso-8-else
1432 coding-category-emacs-mule 1494 coding-category-emacs-mule
1433 coding-category-raw-text 1495 coding-category-raw-text
1434 coding-category-sjis 1496 coding-category-sjis
1435 coding-category-big5 1497 coding-category-big5
@@ -1451,7 +1513,7 @@ The default status is as follows:
1451 (let ((output-coding 1513 (let ((output-coding
1452 ;; When bootstrapping, coding-systems are not defined yet, so 1514 ;; When bootstrapping, coding-systems are not defined yet, so
1453 ;; we need to catch the error from check-coding-system. 1515 ;; we need to catch the error from check-coding-system.
1454 (condition-case nil 1516 (condition-case nil
1455 (coding-system-change-text-conversion 1517 (coding-system-change-text-conversion
1456 (car default-process-coding-system) 'undecided) 1518 (car default-process-coding-system) 'undecided)
1457 (coding-system-error 'undecided))) 1519 (coding-system-error 'undecided)))
@@ -1602,7 +1664,7 @@ specifies the character set for the major languages of Western Europe."
1602 "Do various coding system setups for language environment LANGUAGE-NAME. 1664 "Do various coding system setups for language environment LANGUAGE-NAME.
1603 1665
1604The optional arg EOL-TYPE specifies the eol-type of the default value 1666The optional arg EOL-TYPE specifies the eol-type of the default value
1605of buffer-file-coding-system set by this function." 1667of `buffer-file-coding-system' set by this function."
1606 (let* ((priority (get-language-info language-name 'coding-priority)) 1668 (let* ((priority (get-language-info language-name 'coding-priority))
1607 (default-coding (car priority))) 1669 (default-coding (car priority)))
1608 (if priority 1670 (if priority
@@ -1618,8 +1680,8 @@ of buffer-file-coding-system set by this function."
1618 (setq priority (cdr priority) categories (cdr categories))) 1680 (setq priority (cdr priority) categories (cdr categories)))
1619 (update-coding-systems-internal))))) 1681 (update-coding-systems-internal)))))
1620 1682
1621;; Print all arguments with `princ', then print "\n".
1622(defsubst princ-list (&rest args) 1683(defsubst princ-list (&rest args)
1684 "Print all arguments with `princ', then print \"\n\"."
1623 (while args (princ (car args)) (setq args (cdr args))) 1685 (while args (princ (car args)) (setq args (cdr args)))
1624 (princ "\n")) 1686 (princ "\n"))
1625 1687
@@ -1763,10 +1825,11 @@ of buffer-file-coding-system set by this function."
1763 ; bn Bengali, Bangla 1825 ; bn Bengali, Bangla
1764 ("bo" . "Tibetan") 1826 ("bo" . "Tibetan")
1765 ("br" . "Latin-1") ; Breton 1827 ("br" . "Latin-1") ; Breton
1828 ("bs" . "Latin-2") ; Bosnian
1766 ("ca" . "Latin-1") ; Catalan 1829 ("ca" . "Latin-1") ; Catalan
1767 ; co Corsican 1830 ; co Corsican
1768 ("cs" . "Czech") 1831 ("cs" . "Czech")
1769 ("cy" . "Latin-8") ; Welsh 1832 ("cy" . "Welsh") ; Welsh
1770 ("da" . "Latin-1") ; Danish 1833 ("da" . "Latin-1") ; Danish
1771 ("de" . "German") 1834 ("de" . "German")
1772 ; dz Bhutani 1835 ; dz Bhutani
@@ -1777,7 +1840,7 @@ of buffer-file-coding-system set by this function."
1777 ("es" . "Spanish") 1840 ("es" . "Spanish")
1778 ("et" . "Latin-4") ; Estonian 1841 ("et" . "Latin-4") ; Estonian
1779 ("eu" . "Latin-1") ; Basque 1842 ("eu" . "Latin-1") ; Basque
1780 ; fa Persian 1843 ; fa Persian glibc uses utf-8
1781 ("fi" . "Latin-1") ; Finnish 1844 ("fi" . "Latin-1") ; Finnish
1782 ; fj Fiji 1845 ; fj Fiji
1783 ("fo" . "Latin-1") ; Faroese 1846 ("fo" . "Latin-1") ; Faroese
@@ -1788,7 +1851,7 @@ of buffer-file-coding-system set by this function."
1788 ("gl" . "Latin-1") ; Galician 1851 ("gl" . "Latin-1") ; Galician
1789 ; gn Guarani 1852 ; gn Guarani
1790 ; gu Gujarati 1853 ; gu Gujarati
1791 ("gv" . "Latin-8") ; Manx Gaelic 1854 ("gv" . "Latin-8") ; Manx Gaelic glibc uses 8859-1
1792 ; ha Hausa 1855 ; ha Hausa
1793 ("he" . "Hebrew") 1856 ("he" . "Hebrew")
1794 ("hi" . "Devanagari") ; Hindi glibc uses utf-8 1857 ("hi" . "Devanagari") ; Hindi glibc uses utf-8
@@ -1886,6 +1949,7 @@ of buffer-file-coding-system set by this function."
1886 ("uz" . "Latin-1") ; Uzbek 1949 ("uz" . "Latin-1") ; Uzbek
1887 ("vi" . "Vietnamese") ; glibc uses utf-8 1950 ("vi" . "Vietnamese") ; glibc uses utf-8
1888 ; vo Volapuk 1951 ; vo Volapuk
1952 ("wa" . "Latin-1") ; Walloon
1889 ; wo Wolof 1953 ; wo Wolof
1890 ; xh Xhosa 1954 ; xh Xhosa
1891 ("yi" . "Windows-1255") ; Yiddish 1955 ("yi" . "Windows-1255") ; Yiddish
@@ -1991,7 +2055,7 @@ For example, the locale name \"ja_JP.EUC\" might name a locale
1991for Japanese in Japan using the `japanese-iso-8bit' coding-system. 2055for Japanese in Japan using the `japanese-iso-8bit' coding-system.
1992 2056
1993If LOCALE-NAME is nil, its value is taken from the environment 2057If LOCALE-NAME is nil, its value is taken from the environment
1994variables LC_ALL, LC_CTYLE and LANG (the first one that is set). 2058variables LC_ALL, LC_CTYPE and LANG (the first one that is set).
1995 2059
1996The locale names supported by your system can typically be found in a 2060The locale names supported by your system can typically be found in a
1997directory named `/usr/share/locale' or `/usr/lib/locale'. LOCALE-NAME 2061directory named `/usr/share/locale' or `/usr/lib/locale'. LOCALE-NAME