mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-11-29 07:58:28 +00:00
(universal-coding-system-argument):
Check the coding system type `undecided', not `t'. (sort-coding-systems): Fix for iso-2022 coding systems. (find-multibyte-characters): Fix for eight-bit chars. (set-language-environment): Set charset priorities according to the charsets supported by the coding systems of higher priorities.
This commit is contained in:
parent
af7c60ca4f
commit
a0d96cad18
@ -254,9 +254,8 @@ wrong, use this command again to toggle back to the right mode."
|
|||||||
"Execute an I/O command using the specified coding system."
|
"Execute an I/O command using the specified coding system."
|
||||||
(interactive)
|
(interactive)
|
||||||
(let* ((default (and buffer-file-coding-system
|
(let* ((default (and buffer-file-coding-system
|
||||||
;; Fixme: what is t here?
|
|
||||||
(not (eq (coding-system-type buffer-file-coding-system)
|
(not (eq (coding-system-type buffer-file-coding-system)
|
||||||
t))
|
'undecided))
|
||||||
buffer-file-coding-system))
|
buffer-file-coding-system))
|
||||||
(coding-system (read-coding-system
|
(coding-system (read-coding-system
|
||||||
(if default
|
(if default
|
||||||
@ -396,18 +395,21 @@ non-nil, it is used to sort CODINGS in the different way than above."
|
|||||||
(if (memq base lang-preferred) 8 0)
|
(if (memq base lang-preferred) 8 0)
|
||||||
(if (string-match "-with-esc$" (symbol-name base))
|
(if (string-match "-with-esc$" (symbol-name base))
|
||||||
0 4)
|
0 4)
|
||||||
;; Fixme: sort out coding-system-spec
|
(if (eq (coding-system-type base) 'iso-2022)
|
||||||
;; (if (eq (coding-system-type base) 'iso-2022)
|
(let ((category (coding-system-category base)))
|
||||||
;; ;; For ISO based coding systems, prefer
|
;; For ISO based coding systems, prefer
|
||||||
;; ;; one that doesn't use escape sequences.
|
;; one that doesn't use designation nor
|
||||||
;; (let* ((extra-spec (coding-system-spec base))
|
;; locking/single shifting.
|
||||||
;; (flags (aref extra-spec 3)))
|
(cond
|
||||||
;; (if (/= (logand flags #x40) 0)
|
((or (eq category 'coding-category-iso-8-1)
|
||||||
;; (if (/= (logand flags #x30) 0)
|
(eq category 'coding-category-iso-8-2))
|
||||||
;; 0
|
2)
|
||||||
;; 1)
|
((or (eq category 'coding-category-iso-7-tight)
|
||||||
;; 2))
|
(eq category 'coding-category-iso-7))
|
||||||
;; 1)
|
1)
|
||||||
|
(t
|
||||||
|
0)))
|
||||||
|
1)
|
||||||
))))))
|
))))))
|
||||||
(sort codings (function (lambda (x y)
|
(sort codings (function (lambda (x y)
|
||||||
(> (funcall func x) (funcall func y))))))))
|
(> (funcall func x) (funcall func y))))))))
|
||||||
@ -473,7 +475,6 @@ Emacs, but is unlikely to be what you really want now."
|
|||||||
(push cs codings))))
|
(push cs codings))))
|
||||||
(nreverse codings)))))
|
(nreverse codings)))))
|
||||||
|
|
||||||
;; Fixme: is this doing the right thing now, at least with eight-bit?
|
|
||||||
(defun find-multibyte-characters (from to &optional maxcount excludes)
|
(defun find-multibyte-characters (from to &optional maxcount excludes)
|
||||||
"Find multibyte characters in the region specified by FROM and TO.
|
"Find multibyte characters in the region specified by FROM and TO.
|
||||||
If FROM is a string, find multibyte characters in the string.
|
If FROM is a string, find multibyte characters in the string.
|
||||||
@ -488,36 +489,36 @@ Optional 4th arg EXCLUDE is a list of character sets to be ignored."
|
|||||||
(let ((chars nil)
|
(let ((chars nil)
|
||||||
charset char)
|
charset char)
|
||||||
(if (stringp from)
|
(if (stringp from)
|
||||||
(let ((idx 0))
|
(if (multibyte-string-p from)
|
||||||
(while (setq idx (string-match "[^\000-\177]" from idx))
|
(let ((idx 0))
|
||||||
(setq char (aref from idx)
|
(while (setq idx (string-match "[^\000-\177]" from idx))
|
||||||
charset (char-charset char))
|
(setq char (aref from idx)
|
||||||
(if (or (memq charset '(eight-bit-control eight-bit-graphic))
|
charset (char-charset char))
|
||||||
(not (or (eq excludes t) (memq charset excludes))))
|
(unless (memq charset excludes)
|
||||||
|
(let ((slot (assq charset chars)))
|
||||||
|
(if slot
|
||||||
|
(if (not (memq char (nthcdr 2 slot)))
|
||||||
|
(let ((count (nth 1 slot)))
|
||||||
|
(setcar (cdr slot) (1+ count))
|
||||||
|
(if (or (not maxcount) (< count maxcount))
|
||||||
|
(nconc slot (list char)))))
|
||||||
|
(setq chars (cons (list charset 1 char) chars)))))
|
||||||
|
(setq idx (1+ idx)))))
|
||||||
|
(if enable-multibyte-characters
|
||||||
|
(save-excursion
|
||||||
|
(goto-char from)
|
||||||
|
(while (re-search-forward "[^\000-\177]" to t)
|
||||||
|
(setq char (preceding-char)
|
||||||
|
charset (char-charset char))
|
||||||
|
(unless (memq charset excludes)
|
||||||
(let ((slot (assq charset chars)))
|
(let ((slot (assq charset chars)))
|
||||||
(if slot
|
(if slot
|
||||||
(if (not (memq char (nthcdr 2 slot)))
|
(if (not (member char (nthcdr 2 slot)))
|
||||||
(let ((count (nth 1 slot)))
|
(let ((count (nth 1 slot)))
|
||||||
(setcar (cdr slot) (1+ count))
|
(setcar (cdr slot) (1+ count))
|
||||||
(if (or (not maxcount) (< count maxcount))
|
(if (or (not maxcount) (< count maxcount))
|
||||||
(nconc slot (list char)))))
|
(nconc slot (list char)))))
|
||||||
(setq chars (cons (list charset 1 char) chars)))))
|
(setq chars (cons (list charset 1 char) chars)))))))))
|
||||||
(setq idx (1+ idx))))
|
|
||||||
(save-excursion
|
|
||||||
(goto-char from)
|
|
||||||
(while (re-search-forward "[^\000-\177]" to t)
|
|
||||||
(setq char (preceding-char)
|
|
||||||
charset (char-charset char))
|
|
||||||
(if (or (memq charset '(eight-bit-control eight-bit-graphic))
|
|
||||||
(not (or (eq excludes t) (memq charset excludes))))
|
|
||||||
(let ((slot (assq charset chars)))
|
|
||||||
(if slot
|
|
||||||
(if (not (member char (nthcdr 2 slot)))
|
|
||||||
(let ((count (nth 1 slot)))
|
|
||||||
(setcar (cdr slot) (1+ count))
|
|
||||||
(if (or (not maxcount) (< count maxcount))
|
|
||||||
(nconc slot (list char)))))
|
|
||||||
(setq chars (cons (list charset 1 char) chars))))))))
|
|
||||||
(nreverse chars)))
|
(nreverse chars)))
|
||||||
|
|
||||||
(defvar last-coding-system-specified nil
|
(defvar last-coding-system-specified nil
|
||||||
@ -1438,11 +1439,13 @@ specifies the character set for the major languages of Western Europe."
|
|||||||
(cons input-method
|
(cons input-method
|
||||||
(delete input-method input-method-history))))))
|
(delete input-method input-method-history))))))
|
||||||
|
|
||||||
;; Fixme: default from the environment coding system where that's
|
;; Put higher priorities to such charsets that are supported by the
|
||||||
;; charset-based.
|
;; coding systems of higher priorities in this environment.
|
||||||
(if (get-language-info language-name 'charset)
|
(let ((charsets nil))
|
||||||
(apply 'set-charset-priority (get-language-info language-name
|
(dolist (coding (get-language-info language-name 'coding-priority))
|
||||||
'charset)))
|
(setq charsets (append charsets (coding-system-charset-list coding))))
|
||||||
|
(if charsets
|
||||||
|
(apply 'set-charset-priority charsets)))
|
||||||
|
|
||||||
;; Note: For DOS, we assumed that the charset cpXXX is already
|
;; Note: For DOS, we assumed that the charset cpXXX is already
|
||||||
;; defined.
|
;; defined.
|
||||||
|
Loading…
Reference in New Issue
Block a user