2002-05-17 16:51:14 +00:00
|
|
|
|
;;; mule.el --- basic commands for multilingual environment
|
1997-02-20 07:02:49 +00:00
|
|
|
|
|
2011-01-26 00:36:39 -08:00
|
|
|
|
;; Copyright (C) 1997-2011 Free Software Foundation, Inc.
|
2006-12-13 01:13:58 +00:00
|
|
|
|
;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
|
2011-01-02 15:50:46 -08:00
|
|
|
|
;; 2005, 2006, 2007, 2008, 2009, 2010, 2011
|
2005-05-13 06:03:46 +00:00
|
|
|
|
;; National Institute of Advanced Industrial Science and Technology (AIST)
|
|
|
|
|
;; Registration Number H14PRO021
|
2003-09-08 12:53:41 +00:00
|
|
|
|
;; Copyright (C) 2003
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
;; National Institute of Advanced Industrial Science and Technology (AIST)
|
|
|
|
|
;; Registration Number H13PRO009
|
1997-02-20 07:02:49 +00:00
|
|
|
|
|
|
|
|
|
;; Keywords: mule, multilingual, character set, coding system
|
|
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
2008-05-06 04:29:13 +00:00
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
1997-02-20 07:02:49 +00:00
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 04:29:13 +00:00
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
1997-02-20 07:02:49 +00:00
|
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2008-05-06 04:29:13 +00:00
|
|
|
|
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
1997-02-20 07:02:49 +00:00
|
|
|
|
|
2001-07-15 19:53:53 +00:00
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
1997-02-20 07:02:49 +00:00
|
|
|
|
;;; Code:
|
|
|
|
|
|
2003-09-08 12:53:41 +00:00
|
|
|
|
(defconst mule-version "6.0 (HANACHIRUSATO)" "\
|
1997-02-20 07:02:49 +00:00
|
|
|
|
Version number and name of this version of MULE (multilingual environment).")
|
|
|
|
|
|
2003-09-08 12:53:41 +00:00
|
|
|
|
(defconst mule-version-date "2003.9.1" "\
|
1997-02-20 07:02:49 +00:00
|
|
|
|
Distribution date of this version of MULE (multilingual environment).")
|
|
|
|
|
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
|
|
|
|
|
;;; CHARSET
|
|
|
|
|
|
2003-11-17 03:57:03 +00:00
|
|
|
|
;; Backward compatibility code for handling emacs-mule charsets.
|
|
|
|
|
(defvar private-char-area-1-min #xF0000)
|
|
|
|
|
(defvar private-char-area-1-max #xFFFFE)
|
|
|
|
|
(defvar private-char-area-2-min #x100000)
|
|
|
|
|
(defvar private-char-area-2-max #x10FFFE)
|
|
|
|
|
|
|
|
|
|
;; Table of emacs-mule charsets indexed by their emacs-mule ID.
|
|
|
|
|
(defvar emacs-mule-charset-table (make-vector 256 nil))
|
|
|
|
|
(aset emacs-mule-charset-table 0 'ascii)
|
|
|
|
|
|
2009-01-06 02:05:34 +00:00
|
|
|
|
;; Convert the argument of old-style call of define-charset to a
|
2003-11-17 03:57:03 +00:00
|
|
|
|
;; property list used by the new-style.
|
|
|
|
|
;; INFO-VECTOR is a vector of the format:
|
|
|
|
|
;; [DIMENSION CHARS WIDTH DIRECTION ISO-FINAL-CHAR ISO-GRAPHIC-PLANE
|
|
|
|
|
;; SHORT-NAME LONG-NAME DESCRIPTION]
|
|
|
|
|
|
|
|
|
|
(defun convert-define-charset-argument (emacs-mule-id info-vector)
|
|
|
|
|
(let* ((dim (aref info-vector 0))
|
|
|
|
|
(chars (aref info-vector 1))
|
|
|
|
|
(total (if (= dim 1) chars (* chars chars)))
|
|
|
|
|
(code-space (if (= dim 1) (if (= chars 96) [32 127] [33 126])
|
|
|
|
|
(if (= chars 96) [32 127 32 127] [33 126 33 126])))
|
|
|
|
|
code-offset)
|
|
|
|
|
(if (integerp emacs-mule-id)
|
|
|
|
|
(or (= emacs-mule-id 0)
|
|
|
|
|
(and (>= emacs-mule-id 129) (< emacs-mule-id 256))
|
|
|
|
|
(error "Invalid CHARSET-ID: %d" emacs-mule-id))
|
|
|
|
|
(let (from-id to-id)
|
|
|
|
|
(if (= dim 1) (setq from-id 160 to-id 224)
|
|
|
|
|
(setq from-id 224 to-id 255))
|
|
|
|
|
(while (and (< from-id to-id)
|
|
|
|
|
(not (aref emacs-mule-charset-table from-id)))
|
|
|
|
|
(setq from-id (1+ from-id)))
|
|
|
|
|
(if (= from-id to-id)
|
|
|
|
|
(error "No more room for the new Emacs-mule charset"))
|
|
|
|
|
(setq emacs-mule-id from-id)))
|
|
|
|
|
(if (> (- private-char-area-1-max private-char-area-1-min) total)
|
|
|
|
|
(setq code-offset private-char-area-1-min
|
|
|
|
|
private-char-area-1-min (+ private-char-area-1-min total))
|
|
|
|
|
(if (> (- private-char-area-2-max private-char-area-2-min) total)
|
|
|
|
|
(setq code-offset private-char-area-2-min
|
|
|
|
|
private-char-area-2-min (+ private-char-area-2-min total))
|
2008-05-14 11:46:24 +00:00
|
|
|
|
(error "No more space for a new charset")))
|
2003-11-17 03:57:03 +00:00
|
|
|
|
(list :dimension dim
|
|
|
|
|
:code-space code-space
|
|
|
|
|
:iso-final-char (aref info-vector 4)
|
|
|
|
|
:code-offset code-offset
|
|
|
|
|
:emacs-mule-id emacs-mule-id)))
|
|
|
|
|
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
(defun define-charset (name docstring &rest props)
|
|
|
|
|
"Define NAME (symbol) as a charset with DOCSTRING.
|
|
|
|
|
The remaining arguments must come in pairs ATTRIBUTE VALUE. ATTRIBUTE
|
2002-05-17 16:51:14 +00:00
|
|
|
|
may be any symbol. The following have special meanings, and one of
|
2002-06-12 00:57:01 +00:00
|
|
|
|
`:code-offset', `:map', `:subset', `:superset' must be specified.
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
|
|
|
|
|
`:short-name'
|
|
|
|
|
|
|
|
|
|
VALUE must be a short string to identify the charset. If omitted,
|
|
|
|
|
NAME is used.
|
|
|
|
|
|
|
|
|
|
`:long-name'
|
|
|
|
|
|
|
|
|
|
VALUE must be a string longer than `:short-name' to identify the
|
2002-05-17 16:51:14 +00:00
|
|
|
|
charset. If omitted, the value of the `:short-name' attribute is used.
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
|
|
|
|
|
`:dimension'
|
|
|
|
|
|
|
|
|
|
VALUE must be an integer 0, 1, 2, or 3, specifying the dimension of
|
2002-05-17 16:51:14 +00:00
|
|
|
|
code-points of the charsets. If omitted, it is calculated from the
|
|
|
|
|
value of the `:code-space' attribute.
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
|
|
|
|
|
`:code-space'
|
|
|
|
|
|
|
|
|
|
VALUE must be a vector of length at most 8 specifying the byte code
|
|
|
|
|
range of each dimension in this format:
|
|
|
|
|
[ MIN-1 MAX-1 MIN-2 MAX-2 ... ]
|
2002-05-17 16:51:14 +00:00
|
|
|
|
where MIN-N is the minimum byte value of Nth dimension of code-point,
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
MAX-N is the maximum byte value of that.
|
|
|
|
|
|
2002-05-30 00:32:34 +00:00
|
|
|
|
`:min-code'
|
|
|
|
|
|
|
|
|
|
VALUE must be an integer specifying the mininum code point of the
|
|
|
|
|
charset. If omitted, it is calculated from `:code-space'. VALUE may
|
|
|
|
|
be a cons (HIGH . LOW), where HIGH is the most significant 16 bits of
|
|
|
|
|
the code point and LOW is the least significant 16 bits.
|
|
|
|
|
|
2002-07-11 23:08:18 +00:00
|
|
|
|
`:max-code'
|
2002-05-30 00:32:34 +00:00
|
|
|
|
|
|
|
|
|
VALUE must be an integer specifying the maxinum code point of the
|
|
|
|
|
charset. If omitted, it is calculated from `:code-space'. VALUE may
|
|
|
|
|
be a cons (HIGH . LOW), where HIGH is the most significant 16 bits of
|
|
|
|
|
the code point and LOW is the least significant 16 bits.
|
|
|
|
|
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
`:iso-final-char'
|
|
|
|
|
|
|
|
|
|
VALUE must be a character in the range 32 to 127 (inclusive)
|
|
|
|
|
specifying the final char of the charset for ISO-2022 encoding. If
|
|
|
|
|
omitted, the charset can't be encoded by ISO-2022 based
|
|
|
|
|
coding-systems.
|
|
|
|
|
|
|
|
|
|
`:iso-revision-number'
|
|
|
|
|
|
|
|
|
|
VALUE must be an integer in the range 0..63, specifying the revision
|
|
|
|
|
number of the charset for ISO-2022 encoding.
|
|
|
|
|
|
|
|
|
|
`:emacs-mule-id'
|
|
|
|
|
|
2003-11-17 03:57:03 +00:00
|
|
|
|
VALUE must be an integer of 0, 129..255. If omitted, the charset
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
can't be encoded by coding-systems of type `emacs-mule'.
|
|
|
|
|
|
|
|
|
|
`:ascii-compatible-p'
|
|
|
|
|
|
2002-05-17 16:51:14 +00:00
|
|
|
|
VALUE must be nil or t (default nil). If VALUE is t, the charset is
|
|
|
|
|
compatible with ASCII, i.e. the first 128 code points map to ASCII.
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
|
|
|
|
|
`:supplementary-p'
|
|
|
|
|
|
|
|
|
|
VALUE must be nil or t. If the VALUE is t, the charset is
|
2007-12-06 07:28:58 +00:00
|
|
|
|
supplementary, which means it is used only as a parent or a
|
|
|
|
|
subset of some other charset, or it is provided just for backward
|
|
|
|
|
compatibility.
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
|
|
|
|
|
`:invalid-code'
|
|
|
|
|
|
|
|
|
|
VALUE must be a nonnegative integer that can be used as an invalid
|
|
|
|
|
code point of the charset. If the minimum code is 0 and the maximum
|
|
|
|
|
code is greater than Emacs' maximum integer value, `:invalid-code'
|
|
|
|
|
should not be omitted.
|
|
|
|
|
|
|
|
|
|
`:code-offset'
|
|
|
|
|
|
2002-05-17 16:51:14 +00:00
|
|
|
|
VALUE must be an integer added to the index number of a character to
|
|
|
|
|
get the corresponding character code.
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
|
|
|
|
|
`:map'
|
|
|
|
|
|
|
|
|
|
VALUE must be vector or string.
|
|
|
|
|
|
|
|
|
|
If it is a vector, the format is [ CODE-1 CHAR-1 CODE-2 CHAR-2 ... ],
|
|
|
|
|
where CODE-n is a code-point of the charset, and CHAR-n is the
|
2002-05-17 16:51:14 +00:00
|
|
|
|
corresponding character code.
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
|
|
|
|
|
If it is a string, it is a name of file that contains the above
|
2002-03-05 01:07:22 +00:00
|
|
|
|
information. Each line of the file must be this format:
|
|
|
|
|
0xXXX 0xYYY
|
|
|
|
|
where XXX is a hexadecimal representation of CODE-n and YYY is a
|
|
|
|
|
hexadecimal representation of CHAR-n. A line starting with `#' is a
|
|
|
|
|
comment line.
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
|
2002-06-12 00:15:39 +00:00
|
|
|
|
`:subset'
|
|
|
|
|
|
|
|
|
|
VALUE must be a list:
|
|
|
|
|
( PARENT MIN-CODE MAX-CODE OFFSET )
|
|
|
|
|
PARENT is a parent charset. MIN-CODE and MAX-CODE specify the range
|
|
|
|
|
of characters inherited from the parent. OFFSET is an integer value
|
|
|
|
|
to add to a code point of the parent charset to get the corresponding
|
|
|
|
|
code point of this charset.
|
|
|
|
|
|
|
|
|
|
`:superset'
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
|
|
|
|
|
VALUE must be a list of parent charsets. The charset inherits
|
|
|
|
|
characters from them. Each element of the list may be a cons (PARENT
|
|
|
|
|
. OFFSET), where PARENT is a parent charset, and OFFSET is an offset
|
2002-06-12 00:15:39 +00:00
|
|
|
|
value to add to a code point of PARENT to get the corresponding code
|
|
|
|
|
point of this charset.
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
|
|
|
|
|
`:unify-map'
|
|
|
|
|
|
|
|
|
|
VALUE must be vector or string.
|
|
|
|
|
|
|
|
|
|
If it is a vector, the format is [ CODE-1 CHAR-1 CODE-2 CHAR-2 ... ],
|
|
|
|
|
where CODE-n is a code-point of the charset, and CHAR-n is the
|
2002-05-17 16:51:14 +00:00
|
|
|
|
corresponding Unicode character code.
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
|
|
|
|
|
If it is a string, it is a name of file that contains the above
|
2002-03-05 01:07:22 +00:00
|
|
|
|
information. The file format is the same as what described for `:map'
|
|
|
|
|
attribute."
|
2003-11-17 03:57:03 +00:00
|
|
|
|
(when (vectorp (car props))
|
|
|
|
|
;; Old style code:
|
|
|
|
|
;; (define-charset CHARSET-ID CHARSET-SYMBOL INFO-VECTOR)
|
|
|
|
|
;; Convert the argument to make it fit with the current style.
|
|
|
|
|
(let ((vec (car props)))
|
|
|
|
|
(setq props (convert-define-charset-argument name vec)
|
|
|
|
|
name docstring
|
|
|
|
|
docstring (aref vec 8))))
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
(let ((attrs (mapcar 'list '(:dimension
|
|
|
|
|
:code-space
|
2002-05-30 00:32:34 +00:00
|
|
|
|
:min-code
|
|
|
|
|
:max-code
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
:iso-final-char
|
|
|
|
|
:iso-revision-number
|
|
|
|
|
:emacs-mule-id
|
|
|
|
|
:ascii-compatible-p
|
|
|
|
|
:supplementary-p
|
|
|
|
|
:invalid-code
|
|
|
|
|
:code-offset
|
|
|
|
|
:map
|
2002-06-12 00:15:39 +00:00
|
|
|
|
:subset
|
|
|
|
|
:superset
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
:unify-map
|
|
|
|
|
:plist))))
|
|
|
|
|
|
|
|
|
|
;; If :dimension is omitted, get the dimension from :code-space.
|
|
|
|
|
(let ((dimension (plist-get props :dimension)))
|
|
|
|
|
(or dimension
|
2004-01-25 07:33:44 +00:00
|
|
|
|
(let ((code-space (plist-get props :code-space)))
|
|
|
|
|
(setq dimension (if code-space (/ (length code-space) 2) 4))
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
(setq props (plist-put props :dimension dimension)))))
|
|
|
|
|
|
2004-01-25 07:33:44 +00:00
|
|
|
|
(let ((code-space (plist-get props :code-space)))
|
|
|
|
|
(or code-space
|
|
|
|
|
(let ((dimension (plist-get props :dimension)))
|
|
|
|
|
(setq code-space (make-vector 8 0))
|
|
|
|
|
(dotimes (i dimension)
|
|
|
|
|
(aset code-space (1+ (* i 2)) #xFF))
|
|
|
|
|
(setq props (plist-put props :code-space code-space)))))
|
|
|
|
|
|
2003-11-17 03:57:03 +00:00
|
|
|
|
;; If :emacs-mule-id is specified, update emacs-mule-charset-table.
|
|
|
|
|
(let ((emacs-mule-id (plist-get props :emacs-mule-id)))
|
|
|
|
|
(if (integerp emacs-mule-id)
|
|
|
|
|
(aset emacs-mule-charset-table emacs-mule-id name)))
|
|
|
|
|
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
(dolist (slot attrs)
|
2009-11-11 06:27:23 +00:00
|
|
|
|
(setcdr slot (purecopy (plist-get props (car slot)))))
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
|
|
|
|
|
;; Make sure that the value of :code-space is a vector of 8
|
|
|
|
|
;; elements.
|
|
|
|
|
(let* ((slot (assq :code-space attrs))
|
|
|
|
|
(val (cdr slot))
|
|
|
|
|
(len (length val)))
|
|
|
|
|
(if (< len 8)
|
|
|
|
|
(setcdr slot
|
|
|
|
|
(vconcat val (make-vector (- 8 len) 0)))))
|
|
|
|
|
|
|
|
|
|
;; Add :name and :docstring properties to PROPS.
|
|
|
|
|
(setq props
|
2009-11-11 06:27:23 +00:00
|
|
|
|
(cons :name (cons name (cons :docstring (cons (purecopy docstring) props)))))
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
(or (plist-get props :short-name)
|
|
|
|
|
(plist-put props :short-name (symbol-name name)))
|
|
|
|
|
(or (plist-get props :long-name)
|
|
|
|
|
(plist-put props :long-name (plist-get props :short-name)))
|
2010-08-06 17:11:19 +09:00
|
|
|
|
(plist-put props :base name)
|
2002-05-17 20:17:04 +00:00
|
|
|
|
;; We can probably get a worthwhile amount in purespace.
|
|
|
|
|
(setq props
|
|
|
|
|
(mapcar (lambda (elt)
|
|
|
|
|
(if (stringp elt)
|
|
|
|
|
(purecopy elt)
|
|
|
|
|
elt))
|
|
|
|
|
props))
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
(setcdr (assq :plist attrs) props)
|
|
|
|
|
|
|
|
|
|
(apply 'define-charset-internal name (mapcar 'cdr attrs))))
|
|
|
|
|
|
|
|
|
|
|
1997-02-20 07:02:49 +00:00
|
|
|
|
(defun load-with-code-conversion (fullname file &optional noerror nomessage)
|
1997-12-04 04:47:41 +00:00
|
|
|
|
"Execute a file of Lisp code named FILE whose absolute name is FULLNAME.
|
|
|
|
|
The file contents are decoded before evaluation if necessary.
|
2006-11-06 23:05:34 +00:00
|
|
|
|
If optional third arg NOERROR is non-nil,
|
1997-02-20 07:02:49 +00:00
|
|
|
|
report no error if FILE doesn't exist.
|
|
|
|
|
Print messages at start and end of loading unless
|
2006-11-06 23:05:34 +00:00
|
|
|
|
optional fourth arg NOMESSAGE is non-nil.
|
1997-02-20 07:02:49 +00:00
|
|
|
|
Return t if file exists."
|
|
|
|
|
(if (null (file-readable-p fullname))
|
|
|
|
|
(and (null noerror)
|
|
|
|
|
(signal 'file-error (list "Cannot open load file" file)))
|
|
|
|
|
;; Read file with code conversion, and then eval.
|
|
|
|
|
(let* ((buffer
|
2009-08-28 16:29:25 +00:00
|
|
|
|
;; We can't use `generate-new-buffer' because files.el
|
|
|
|
|
;; is not yet loaded.
|
|
|
|
|
(get-buffer-create (generate-new-buffer-name " *load*")))
|
1997-10-23 14:58:25 +00:00
|
|
|
|
(load-in-progress t)
|
|
|
|
|
(source (save-match-data (string-match "\\.el\\'" fullname))))
|
|
|
|
|
(unless nomessage
|
|
|
|
|
(if source
|
|
|
|
|
(message "Loading %s (source)..." file)
|
|
|
|
|
(message "Loading %s..." file)))
|
|
|
|
|
(when purify-flag
|
2009-11-11 06:27:23 +00:00
|
|
|
|
(push (purecopy file) preloaded-file-list))
|
1997-02-20 07:02:49 +00:00
|
|
|
|
(unwind-protect
|
1997-10-23 12:05:45 +00:00
|
|
|
|
(let ((load-file-name fullname)
|
1998-07-06 01:52:48 +00:00
|
|
|
|
(set-auto-coding-for-load t)
|
1997-10-23 12:05:45 +00:00
|
|
|
|
(inhibit-file-name-operation nil))
|
2006-11-24 18:43:58 +00:00
|
|
|
|
(with-current-buffer buffer
|
2008-03-19 01:56:48 +00:00
|
|
|
|
;; So that we don't get completely screwed if the
|
|
|
|
|
;; file is encoded in some complicated character set,
|
2010-08-22 17:15:20 -04:00
|
|
|
|
;; read it with real decoding, as a multibyte buffer.
|
2008-03-19 01:56:48 +00:00
|
|
|
|
(set-buffer-multibyte t)
|
2005-12-12 05:11:57 +00:00
|
|
|
|
;; Don't let deactivate-mark remain set.
|
|
|
|
|
(let (deactivate-mark)
|
|
|
|
|
(insert-file-contents fullname))
|
1998-12-10 13:37:02 +00:00
|
|
|
|
;; If the loaded file was inserted with no-conversion or
|
|
|
|
|
;; raw-text coding system, make the buffer unibyte.
|
|
|
|
|
;; Otherwise, eval-buffer might try to interpret random
|
|
|
|
|
;; binary junk as multibyte characters.
|
|
|
|
|
(if (and enable-multibyte-characters
|
2003-09-08 12:53:41 +00:00
|
|
|
|
(or (eq (coding-system-type last-coding-system-used)
|
|
|
|
|
'raw-text)))
|
1998-12-10 13:37:02 +00:00
|
|
|
|
(set-buffer-multibyte nil))
|
1997-02-20 07:02:49 +00:00
|
|
|
|
;; Make `kill-buffer' quiet.
|
|
|
|
|
(set-buffer-modified-p nil))
|
1997-12-04 04:47:41 +00:00
|
|
|
|
;; Have the original buffer current while we eval.
|
2005-10-23 18:24:00 +00:00
|
|
|
|
(eval-buffer buffer nil
|
|
|
|
|
;; This is compatible with what `load' does.
|
|
|
|
|
(if purify-flag file fullname)
|
2010-08-22 17:15:20 -04:00
|
|
|
|
nil t))
|
1997-07-04 00:17:55 +00:00
|
|
|
|
(let (kill-buffer-hook kill-buffer-query-functions)
|
|
|
|
|
(kill-buffer buffer)))
|
2009-11-04 06:16:58 +00:00
|
|
|
|
(do-after-load-evaluation fullname)
|
2006-11-06 23:05:34 +00:00
|
|
|
|
|
1997-10-23 14:58:25 +00:00
|
|
|
|
(unless (or nomessage noninteractive)
|
|
|
|
|
(if source
|
|
|
|
|
(message "Loading %s (source)...done" file)
|
|
|
|
|
(message "Loading %s...done" file)))
|
1997-02-20 07:02:49 +00:00
|
|
|
|
t)))
|
|
|
|
|
|
2003-09-08 12:53:41 +00:00
|
|
|
|
(defun charset-info (charset)
|
1997-02-20 07:02:49 +00:00
|
|
|
|
"Return a vector of information of CHARSET.
|
2003-09-08 12:53:41 +00:00
|
|
|
|
This function is provided for backward compatibility.
|
1997-02-20 07:02:49 +00:00
|
|
|
|
|
|
|
|
|
The elements of the vector are:
|
|
|
|
|
CHARSET-ID, BYTES, DIMENSION, CHARS, WIDTH, DIRECTION,
|
|
|
|
|
LEADING-CODE-BASE, LEADING-CODE-EXT,
|
|
|
|
|
ISO-FINAL-CHAR, ISO-GRAPHIC-PLANE,
|
|
|
|
|
REVERSE-CHARSET, SHORT-NAME, LONG-NAME, DESCRIPTION,
|
2003-09-08 12:53:41 +00:00
|
|
|
|
PLIST.
|
1997-02-20 07:02:49 +00:00
|
|
|
|
where
|
2003-09-08 12:53:41 +00:00
|
|
|
|
CHARSET-ID is always 0.
|
|
|
|
|
BYTES is always 0.
|
|
|
|
|
DIMENSION is the number of bytes of a code-point of the charset:
|
|
|
|
|
1, 2, 3, or 4.
|
|
|
|
|
CHARS is the number of characters in a dimension:
|
|
|
|
|
94, 96, 128, or 256.
|
|
|
|
|
WIDTH is always 0.
|
|
|
|
|
DIRECTION is always 0.
|
|
|
|
|
LEADING-CODE-BASE is always 0.
|
|
|
|
|
LEADING-CODE-EXT is always 0.
|
1997-02-20 07:02:49 +00:00
|
|
|
|
ISO-FINAL-CHAR (character) is the final character of the
|
2001-01-31 00:12:02 +00:00
|
|
|
|
corresponding ISO 2022 charset. If the charset is not assigned
|
|
|
|
|
any final character, the value is -1.
|
2003-09-08 12:53:41 +00:00
|
|
|
|
ISO-GRAPHIC-PLANE is always 0.
|
|
|
|
|
REVERSE-CHARSET is always -1.
|
1997-02-20 07:02:49 +00:00
|
|
|
|
SHORT-NAME (string) is the short name to refer to the charset.
|
|
|
|
|
LONG-NAME (string) is the long name to refer to the charset
|
|
|
|
|
DESCRIPTION (string) is the description string of the charset.
|
|
|
|
|
PLIST (property list) may contain any type of information a user
|
|
|
|
|
want to put and get by functions `put-charset-property' and
|
|
|
|
|
`get-charset-property' respectively."
|
2003-09-08 12:53:41 +00:00
|
|
|
|
(vector 0
|
|
|
|
|
0
|
|
|
|
|
(charset-dimension charset)
|
|
|
|
|
(charset-chars charset)
|
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
|
(charset-iso-final-char charset)
|
|
|
|
|
0
|
|
|
|
|
-1
|
|
|
|
|
(get-charset-property charset :short-name)
|
|
|
|
|
(get-charset-property charset :short-name)
|
|
|
|
|
(charset-description charset)
|
|
|
|
|
(charset-plist charset)))
|
1997-02-20 07:02:49 +00:00
|
|
|
|
|
* international/mule-cmds.el (global-map):
Do not use backquote, because that makes a bootstrapping
problem if you need to recompile all Lisp files using interpreted code.
* international/mule.el (charset-id, charset-bytes,
charset-dimension, charset-chars, charset-width,
charset-direction, charset-iso-final-char,
charset-iso-graphic-plane, charset-reverse-charset,
charset-short-name, charset-long-name, charset-description,
charset-plist): Likewise.
* international/mule-cmds.el
(set-display-table-and-terminal-coding-system): New function,
containing code migrated out of set-language-environment.
(set-language-environment, set-locale-environment): Use it.
(locale-translation-file-name): Moved here from startup.el.
(locale-language-names, locale-preferred-coding-systems):
New vars.
(locale-name-match, set-locale-environment): New functions.
1999-10-19 07:20:09 +00:00
|
|
|
|
;; It is better not to use backquote in this file,
|
|
|
|
|
;; because that makes a bootstrapping problem
|
|
|
|
|
;; if you need to recompile all the Lisp files using interpreted code.
|
|
|
|
|
|
2003-09-08 12:53:41 +00:00
|
|
|
|
(defun charset-id (charset)
|
|
|
|
|
"Always return 0. This is provided for backward compatibility."
|
|
|
|
|
0)
|
2008-11-12 18:39:08 +00:00
|
|
|
|
(make-obsolete 'charset-id "do not use it." "23.1")
|
1997-02-20 07:02:49 +00:00
|
|
|
|
|
|
|
|
|
(defmacro charset-bytes (charset)
|
2003-09-08 12:53:41 +00:00
|
|
|
|
"Always return 0. This is provided for backward compatibility."
|
|
|
|
|
0)
|
2008-11-12 18:39:08 +00:00
|
|
|
|
(make-obsolete 'charset-bytes "do not use it." "23.1")
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
|
|
|
|
|
(defun get-charset-property (charset propname)
|
|
|
|
|
"Return the value of CHARSET's PROPNAME property.
|
|
|
|
|
This is the last value stored with
|
|
|
|
|
(put-charset-property CHARSET PROPNAME VALUE)."
|
|
|
|
|
(plist-get (charset-plist charset) propname))
|
|
|
|
|
|
|
|
|
|
(defun put-charset-property (charset propname value)
|
2002-07-11 23:08:18 +00:00
|
|
|
|
"Set CHARSETS's PROPNAME property to value VALUE.
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
It can be retrieved with `(get-charset-property CHARSET PROPNAME)'."
|
|
|
|
|
(set-charset-plist charset
|
2009-11-11 06:27:23 +00:00
|
|
|
|
(plist-put (charset-plist charset) propname
|
|
|
|
|
(if (stringp value)
|
|
|
|
|
(purecopy value)
|
|
|
|
|
value))))
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
|
|
|
|
|
(defun charset-description (charset)
|
|
|
|
|
"Return description string of CHARSET."
|
|
|
|
|
(plist-get (charset-plist charset) :docstring))
|
|
|
|
|
|
|
|
|
|
(defun charset-dimension (charset)
|
2002-06-27 21:40:53 +00:00
|
|
|
|
"Return dimension of CHARSET."
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
(plist-get (charset-plist charset) :dimension))
|
|
|
|
|
|
2002-05-31 21:53:07 +00:00
|
|
|
|
(defun charset-chars (charset &optional dimension)
|
2002-06-27 21:40:53 +00:00
|
|
|
|
"Return number of characters contained in DIMENSION of CHARSET.
|
2002-05-31 21:53:07 +00:00
|
|
|
|
DIMENSION defaults to the first dimension."
|
|
|
|
|
(unless dimension (setq dimension 1))
|
2002-05-07 04:48:27 +00:00
|
|
|
|
(let ((code-space (plist-get (charset-plist charset) :code-space)))
|
2002-05-31 21:53:07 +00:00
|
|
|
|
(1+ (- (aref code-space (1- (* 2 dimension)))
|
|
|
|
|
(aref code-space (- (* 2 dimension) 2))))))
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
|
|
|
|
|
(defun charset-iso-final-char (charset)
|
2003-02-04 19:26:38 +00:00
|
|
|
|
"Return ISO-2022 final character of CHARSET.
|
|
|
|
|
Return -1 if charset isn't an ISO 2022 one."
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
(or (plist-get (charset-plist charset) :iso-final-char)
|
|
|
|
|
-1))
|
1997-02-20 07:02:49 +00:00
|
|
|
|
|
|
|
|
|
(defmacro charset-short-name (charset)
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
"Return short name of CHARSET."
|
|
|
|
|
(plist-get (charset-plist charset) :short-name))
|
1997-02-20 07:02:49 +00:00
|
|
|
|
|
|
|
|
|
(defmacro charset-long-name (charset)
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
"Return long name of CHARSET."
|
|
|
|
|
(plist-get (charset-plist charset) :long-name))
|
1997-02-20 07:02:49 +00:00
|
|
|
|
|
1997-09-25 12:26:38 +00:00
|
|
|
|
(defun charset-list ()
|
2008-11-12 18:39:08 +00:00
|
|
|
|
"Return list of all charsets ever defined."
|
1997-09-25 12:26:38 +00:00
|
|
|
|
charset-list)
|
2008-04-18 10:17:43 +00:00
|
|
|
|
(make-obsolete 'charset-list "use variable `charset-list'." "23.1")
|
1997-09-25 12:26:38 +00:00
|
|
|
|
|
2003-11-17 03:57:03 +00:00
|
|
|
|
|
|
|
|
|
;;; CHARACTER
|
2008-11-12 18:39:08 +00:00
|
|
|
|
(define-obsolete-function-alias 'char-valid-p 'characterp "23.1")
|
2003-11-17 03:57:03 +00:00
|
|
|
|
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
(defun generic-char-p (char)
|
2003-09-08 12:53:41 +00:00
|
|
|
|
"Always return nil. This is provided for backward compatibility."
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
nil)
|
2008-04-18 10:17:43 +00:00
|
|
|
|
(make-obsolete 'generic-char-p "generic characters no longer exist." "23.1")
|
2003-11-17 03:57:03 +00:00
|
|
|
|
|
|
|
|
|
(defun make-char-internal (charset-id &optional code1 code2)
|
|
|
|
|
(let ((charset (aref emacs-mule-charset-table charset-id)))
|
|
|
|
|
(or charset
|
|
|
|
|
(error "Invalid Emacs-mule charset ID: %d" charset-id))
|
|
|
|
|
(make-char charset code1 code2)))
|
1997-10-21 10:47:35 +00:00
|
|
|
|
|
2007-04-04 15:34:59 +00:00
|
|
|
|
;; Save the ASCII case table in case we need it later. Some locales
|
|
|
|
|
;; (such as Turkish) modify the case behavior of ASCII characters,
|
|
|
|
|
;; which can interfere with networking code that uses ASCII strings.
|
|
|
|
|
|
|
|
|
|
(defvar ascii-case-table
|
|
|
|
|
;; Code copied from copy-case-table to avoid requiring case-table.el
|
|
|
|
|
(let ((tbl (copy-sequence (standard-case-table)))
|
|
|
|
|
(up (char-table-extra-slot (standard-case-table) 0)))
|
|
|
|
|
(if up (set-char-table-extra-slot tbl 0 (copy-sequence up)))
|
|
|
|
|
(set-char-table-extra-slot tbl 1 nil)
|
|
|
|
|
(set-char-table-extra-slot tbl 2 nil)
|
|
|
|
|
tbl)
|
|
|
|
|
"Case table for the ASCII character set.")
|
|
|
|
|
|
2000-12-06 18:48:59 +00:00
|
|
|
|
;; Coding system stuff
|
1997-02-20 07:02:49 +00:00
|
|
|
|
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
;; Coding system is a symbol that has been defined by the function
|
|
|
|
|
;; `define-coding-system'.
|
1997-02-20 07:02:49 +00:00
|
|
|
|
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
(defconst coding-system-iso-2022-flags
|
|
|
|
|
'(long-form
|
|
|
|
|
ascii-at-eol
|
|
|
|
|
ascii-at-cntl
|
|
|
|
|
7-bit
|
|
|
|
|
locking-shift
|
|
|
|
|
single-shift
|
|
|
|
|
designation
|
|
|
|
|
revision
|
|
|
|
|
direction
|
|
|
|
|
init-at-bol
|
|
|
|
|
designate-at-bol
|
|
|
|
|
safe
|
|
|
|
|
latin-extra
|
|
|
|
|
composition
|
2002-05-30 11:05:50 +00:00
|
|
|
|
euc-tw-shift
|
|
|
|
|
use-roman
|
|
|
|
|
use-oldjis)
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
"List of symbols that control ISO-2022 encoder/decoder.
|
1997-02-20 07:02:49 +00:00
|
|
|
|
|
2002-06-27 21:40:53 +00:00
|
|
|
|
The value of the `:flags' attribute in the argument of the function
|
2002-05-26 00:01:51 +00:00
|
|
|
|
`define-coding-system' must be one of them.
|
1997-02-20 07:02:49 +00:00
|
|
|
|
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
If `long-form' is specified, use a long designation sequence on
|
|
|
|
|
encoding for the charsets `japanese-jisx0208-1978', `chinese-gb2312',
|
|
|
|
|
and `japanese-jisx0208'. The long designation sequence doesn't
|
2002-06-27 21:40:53 +00:00
|
|
|
|
conform to ISO 2022, but is used by such coding systems as
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
`compound-text'.
|
|
|
|
|
|
|
|
|
|
If `ascii-at-eol' is specified, designate ASCII to g0 at end of line
|
|
|
|
|
on encoding.
|
|
|
|
|
|
|
|
|
|
If `ascii-at-cntl' is specified, designate ASCII to g0 before control
|
|
|
|
|
codes and SPC on encoding.
|
|
|
|
|
|
|
|
|
|
If `7-bit' is specified, use 7-bit code only on encoding.
|
|
|
|
|
|
|
|
|
|
If `locking-shift' is specified, decode locking-shift code correctly
|
|
|
|
|
on decoding, and use locking-shift to invoke a graphic element on
|
|
|
|
|
encoding.
|
|
|
|
|
|
|
|
|
|
If `single-shift' is specified, decode single-shift code correctly on
|
|
|
|
|
decoding, and use single-shift to invoke a graphic element on encoding.
|
|
|
|
|
|
|
|
|
|
If `designation' is specified, decode designation code correctly on
|
|
|
|
|
decoding, and use designation to designate a charset to a graphic
|
|
|
|
|
element on encoding.
|
|
|
|
|
|
|
|
|
|
If `revision' is specified, produce an escape sequence to specify
|
|
|
|
|
revision number of a charset on encoding. Such an escape sequence is
|
|
|
|
|
always correctly decoded on decoding.
|
|
|
|
|
|
|
|
|
|
If `direction' is specified, decode ISO6429's code for specifying
|
2002-06-27 21:40:53 +00:00
|
|
|
|
direction correctly, and produce the code on encoding.
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
|
|
|
|
|
If `init-at-bol' is specified, on encoding, it is assumed that
|
|
|
|
|
invocation and designation statuses are reset at each beginning of
|
2002-06-27 21:40:53 +00:00
|
|
|
|
line even if `ascii-at-eol' is not specified; thus no codes for
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
resetting them are produced.
|
|
|
|
|
|
|
|
|
|
If `safe' is specified, on encoding, characters not supported by a
|
|
|
|
|
coding are replaced with `?'.
|
|
|
|
|
|
2002-06-27 21:40:53 +00:00
|
|
|
|
If `latin-extra' is specified, the code-detection routine assumes that a
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
code specified in `latin-extra-code-table' (which see) is valid.
|
|
|
|
|
|
|
|
|
|
If `composition' is specified, an escape sequence to specify
|
2002-06-27 21:40:53 +00:00
|
|
|
|
composition sequence is correctly decoded on decoding, and is produced
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
on encoding.
|
|
|
|
|
|
|
|
|
|
If `euc-tw-shift' is specified, the EUC-TW specific shifting code is
|
2002-06-27 21:40:53 +00:00
|
|
|
|
correctly decoded on decoding, and is produced on encoding.
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
|
2002-06-27 21:40:53 +00:00
|
|
|
|
If `use-roman' is specified, JIS0201-1976-Roman is designated instead
|
|
|
|
|
of ASCII.
|
|
|
|
|
|
|
|
|
|
If `use-oldjis' is specified, JIS0208-1976 is designated instead of
|
|
|
|
|
JIS0208-1983.")
|
|
|
|
|
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
(defun define-coding-system (name docstring &rest props)
|
2002-06-27 21:40:53 +00:00
|
|
|
|
"Define NAME (a symbol) as a coding system with DOCSTRING and attributes.
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
The remaining arguments must come in pairs ATTRIBUTE VALUE. ATTRIBUTE
|
|
|
|
|
may be any symbol.
|
|
|
|
|
|
2002-06-27 21:40:53 +00:00
|
|
|
|
The following attributes have special meanings. Those labeled as
|
2009-01-07 14:24:29 +00:00
|
|
|
|
\"(required)\" should not be omitted.
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
|
|
|
|
|
`:mnemonic' (required)
|
|
|
|
|
|
|
|
|
|
VALUE is a character to display on mode line for the coding system.
|
|
|
|
|
|
|
|
|
|
`:coding-type' (required)
|
|
|
|
|
|
|
|
|
|
VALUE must be one of `charset', `utf-8', `utf-16', `iso-2022',
|
2003-05-23 23:32:28 +00:00
|
|
|
|
`emacs-mule', `shift-jis', `ccl', `raw-text', `undecided'.
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
|
2002-06-27 21:40:53 +00:00
|
|
|
|
`:eol-type'
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
|
2002-06-27 21:40:53 +00:00
|
|
|
|
VALUE is the EOL (end-of-line) format of the coding system. It must be
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
one of `unix', `dos', `mac'. The symbol `unix' means Unix-like EOL
|
|
|
|
|
\(i.e. single LF), `dos' means DOS-like EOL \(i.e. sequence of CR LF),
|
2010-05-30 22:47:34 +03:00
|
|
|
|
and `mac' means Mac-like EOL \(i.e. single CR). If omitted, Emacs
|
|
|
|
|
detects the EOL format automatically when decoding.
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
|
2002-09-12 08:36:59 +00:00
|
|
|
|
`:charset-list'
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
|
|
|
|
|
VALUE must be a list of charsets supported by the coding system. On
|
|
|
|
|
encoding by the coding system, if a character belongs to multiple
|
|
|
|
|
charsets in the list, a charset that comes earlier in the list is
|
2002-09-12 08:36:59 +00:00
|
|
|
|
selected. If `:coding-type' is `iso-2022', VALUE may be `iso-2022',
|
|
|
|
|
which indicates that the coding system supports all ISO-2022 based
|
|
|
|
|
charsets. If `:coding-type' is `emacs-mule', VALUE may be
|
|
|
|
|
`emacs-mule', which indicates that the coding system supports all
|
2003-02-04 19:26:38 +00:00
|
|
|
|
charsets that have the `:emacs-mule-id' property.
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
|
2002-06-27 21:40:53 +00:00
|
|
|
|
`:ascii-compatible-p'
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
|
|
|
|
|
If VALUE is non-nil, the coding system decodes all 7-bit bytes into
|
2002-05-17 16:51:14 +00:00
|
|
|
|
the corresponding ASCII characters, and encodes all ASCII characters
|
2002-06-27 21:40:53 +00:00
|
|
|
|
back to the corresponding 7-bit bytes. VALUE defaults to nil.
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
|
2002-06-27 21:40:53 +00:00
|
|
|
|
`:decode-translation-table'
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
|
|
|
|
|
VALUE must be a translation table to use on decoding.
|
|
|
|
|
|
2002-06-27 21:40:53 +00:00
|
|
|
|
`:encode-translation-table'
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
|
|
|
|
|
VALUE must be a translation table to use on encoding.
|
|
|
|
|
|
2002-06-27 21:40:53 +00:00
|
|
|
|
`:post-read-conversion'
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
|
|
|
|
|
VALUE must be a function to call after some text is inserted and
|
|
|
|
|
decoded by the coding system itself and before any functions in
|
2010-09-27 13:52:56 +09:00
|
|
|
|
`after-insert-functions' are called. This function is passed one
|
|
|
|
|
argument; the number of characters in the text to convert, with
|
|
|
|
|
point at the start of the text. The function should leave point
|
|
|
|
|
the same, and return the new character count.
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
|
|
|
|
|
`:pre-write-conversion'
|
|
|
|
|
|
|
|
|
|
VALUE must be a function to call after all functions in
|
2010-09-27 13:52:56 +09:00
|
|
|
|
`write-region-annotate-functions' and `buffer-file-format' are
|
|
|
|
|
called, and before the text is encoded by the coding system
|
|
|
|
|
itself. This function should convert the whole text in the
|
2010-10-13 01:25:19 +02:00
|
|
|
|
current buffer. For backward compatibility, this function is
|
2010-09-27 13:52:56 +09:00
|
|
|
|
passed two arguments which can be ignored.
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
|
|
|
|
|
`:default-char'
|
|
|
|
|
|
|
|
|
|
VALUE must be a character. On encoding, a character not supported by
|
|
|
|
|
the coding system is replaced with VALUE.
|
|
|
|
|
|
2003-09-08 12:53:41 +00:00
|
|
|
|
`:for-unibyte'
|
|
|
|
|
|
|
|
|
|
VALUE non-nil means that visiting a file with the coding system
|
|
|
|
|
results in a unibyte buffer.
|
|
|
|
|
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
`:mime-charset'
|
|
|
|
|
|
2002-06-27 21:40:53 +00:00
|
|
|
|
VALUE must be a symbol whose name is that of a MIME charset converted
|
|
|
|
|
to lower case.
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
|
2003-05-23 23:32:28 +00:00
|
|
|
|
`:mime-text-unsuitable'
|
|
|
|
|
|
|
|
|
|
VALUE non-nil means the `:mime-charset' property names a charset which
|
2003-05-28 11:41:17 +00:00
|
|
|
|
is unsuitable for the top-level media type \"text\".
|
2003-05-23 23:32:28 +00:00
|
|
|
|
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
`:flags'
|
|
|
|
|
|
2002-06-27 21:40:53 +00:00
|
|
|
|
VALUE must be a list of symbols that control the ISO-2022 converter.
|
|
|
|
|
Each must be a member of the list `coding-system-iso-2022-flags'
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
\(which see). This attribute has a meaning only when `:coding-type'
|
|
|
|
|
is `iso-2022'.
|
|
|
|
|
|
|
|
|
|
`:designation'
|
|
|
|
|
|
2002-06-27 21:40:53 +00:00
|
|
|
|
VALUE must be a vector [G0-USAGE G1-USAGE G2-USAGE G3-USAGE].
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
GN-USAGE specifies the usage of graphic register GN as follows.
|
|
|
|
|
|
|
|
|
|
If it is nil, no charset can be designated to GN.
|
|
|
|
|
|
2002-05-17 16:51:14 +00:00
|
|
|
|
If it is a charset, the charset is initially designated to GN, and
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
never used by the other charsets.
|
|
|
|
|
|
|
|
|
|
If it is a list, the elements must be charsets, nil, 94, or 96. GN
|
2002-06-27 21:40:53 +00:00
|
|
|
|
can be used by all the listed charsets. If the list contains 94, any
|
|
|
|
|
iso-2022 charset whose code-space ranges are 94 long can be designated
|
|
|
|
|
to GN. If the list contains 96, any charsets whose whose ranges are
|
|
|
|
|
96 long can be designated to GN. If the first element is a charset,
|
|
|
|
|
that charset is initially designated to GN.
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
|
|
|
|
|
This attribute has a meaning only when `:coding-type' is `iso-2022'.
|
|
|
|
|
|
|
|
|
|
`:bom'
|
|
|
|
|
|
2002-06-27 21:40:53 +00:00
|
|
|
|
This attributes specifies whether the coding system uses a `byte order
|
2009-01-07 14:24:29 +00:00
|
|
|
|
mark'. VALUE must be nil, t, or cons of coding systems whose
|
2009-01-07 12:33:14 +00:00
|
|
|
|
`:coding-type' is `utf-16' or `utf-8'.
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
|
2003-05-06 12:29:02 +00:00
|
|
|
|
If the value is nil, on decoding, don't treat the first two-byte as
|
|
|
|
|
BOM, and on encoding, don't produce BOM bytes.
|
|
|
|
|
|
|
|
|
|
If the value is t, on decoding, skip the first two-byte as BOM, and on
|
|
|
|
|
encoding, produce BOM bytes accoding to the value of `:endian'.
|
|
|
|
|
|
2009-01-06 02:05:34 +00:00
|
|
|
|
If the value is cons, on decoding, check the first two-byte. If they
|
2003-05-06 12:29:02 +00:00
|
|
|
|
are 0xFE 0xFF, use the car part coding system of the value. If they
|
2009-01-06 02:05:34 +00:00
|
|
|
|
are 0xFF 0xFE, use the cdr part coding system of the value.
|
2003-05-06 12:29:02 +00:00
|
|
|
|
Otherwise, treat them as bytes for a normal character. On encoding,
|
|
|
|
|
produce BOM bytes accoding to the value of `:endian'.
|
|
|
|
|
|
2009-01-07 14:24:29 +00:00
|
|
|
|
This attribute has a meaning only when `:coding-type' is `utf-16' or
|
|
|
|
|
`utf-8'.
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
|
|
|
|
|
`:endian'
|
|
|
|
|
|
2003-05-06 12:29:02 +00:00
|
|
|
|
VALUE must be `big' or `little' specifying big-endian and
|
|
|
|
|
little-endian respectively. The default value is `big'.
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
|
|
|
|
|
This attribute has a meaning only when `:coding-type' is `utf-16'.
|
|
|
|
|
|
|
|
|
|
`:ccl-decoder'
|
|
|
|
|
|
2002-06-27 21:40:53 +00:00
|
|
|
|
VALUE is a symbol representing the registered CCL program used for
|
|
|
|
|
decoding. This attribute has a meaning only when `:coding-type' is
|
|
|
|
|
`ccl'.
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
|
|
|
|
|
`:ccl-encoder'
|
|
|
|
|
|
2002-06-27 21:40:53 +00:00
|
|
|
|
VALUE is a symbol representing the registered CCL program used for
|
|
|
|
|
encoding. This attribute has a meaning only when `:coding-type' is
|
|
|
|
|
`ccl'."
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
(let* ((common-attrs (mapcar 'list
|
|
|
|
|
'(:mnemonic
|
|
|
|
|
:coding-type
|
|
|
|
|
:charset-list
|
|
|
|
|
:ascii-compatible-p
|
2002-10-15 01:19:59 +00:00
|
|
|
|
:decode-translation-table
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
:encode-translation-table
|
|
|
|
|
:post-read-conversion
|
|
|
|
|
:pre-write-conversion
|
|
|
|
|
:default-char
|
2003-09-28 23:56:11 +00:00
|
|
|
|
:for-unibyte
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
:plist
|
|
|
|
|
:eol-type)))
|
|
|
|
|
(coding-type (plist-get props :coding-type))
|
|
|
|
|
(spec-attrs (mapcar 'list
|
|
|
|
|
(cond ((eq coding-type 'iso-2022)
|
|
|
|
|
'(:initial
|
|
|
|
|
:reg-usage
|
|
|
|
|
:request
|
|
|
|
|
:flags))
|
2008-05-29 22:58:58 +00:00
|
|
|
|
((eq coding-type 'utf-8)
|
|
|
|
|
'(:bom))
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
((eq coding-type 'utf-16)
|
|
|
|
|
'(:bom
|
|
|
|
|
:endian))
|
|
|
|
|
((eq coding-type 'ccl)
|
|
|
|
|
'(:ccl-decoder
|
|
|
|
|
:ccl-encoder
|
|
|
|
|
:valids))))))
|
|
|
|
|
|
|
|
|
|
(dolist (slot common-attrs)
|
|
|
|
|
(setcdr slot (plist-get props (car slot))))
|
|
|
|
|
|
|
|
|
|
(dolist (slot spec-attrs)
|
|
|
|
|
(setcdr slot (plist-get props (car slot))))
|
|
|
|
|
|
|
|
|
|
(if (eq coding-type 'iso-2022)
|
|
|
|
|
(let ((designation (plist-get props :designation))
|
|
|
|
|
(flags (plist-get props :flags))
|
|
|
|
|
(initial (make-vector 4 nil))
|
|
|
|
|
(reg-usage (cons 4 4))
|
|
|
|
|
request elt)
|
|
|
|
|
(dotimes (i 4)
|
|
|
|
|
(setq elt (aref designation i))
|
|
|
|
|
(cond ((charsetp elt)
|
|
|
|
|
(aset initial i elt)
|
|
|
|
|
(setq request (cons (cons elt i) request)))
|
|
|
|
|
((consp elt)
|
|
|
|
|
(aset initial i (car elt))
|
|
|
|
|
(if (charsetp (car elt))
|
|
|
|
|
(setq request (cons (cons (car elt) i) request)))
|
|
|
|
|
(dolist (e (cdr elt))
|
|
|
|
|
(cond ((charsetp e)
|
|
|
|
|
(setq request (cons (cons e i) request)))
|
|
|
|
|
((eq e 94)
|
|
|
|
|
(setcar reg-usage i))
|
|
|
|
|
((eq e 96)
|
|
|
|
|
(setcdr reg-usage i))
|
|
|
|
|
((eq e t)
|
|
|
|
|
(setcar reg-usage i)
|
|
|
|
|
(setcdr reg-usage i)))))))
|
|
|
|
|
(setcdr (assq :initial spec-attrs) initial)
|
|
|
|
|
(setcdr (assq :reg-usage spec-attrs) reg-usage)
|
|
|
|
|
(setcdr (assq :request spec-attrs) request)
|
|
|
|
|
|
|
|
|
|
;; Change :flags value from a list to a bit-mask.
|
|
|
|
|
(let ((bits 0)
|
|
|
|
|
(i 0))
|
|
|
|
|
(dolist (elt coding-system-iso-2022-flags)
|
|
|
|
|
(if (memq elt flags)
|
|
|
|
|
(setq bits (logior bits (lsh 1 i))))
|
|
|
|
|
(setq i (1+ i)))
|
|
|
|
|
(setcdr (assq :flags spec-attrs) bits))))
|
|
|
|
|
|
|
|
|
|
;; Add :name and :docstring properties to PROPS.
|
|
|
|
|
(setq props
|
2002-05-17 20:17:04 +00:00
|
|
|
|
(cons :name (cons name (cons :docstring (cons (purecopy docstring)
|
|
|
|
|
props)))))
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
(setcdr (assq :plist common-attrs) props)
|
2008-04-18 10:17:43 +00:00
|
|
|
|
(apply 'define-coding-system-internal
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
name (mapcar 'cdr (append common-attrs spec-attrs)))))
|
1997-02-20 07:02:49 +00:00
|
|
|
|
|
1997-06-10 00:56:15 +00:00
|
|
|
|
(defun coding-system-doc-string (coding-system)
|
1997-10-21 10:47:35 +00:00
|
|
|
|
"Return the documentation string for CODING-SYSTEM."
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
(plist-get (coding-system-plist coding-system) :docstring))
|
1997-02-20 07:02:49 +00:00
|
|
|
|
|
|
|
|
|
(defun coding-system-mnemonic (coding-system)
|
1997-10-21 10:47:35 +00:00
|
|
|
|
"Return the mnemonic character of CODING-SYSTEM.
|
2002-06-27 21:40:53 +00:00
|
|
|
|
The mnemonic character of a coding system is used in mode line to
|
2008-05-14 11:46:24 +00:00
|
|
|
|
indicate the coding system. If CODING-SYSTEM is nil, return ?=."
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
(plist-get (coding-system-plist coding-system) :mnemonic))
|
1997-02-20 07:02:49 +00:00
|
|
|
|
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
(defun coding-system-type (coding-system)
|
|
|
|
|
"Return the coding type of CODING-SYSTEM.
|
|
|
|
|
A coding type is a symbol indicating the encoding method of CODING-SYSTEM.
|
|
|
|
|
See the function `define-coding-system' for more detail."
|
|
|
|
|
(plist-get (coding-system-plist coding-system) :coding-type))
|
1997-09-25 12:26:38 +00:00
|
|
|
|
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
(defun coding-system-charset-list (coding-system)
|
2002-05-17 16:51:14 +00:00
|
|
|
|
"Return list of charsets supported by CODING-SYSTEM.
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
If CODING-SYSTEM supports all ISO-2022 charsets, return `iso-2022'.
|
|
|
|
|
If CODING-SYSTEM supports all emacs-mule charsets, return `emacs-mule'."
|
|
|
|
|
(plist-get (coding-system-plist coding-system) :charset-list))
|
1997-10-21 10:47:35 +00:00
|
|
|
|
|
2003-06-10 01:24:23 +00:00
|
|
|
|
(defun coding-system-category (coding-system)
|
|
|
|
|
"Return a category symbol of CODING-SYSTEM."
|
|
|
|
|
(plist-get (coding-system-plist coding-system) :category))
|
1997-10-21 10:47:35 +00:00
|
|
|
|
|
|
|
|
|
(defun coding-system-get (coding-system prop)
|
2002-05-17 16:51:14 +00:00
|
|
|
|
"Extract a value from CODING-SYSTEM's property list for property PROP.
|
|
|
|
|
For compatibility with Emacs 20/21, this accepts old-style symbols
|
|
|
|
|
like `mime-charset' as well as the current style like `:mime-charset'."
|
|
|
|
|
(or (plist-get (coding-system-plist coding-system) prop)
|
|
|
|
|
(if (not (keywordp prop))
|
2009-10-26 15:18:03 +00:00
|
|
|
|
;; For backward compatibility.
|
2005-07-29 06:17:39 +00:00
|
|
|
|
(if (eq prop 'ascii-incompatible)
|
|
|
|
|
(not (plist-get (coding-system-plist coding-system)
|
|
|
|
|
:ascii-compatible-p))
|
|
|
|
|
(plist-get (coding-system-plist coding-system)
|
|
|
|
|
(intern (concat ":" (symbol-name prop))))))))
|
1997-10-21 10:47:35 +00:00
|
|
|
|
|
2002-11-05 10:42:25 +00:00
|
|
|
|
(defun coding-system-eol-type-mnemonic (coding-system)
|
|
|
|
|
"Return the string indicating end-of-line format of CODING-SYSTEM."
|
|
|
|
|
(let* ((eol-type (coding-system-eol-type coding-system))
|
2002-11-06 01:07:49 +00:00
|
|
|
|
(val (cond ((eq eol-type 0) eol-mnemonic-unix)
|
2002-11-05 10:42:25 +00:00
|
|
|
|
((eq eol-type 1) eol-mnemonic-dos)
|
|
|
|
|
((eq eol-type 2) eol-mnemonic-mac)
|
2002-11-06 01:07:49 +00:00
|
|
|
|
(t eol-mnemonic-undecided))))
|
2002-11-05 10:42:25 +00:00
|
|
|
|
(if (stringp val)
|
|
|
|
|
val
|
|
|
|
|
(char-to-string val))))
|
|
|
|
|
|
1999-02-08 09:50:26 +00:00
|
|
|
|
(defun coding-system-lessp (x y)
|
|
|
|
|
(cond ((eq x 'no-conversion) t)
|
|
|
|
|
((eq y 'no-conversion) nil)
|
|
|
|
|
((eq x 'emacs-mule) t)
|
|
|
|
|
((eq y 'emacs-mule) nil)
|
|
|
|
|
((eq x 'undecided) t)
|
|
|
|
|
((eq y 'undecided) nil)
|
|
|
|
|
(t (let ((c1 (coding-system-mnemonic x))
|
|
|
|
|
(c2 (coding-system-mnemonic y)))
|
|
|
|
|
(or (< (downcase c1) (downcase c2))
|
|
|
|
|
(and (not (> (downcase c1) (downcase c2)))
|
|
|
|
|
(< c1 c2)))))))
|
|
|
|
|
|
2004-10-12 05:26:29 +00:00
|
|
|
|
(defun coding-system-equal (coding-system-1 coding-system-2)
|
|
|
|
|
"Return t if and only if CODING-SYSTEM-1 and CODING-SYSTEM-2 are identical.
|
2008-11-12 18:39:08 +00:00
|
|
|
|
Two coding systems are identical if both symbols are equal
|
2004-10-12 05:26:29 +00:00
|
|
|
|
or one is an alias of the other."
|
|
|
|
|
(or (eq coding-system-1 coding-system-2)
|
2004-10-16 00:23:39 +00:00
|
|
|
|
(and (equal (coding-system-plist coding-system-1)
|
|
|
|
|
(coding-system-plist coding-system-2))
|
2004-10-12 05:26:29 +00:00
|
|
|
|
(let ((eol-type-1 (coding-system-eol-type coding-system-1))
|
|
|
|
|
(eol-type-2 (coding-system-eol-type coding-system-2)))
|
|
|
|
|
(or (eq eol-type-1 eol-type-2)
|
|
|
|
|
(and (vectorp eol-type-1) (vectorp eol-type-2)))))))
|
|
|
|
|
|
1999-02-08 09:50:26 +00:00
|
|
|
|
(defun add-to-coding-system-list (coding-system)
|
2001-02-11 17:07:35 +00:00
|
|
|
|
"Add CODING-SYSTEM to `coding-system-list' while keeping it sorted."
|
1999-02-08 09:50:26 +00:00
|
|
|
|
(if (or (null coding-system-list)
|
|
|
|
|
(coding-system-lessp coding-system (car coding-system-list)))
|
|
|
|
|
(setq coding-system-list (cons coding-system coding-system-list))
|
|
|
|
|
(let ((len (length coding-system-list))
|
|
|
|
|
mid (tem coding-system-list))
|
|
|
|
|
(while (> len 1)
|
|
|
|
|
(setq mid (nthcdr (/ len 2) tem))
|
|
|
|
|
(if (coding-system-lessp (car mid) coding-system)
|
|
|
|
|
(setq tem mid
|
|
|
|
|
len (- len (/ len 2)))
|
|
|
|
|
(setq len (/ len 2))))
|
|
|
|
|
(setcdr tem (cons coding-system (cdr tem))))))
|
|
|
|
|
|
1999-02-18 13:11:24 +00:00
|
|
|
|
(defun coding-system-list (&optional base-only)
|
2000-07-27 06:08:14 +00:00
|
|
|
|
"Return a list of all existing non-subsidiary coding systems.
|
2002-06-27 21:40:53 +00:00
|
|
|
|
If optional arg BASE-ONLY is non-nil, only base coding systems are
|
|
|
|
|
listed. The value doesn't include subsidiary coding systems which are
|
2000-07-27 06:08:14 +00:00
|
|
|
|
made from bases and aliases automatically for various end-of-line
|
|
|
|
|
formats (e.g. iso-latin-1-unix, koi8-r-dos)."
|
2006-10-17 11:45:46 +00:00
|
|
|
|
(let ((codings nil))
|
|
|
|
|
(dolist (coding coding-system-list)
|
|
|
|
|
(if (eq (coding-system-base coding) coding)
|
|
|
|
|
(if base-only
|
|
|
|
|
(setq codings (cons coding codings))
|
|
|
|
|
(dolist (alias (coding-system-aliases coding))
|
|
|
|
|
(setq codings (cons alias codings))))))
|
1999-02-18 13:11:24 +00:00
|
|
|
|
codings))
|
|
|
|
|
|
2003-03-18 04:11:32 +00:00
|
|
|
|
(defconst char-coding-system-table nil
|
2008-04-18 10:17:43 +00:00
|
|
|
|
"It exists just for backward compatibility, and the value is always nil.")
|
|
|
|
|
(make-obsolete-variable 'char-coding-system-table nil "23.1")
|
2000-07-27 06:08:14 +00:00
|
|
|
|
|
2001-01-16 10:37:43 +00:00
|
|
|
|
(defun transform-make-coding-system-args (name type &optional doc-string props)
|
|
|
|
|
"For internal use only.
|
|
|
|
|
Transform XEmacs style args for `make-coding-system' to Emacs style.
|
|
|
|
|
Value is a list of transformed arguments."
|
|
|
|
|
(let ((mnemonic (string-to-char (or (plist-get props 'mnemonic) "?")))
|
|
|
|
|
(eol-type (plist-get props 'eol-type))
|
|
|
|
|
properties tmp)
|
|
|
|
|
(cond
|
|
|
|
|
((eq eol-type 'lf) (setq eol-type 'unix))
|
|
|
|
|
((eq eol-type 'crlf) (setq eol-type 'dos))
|
|
|
|
|
((eq eol-type 'cr) (setq eol-type 'mac)))
|
|
|
|
|
(if (setq tmp (plist-get props 'post-read-conversion))
|
|
|
|
|
(setq properties (plist-put properties 'post-read-conversion tmp)))
|
|
|
|
|
(if (setq tmp (plist-get props 'pre-write-conversion))
|
|
|
|
|
(setq properties (plist-put properties 'pre-write-conversion tmp)))
|
|
|
|
|
(cond
|
2001-02-06 23:39:26 +00:00
|
|
|
|
((eq type 'shift-jis)
|
|
|
|
|
`(,name 1 ,mnemonic ,doc-string () ,properties ,eol-type))
|
|
|
|
|
((eq type 'iso2022) ; This is not perfect.
|
|
|
|
|
(if (plist-get props 'escape-quoted)
|
|
|
|
|
(error "escape-quoted is not supported: %S"
|
|
|
|
|
`(,name ,type ,doc-string ,props)))
|
|
|
|
|
(let ((g0 (plist-get props 'charset-g0))
|
|
|
|
|
(g1 (plist-get props 'charset-g1))
|
|
|
|
|
(g2 (plist-get props 'charset-g2))
|
|
|
|
|
(g3 (plist-get props 'charset-g3))
|
|
|
|
|
(use-roman
|
|
|
|
|
(and
|
|
|
|
|
(eq (cadr (assoc 'latin-jisx0201
|
|
|
|
|
(plist-get props 'input-charset-conversion)))
|
|
|
|
|
'ascii)
|
|
|
|
|
(eq (cadr (assoc 'ascii
|
|
|
|
|
(plist-get props 'output-charset-conversion)))
|
|
|
|
|
'latin-jisx0201)))
|
|
|
|
|
(use-oldjis
|
|
|
|
|
(and
|
|
|
|
|
(eq (cadr (assoc 'japanese-jisx0208-1978
|
|
|
|
|
(plist-get props 'input-charset-conversion)))
|
|
|
|
|
'japanese-jisx0208)
|
|
|
|
|
(eq (cadr (assoc 'japanese-jisx0208
|
|
|
|
|
(plist-get props 'output-charset-conversion)))
|
|
|
|
|
'japanese-jisx0208-1978))))
|
|
|
|
|
(if (charsetp g0)
|
|
|
|
|
(if (plist-get props 'force-g0-on-output)
|
|
|
|
|
(setq g0 `(nil ,g0))
|
|
|
|
|
(setq g0 `(,g0 t))))
|
|
|
|
|
(if (charsetp g1)
|
|
|
|
|
(if (plist-get props 'force-g1-on-output)
|
|
|
|
|
(setq g1 `(nil ,g1))
|
|
|
|
|
(setq g1 `(,g1 t))))
|
|
|
|
|
(if (charsetp g2)
|
|
|
|
|
(if (plist-get props 'force-g2-on-output)
|
|
|
|
|
(setq g2 `(nil ,g2))
|
|
|
|
|
(setq g2 `(,g2 t))))
|
|
|
|
|
(if (charsetp g3)
|
|
|
|
|
(if (plist-get props 'force-g3-on-output)
|
|
|
|
|
(setq g3 `(nil ,g3))
|
|
|
|
|
(setq g3 `(,g3 t))))
|
|
|
|
|
`(,name 2 ,mnemonic ,doc-string
|
|
|
|
|
(,g0 ,g1 ,g2 ,g3
|
|
|
|
|
,(plist-get props 'short)
|
|
|
|
|
,(not (plist-get props 'no-ascii-eol))
|
|
|
|
|
,(not (plist-get props 'no-ascii-cntl))
|
|
|
|
|
,(plist-get props 'seven)
|
|
|
|
|
t
|
|
|
|
|
,(not (plist-get props 'lock-shift))
|
|
|
|
|
,use-roman
|
|
|
|
|
,use-oldjis
|
|
|
|
|
,(plist-get props 'no-iso6429)
|
|
|
|
|
nil nil nil nil)
|
|
|
|
|
,properties ,eol-type)))
|
|
|
|
|
((eq type 'big5)
|
|
|
|
|
`(,name 3 ,mnemonic ,doc-string () ,properties ,eol-type))
|
2001-01-16 10:37:43 +00:00
|
|
|
|
((eq type 'ccl)
|
2001-02-06 23:39:26 +00:00
|
|
|
|
`(,name 4 ,mnemonic ,doc-string
|
2001-01-16 10:37:43 +00:00
|
|
|
|
(,(plist-get props 'decode) . ,(plist-get props 'encode))
|
2001-02-06 23:39:26 +00:00
|
|
|
|
,properties ,eol-type))
|
2001-01-16 10:37:43 +00:00
|
|
|
|
(t
|
2001-02-06 23:39:26 +00:00
|
|
|
|
(error "unsupported XEmacs style make-coding-style arguments: %S"
|
2001-01-16 10:37:43 +00:00
|
|
|
|
`(,name ,type ,doc-string ,props))))))
|
|
|
|
|
|
1997-06-10 00:56:15 +00:00
|
|
|
|
(defun make-coding-system (coding-system type mnemonic doc-string
|
2000-03-07 06:15:36 +00:00
|
|
|
|
&optional
|
|
|
|
|
flags
|
|
|
|
|
properties
|
|
|
|
|
eol-type)
|
1998-04-20 02:11:52 +00:00
|
|
|
|
"Define a new coding system CODING-SYSTEM (symbol).
|
2008-11-12 18:39:08 +00:00
|
|
|
|
This function is provided for backward compatibility."
|
2009-10-26 15:18:03 +00:00
|
|
|
|
;; For compatibility with XEmacs, we check the type of TYPE. If it
|
2001-01-25 13:00:13 +00:00
|
|
|
|
;; is a symbol, perhaps, this function is called with XEmacs-style
|
|
|
|
|
;; arguments. Here, try to transform that kind of arguments to
|
2001-01-16 10:37:43 +00:00
|
|
|
|
;; Emacs style.
|
|
|
|
|
(if (symbolp type)
|
|
|
|
|
(let ((args (transform-make-coding-system-args coding-system type
|
|
|
|
|
mnemonic doc-string)))
|
|
|
|
|
(setq coding-system (car args)
|
2001-01-23 17:35:03 +00:00
|
|
|
|
type (nth 1 args)
|
2001-01-16 10:37:43 +00:00
|
|
|
|
mnemonic (nth 2 args)
|
|
|
|
|
doc-string (nth 3 args)
|
|
|
|
|
flags (nth 4 args)
|
|
|
|
|
properties (nth 5 args)
|
|
|
|
|
eol-type (nth 6 args))))
|
|
|
|
|
|
2003-09-08 12:53:41 +00:00
|
|
|
|
(setq type
|
|
|
|
|
(cond ((eq type 0) 'emacs-mule)
|
|
|
|
|
((eq type 1) 'shift-jis)
|
|
|
|
|
((eq type 2) 'iso2022)
|
|
|
|
|
((eq type 3) 'big5)
|
|
|
|
|
((eq type 4) 'ccl)
|
|
|
|
|
((eq type 5) 'raw-text)
|
2000-03-07 06:15:36 +00:00
|
|
|
|
(t
|
2003-09-08 12:53:41 +00:00
|
|
|
|
(error "Invalid coding system type: %s" type))))
|
|
|
|
|
|
|
|
|
|
(setq properties
|
|
|
|
|
(let ((plist nil) key)
|
|
|
|
|
(dolist (elt properties)
|
|
|
|
|
(setq key (car elt))
|
|
|
|
|
(cond ((eq key 'post-read-conversion)
|
|
|
|
|
(setq key :post-read-conversion))
|
|
|
|
|
((eq key 'pre-write-conversion)
|
|
|
|
|
(setq key :pre-write-conversion))
|
|
|
|
|
((eq key 'translation-table-for-decode)
|
|
|
|
|
(setq key :decode-translation-table))
|
|
|
|
|
((eq key 'translation-table-for-encode)
|
|
|
|
|
(setq key :encode-translation-table))
|
|
|
|
|
((eq key 'safe-charsets)
|
|
|
|
|
(setq key :charset-list))
|
|
|
|
|
((eq key 'mime-charset)
|
|
|
|
|
(setq key :mime-charset))
|
|
|
|
|
((eq key 'valid-codes)
|
|
|
|
|
(setq key :valids)))
|
|
|
|
|
(setq plist (plist-put plist key (cdr elt))))
|
|
|
|
|
plist))
|
2003-11-22 07:46:20 +00:00
|
|
|
|
(setq properties (plist-put properties :mnemonic mnemonic))
|
2003-09-08 12:53:41 +00:00
|
|
|
|
(plist-put properties :coding-type type)
|
|
|
|
|
(cond ((eq eol-type 0) (setq eol-type 'unix))
|
|
|
|
|
((eq eol-type 1) (setq eol-type 'dos))
|
|
|
|
|
((eq eol-type 2) (setq eol-type 'mac))
|
|
|
|
|
((vectorp eol-type) (setq eol-type nil)))
|
|
|
|
|
(plist-put properties :eol-type eol-type)
|
|
|
|
|
|
|
|
|
|
(cond
|
|
|
|
|
((eq type 'iso2022)
|
|
|
|
|
(plist-put properties :flags
|
|
|
|
|
(list (and (or (consp (nth 0 flags))
|
|
|
|
|
(consp (nth 1 flags))
|
|
|
|
|
(consp (nth 2 flags))
|
|
|
|
|
(consp (nth 3 flags))) 'designation)
|
|
|
|
|
(or (nth 4 flags) 'long-form)
|
|
|
|
|
(and (nth 5 flags) 'ascii-at-eol)
|
|
|
|
|
(and (nth 6 flags) 'ascii-at-cntl)
|
|
|
|
|
(and (nth 7 flags) '7-bit)
|
|
|
|
|
(and (nth 8 flags) 'locking-shift)
|
|
|
|
|
(and (nth 9 flags) 'single-shift)
|
|
|
|
|
(and (nth 10 flags) 'use-roman)
|
|
|
|
|
(and (nth 11 flags) 'use-oldjis)
|
|
|
|
|
(or (nth 12 flags) 'direction)
|
|
|
|
|
(and (nth 13 flags) 'init-at-bol)
|
|
|
|
|
(and (nth 14 flags) 'designate-at-bol)
|
|
|
|
|
(and (nth 15 flags) 'safe)
|
|
|
|
|
(and (nth 16 flags) 'latin-extra)))
|
|
|
|
|
(plist-put properties :designation
|
|
|
|
|
(let ((vec (make-vector 4 nil)))
|
|
|
|
|
(dotimes (i 4)
|
|
|
|
|
(let ((spec (nth i flags)))
|
|
|
|
|
(if (eq spec t)
|
|
|
|
|
(aset vec i '(94 96))
|
|
|
|
|
(if (consp spec)
|
|
|
|
|
(progn
|
|
|
|
|
(if (memq t spec)
|
|
|
|
|
(setq spec (append (delq t spec) '(94 96))))
|
|
|
|
|
(aset vec i spec))))))
|
|
|
|
|
vec)))
|
|
|
|
|
|
|
|
|
|
((eq type 'ccl)
|
|
|
|
|
(plist-put properties :ccl-decoder (car flags))
|
|
|
|
|
(plist-put properties :ccl-encoder (cdr flags))))
|
|
|
|
|
|
|
|
|
|
(apply 'define-coding-system coding-system doc-string properties))
|
1997-02-20 07:02:49 +00:00
|
|
|
|
|
2008-11-12 18:39:08 +00:00
|
|
|
|
(make-obsolete 'make-coding-system 'define-coding-system "23.1")
|
|
|
|
|
|
2002-08-02 18:01:33 +00:00
|
|
|
|
(defun merge-coding-systems (first second)
|
|
|
|
|
"Fill in any unspecified aspects of coding system FIRST from SECOND.
|
|
|
|
|
Return the resulting coding system."
|
|
|
|
|
(let ((base (coding-system-base second))
|
|
|
|
|
(eol (coding-system-eol-type second)))
|
|
|
|
|
;; If FIRST doesn't specify text conversion, merge with that of SECOND.
|
|
|
|
|
(if (eq (coding-system-base first) 'undecided)
|
|
|
|
|
(setq first (coding-system-change-text-conversion first base)))
|
|
|
|
|
;; If FIRST doesn't specify eol conversion, merge with that of SECOND.
|
|
|
|
|
(if (and (vectorp (coding-system-eol-type first))
|
|
|
|
|
(numberp eol) (>= eol 0) (<= eol 2))
|
|
|
|
|
(setq first (coding-system-change-eol-conversion
|
|
|
|
|
first eol)))
|
|
|
|
|
first))
|
|
|
|
|
|
2006-01-19 07:16:47 +00:00
|
|
|
|
(defun autoload-coding-system (symbol form)
|
|
|
|
|
"Define SYMBOL as a coding-system that is defined on demand.
|
|
|
|
|
|
2008-11-12 18:39:08 +00:00
|
|
|
|
FORM is a form to evaluate to define the coding-system."
|
2006-01-19 07:16:47 +00:00
|
|
|
|
(put symbol 'coding-system-define-form form)
|
|
|
|
|
(setq coding-system-alist (cons (list (symbol-name symbol))
|
|
|
|
|
coding-system-alist))
|
|
|
|
|
(dolist (elt '("-unix" "-dos" "-mac"))
|
|
|
|
|
(let ((name (concat (symbol-name symbol) elt)))
|
|
|
|
|
(put (intern name) 'coding-system-define-form form)
|
|
|
|
|
(setq coding-system-alist (cons (list name) coding-system-alist)))))
|
|
|
|
|
|
2009-03-03 01:56:14 +00:00
|
|
|
|
;; This variable is set in these three cases:
|
|
|
|
|
;; (1) A file is read by a coding system specified explicitly.
|
|
|
|
|
;; after-insert-file-set-coding sets the car of this value to
|
|
|
|
|
;; coding-system-for-read, and sets the cdr to nil.
|
|
|
|
|
;; (2) A buffer is saved.
|
|
|
|
|
;; After writing, basic-save-buffer-1 sets the car of this value
|
|
|
|
|
;; to last-coding-system-used.
|
|
|
|
|
;; (3) set-buffer-file-coding-system is called.
|
|
|
|
|
;; The cdr of this value is set to the specified coding system.
|
|
|
|
|
;; This variable is used for decoding in revert-buffer and encoding in
|
|
|
|
|
;; select-safe-coding-system.
|
|
|
|
|
(defvar buffer-file-coding-system-explicit nil
|
|
|
|
|
"The file coding system explicitly specified for the current buffer.
|
|
|
|
|
The value is a cons of coding systems for reading (decoding) and
|
|
|
|
|
writing (encoding).
|
|
|
|
|
Internal use only.")
|
|
|
|
|
(make-variable-buffer-local 'buffer-file-coding-system-explicit)
|
|
|
|
|
(put 'buffer-file-coding-system-explicit 'permanent-local t)
|
|
|
|
|
|
2010-04-19 13:05:12 -04:00
|
|
|
|
(defun read-buffer-file-coding-system ()
|
|
|
|
|
(let* ((bcss (find-coding-systems-region (point-min) (point-max)))
|
|
|
|
|
(css-table
|
|
|
|
|
(unless (equal bcss '(undecided))
|
|
|
|
|
(append '("dos" "unix" "mac")
|
|
|
|
|
(delq nil (mapcar (lambda (cs)
|
|
|
|
|
(if (memq (coding-system-base cs) bcss)
|
|
|
|
|
(symbol-name cs)))
|
|
|
|
|
coding-system-list)))))
|
|
|
|
|
(combined-table
|
|
|
|
|
(if css-table
|
|
|
|
|
(completion-table-in-turn css-table coding-system-alist)
|
|
|
|
|
coding-system-alist))
|
|
|
|
|
(auto-cs
|
|
|
|
|
(unless find-file-literally
|
|
|
|
|
(save-excursion
|
|
|
|
|
(save-restriction
|
|
|
|
|
(widen)
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(funcall set-auto-coding-function
|
|
|
|
|
(or buffer-file-name "") (buffer-size))))))
|
|
|
|
|
(preferred
|
|
|
|
|
(let ((bfcs (default-value 'buffer-file-coding-system)))
|
|
|
|
|
(cons (and (or (equal bcss '(undecided))
|
|
|
|
|
(memq (coding-system-base bfcs) bcss))
|
|
|
|
|
bfcs)
|
|
|
|
|
(mapcar (lambda (cs)
|
|
|
|
|
(and (coding-system-p cs)
|
|
|
|
|
(coding-system-get cs :mime-charset)
|
|
|
|
|
(or (equal bcss '(undecided))
|
|
|
|
|
(memq (coding-system-base cs) bcss))
|
|
|
|
|
cs))
|
|
|
|
|
(coding-system-priority-list)))))
|
|
|
|
|
(default
|
|
|
|
|
(let ((current (coding-system-base buffer-file-coding-system)))
|
|
|
|
|
;; Generally use as a default the first preferred coding-system
|
|
|
|
|
;; different from the current coding-system, except for
|
|
|
|
|
;; the case of auto-cs since choosing anything else is asking
|
|
|
|
|
;; for trouble (would lead to using a different coding
|
|
|
|
|
;; system than specified in the coding tag).
|
|
|
|
|
(or auto-cs
|
|
|
|
|
(car (delq nil
|
|
|
|
|
(mapcar (lambda (cs)
|
|
|
|
|
(if (eq current (coding-system-base cs))
|
|
|
|
|
nil
|
|
|
|
|
cs))
|
|
|
|
|
preferred))))))
|
|
|
|
|
(completion-ignore-case t)
|
|
|
|
|
(completion-pcm--delim-wild-regex ; Let "u8" complete to "utf-8".
|
|
|
|
|
(concat completion-pcm--delim-wild-regex
|
|
|
|
|
"\\|\\([[:alpha:]]\\)[[:digit:]]"))
|
|
|
|
|
(cs (completing-read
|
|
|
|
|
(format "Coding system for saving file (default %s): " default)
|
|
|
|
|
combined-table
|
|
|
|
|
nil t nil 'coding-system-history
|
|
|
|
|
(if default (symbol-name default)))))
|
|
|
|
|
(unless (zerop (length cs)) (intern cs))))
|
|
|
|
|
|
2004-11-16 17:18:39 +00:00
|
|
|
|
(defun set-buffer-file-coding-system (coding-system &optional force nomodify)
|
1997-08-05 07:05:12 +00:00
|
|
|
|
"Set the file coding-system of the current buffer to CODING-SYSTEM.
|
|
|
|
|
This means that when you save the buffer, it will be converted
|
2008-11-12 18:39:08 +00:00
|
|
|
|
according to CODING-SYSTEM. For a list of possible values of
|
|
|
|
|
CODING-SYSTEM, use \\[list-coding-systems].
|
1997-08-05 07:05:12 +00:00
|
|
|
|
|
2008-11-12 18:39:08 +00:00
|
|
|
|
If CODING-SYSTEM leaves the text conversion unspecified, or if it leaves
|
|
|
|
|
the end-of-line conversion unspecified, FORCE controls what to do.
|
|
|
|
|
If FORCE is nil, get the unspecified aspect (or aspects) from the buffer's
|
|
|
|
|
previous `buffer-file-coding-system' value (if it is specified there).
|
|
|
|
|
Otherwise, leave it unspecified.
|
1999-12-06 04:53:04 +00:00
|
|
|
|
|
|
|
|
|
This marks the buffer modified so that the succeeding \\[save-buffer]
|
|
|
|
|
surely saves the buffer with CODING-SYSTEM. From a program, if you
|
2004-11-16 17:18:39 +00:00
|
|
|
|
don't want to mark the buffer modified, specify t for NOMODIFY.
|
|
|
|
|
If you know exactly what coding system you want to use,
|
|
|
|
|
just set the variable `buffer-file-coding-system' directly."
|
2010-04-19 13:05:12 -04:00
|
|
|
|
(interactive
|
|
|
|
|
(list (read-buffer-file-coding-system)
|
|
|
|
|
current-prefix-arg))
|
1997-02-20 07:02:49 +00:00
|
|
|
|
(check-coding-system coding-system)
|
2000-06-12 00:04:43 +00:00
|
|
|
|
(if (and coding-system buffer-file-coding-system (null force))
|
2002-08-02 18:01:33 +00:00
|
|
|
|
(setq coding-system
|
|
|
|
|
(merge-coding-systems coding-system buffer-file-coding-system)))
|
2010-04-19 13:05:12 -04:00
|
|
|
|
(when (called-interactively-p 'interactive)
|
|
|
|
|
;; Check whether save would succeed, and jump to the offending char(s)
|
|
|
|
|
;; if not.
|
|
|
|
|
(let ((css (find-coding-systems-region (point-min) (point-max))))
|
|
|
|
|
(unless (or (eq (car css) 'undecided)
|
|
|
|
|
(memq (coding-system-base coding-system) css))
|
|
|
|
|
(setq coding-system (select-safe-coding-system-interactively
|
|
|
|
|
(point-min) (point-max) css
|
|
|
|
|
(list coding-system))))))
|
1997-02-20 07:02:49 +00:00
|
|
|
|
(setq buffer-file-coding-system coding-system)
|
2009-03-03 01:56:14 +00:00
|
|
|
|
(if buffer-file-coding-system-explicit
|
|
|
|
|
(setcdr buffer-file-coding-system-explicit coding-system)
|
|
|
|
|
(setq buffer-file-coding-system-explicit (cons nil coding-system)))
|
2004-11-16 22:37:04 +00:00
|
|
|
|
(unless nomodify
|
|
|
|
|
(set-buffer-modified-p t))
|
1997-02-20 07:02:49 +00:00
|
|
|
|
(force-mode-line-update))
|
|
|
|
|
|
2002-08-02 18:01:33 +00:00
|
|
|
|
(defun revert-buffer-with-coding-system (coding-system &optional force)
|
|
|
|
|
"Visit the current buffer's file again using coding system CODING-SYSTEM.
|
|
|
|
|
For a list of possible values of CODING-SYSTEM, use \\[list-coding-systems].
|
|
|
|
|
|
2008-11-12 18:39:08 +00:00
|
|
|
|
If CODING-SYSTEM leaves the text conversion unspecified, or if it leaves
|
|
|
|
|
the end-of-line conversion unspecified, FORCE controls what to do.
|
|
|
|
|
If FORCE is nil, get the unspecified aspect (or aspects) from the buffer's
|
|
|
|
|
previous `buffer-file-coding-system' value (if it is specified there).
|
|
|
|
|
Otherwise, determine it from the file contents as usual for visiting a file."
|
2005-09-24 Emilio C. Lopes <eclig@gmx.net>
* woman.el (woman-file-name):
* wid-edit.el (widget-file-prompt-value)
(widget-coding-system-prompt-value):
* w32-fns.el (set-w32-system-coding-system):
* vc.el (vc-version-diff, vc-annotate):
* textmodes/reftex-auc.el (reftex-arg-cite)
(reftex-arg-index-tag):
* textmodes/refer.el (refer-get-bib-files):
* textmodes/artist.el (artist-figlet-choose-font):
* terminal.el (terminal-emulator):
* replace.el (occur-read-primary-args):
* rect.el (string-rectangle, string-insert-rectangle):
* ps-print.el (ps-print-preprint):
* progmodes/pascal.el (pascal-goto-defun):
* progmodes/etags.el (visit-tags-table, visit-tags-table-buffer):
* progmodes/compile.el (compilation-find-file):
* printing.el (pr-interactive-n-up):
* play/animate.el (animate-birthday-present):
* net/rcompile.el (remote-compile):
* man.el (man, Man-goto-section, Man-follow-manual-reference):
* mail/rmailsum.el (rmail-summary-search-backward)
(rmail-summary-search):
* mail/rmailout.el (rmail-output-read-rmail-file-name)
(rmail-output-read-file-name):
* mail/rmail.el (rmail-search, rmail-search-backwards):
* mail/mailabbrev.el (merge-mail-abbrevs, rebuild-mail-abbrevs):
* locate.el (locate):
* international/quail.el (quail-show-keyboard-layout):
* international/mule.el (set-buffer-file-coding-system)
(revert-buffer-with-coding-system, set-file-name-coding-system)
(set-terminal-coding-system, set-keyboard-coding-system)
(set-next-selection-coding-system):
* international/mule-diag.el (describe-coding-system)
(describe-font, describe-fontset):
* international/mule-cmds.el (universal-coding-system-argument)
(search-unencodable-char, describe-input-method)
(set-language-environment, describe-language-environment):
* international/codepage.el (codepage-setup):
* international/code-pages.el (codepage-setup):
* info.el (Info-search, Info-follow-reference)
(Info-search-backward):
* emacs-lisp/advice.el (ad-read-advised-function)
(ad-read-advice-class, ad-clear-cache, ad-activate)
(ad-deactivate, ad-update, ad-unadvise, ad-read-advice-name)
(ad-enable-advice, ad-disable-advice, ad-remove-advice)
(ad-read-regexp):
* ediff-util.el (ediff-toggle-regexp-match):
* ediff-ptch.el (ediff-prompt-for-patch-file):
* dired-aux.el (dired-diff):
* diff.el (diff):
* cus-edit.el (custom-variable-prompt):
* calendar/timeclock.el (timeclock-ask-for-project):
* calc/calcalg3.el (calc-get-fit-variables):
* calc/calc-store.el (calc-edit-variable)
(calc-permanent-variable):
* vc-mcvs.el (vc-mcvs-register):
* shadowfile.el (shadow-define-literal-group):
* woman.el (woman-file-name):
* vc.el (vc-version-diff, vc-merge):
* textmodes/reftex-index.el (reftex-index-complete-tag):
* format.el (format-decode-buffer, format-decode-region):
* emulation/viper-cmd.el (viper-read-string-with-history):
* emacs-lisp/debug.el (cancel-debug-on-entry):
* emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine):
* ediff.el (ediff-merge-revisions)
(ediff-merge-revisions-with-ancestor, ediff-revision):
* completion.el (interactive-completion-string-reader):
* calc/calc-prog.el (calc-user-define-formula):
Follow convention for reading with the minibuffer.
2005-09-24 13:44:02 +00:00
|
|
|
|
(interactive "zCoding system for visited file (default nil): \nP")
|
2002-08-02 18:01:33 +00:00
|
|
|
|
(check-coding-system coding-system)
|
|
|
|
|
(if (and coding-system buffer-file-coding-system (null force))
|
|
|
|
|
(setq coding-system
|
|
|
|
|
(merge-coding-systems coding-system buffer-file-coding-system)))
|
|
|
|
|
(let ((coding-system-for-read coding-system))
|
|
|
|
|
(revert-buffer)))
|
|
|
|
|
|
2002-12-17 11:56:56 +00:00
|
|
|
|
(defun set-file-name-coding-system (coding-system)
|
|
|
|
|
"Set coding system for decoding and encoding file names to CODING-SYSTEM.
|
2008-11-12 18:39:08 +00:00
|
|
|
|
It actually just set the variable `file-name-coding-system' (which see)
|
|
|
|
|
to CODING-SYSTEM."
|
2005-09-24 Emilio C. Lopes <eclig@gmx.net>
* woman.el (woman-file-name):
* wid-edit.el (widget-file-prompt-value)
(widget-coding-system-prompt-value):
* w32-fns.el (set-w32-system-coding-system):
* vc.el (vc-version-diff, vc-annotate):
* textmodes/reftex-auc.el (reftex-arg-cite)
(reftex-arg-index-tag):
* textmodes/refer.el (refer-get-bib-files):
* textmodes/artist.el (artist-figlet-choose-font):
* terminal.el (terminal-emulator):
* replace.el (occur-read-primary-args):
* rect.el (string-rectangle, string-insert-rectangle):
* ps-print.el (ps-print-preprint):
* progmodes/pascal.el (pascal-goto-defun):
* progmodes/etags.el (visit-tags-table, visit-tags-table-buffer):
* progmodes/compile.el (compilation-find-file):
* printing.el (pr-interactive-n-up):
* play/animate.el (animate-birthday-present):
* net/rcompile.el (remote-compile):
* man.el (man, Man-goto-section, Man-follow-manual-reference):
* mail/rmailsum.el (rmail-summary-search-backward)
(rmail-summary-search):
* mail/rmailout.el (rmail-output-read-rmail-file-name)
(rmail-output-read-file-name):
* mail/rmail.el (rmail-search, rmail-search-backwards):
* mail/mailabbrev.el (merge-mail-abbrevs, rebuild-mail-abbrevs):
* locate.el (locate):
* international/quail.el (quail-show-keyboard-layout):
* international/mule.el (set-buffer-file-coding-system)
(revert-buffer-with-coding-system, set-file-name-coding-system)
(set-terminal-coding-system, set-keyboard-coding-system)
(set-next-selection-coding-system):
* international/mule-diag.el (describe-coding-system)
(describe-font, describe-fontset):
* international/mule-cmds.el (universal-coding-system-argument)
(search-unencodable-char, describe-input-method)
(set-language-environment, describe-language-environment):
* international/codepage.el (codepage-setup):
* international/code-pages.el (codepage-setup):
* info.el (Info-search, Info-follow-reference)
(Info-search-backward):
* emacs-lisp/advice.el (ad-read-advised-function)
(ad-read-advice-class, ad-clear-cache, ad-activate)
(ad-deactivate, ad-update, ad-unadvise, ad-read-advice-name)
(ad-enable-advice, ad-disable-advice, ad-remove-advice)
(ad-read-regexp):
* ediff-util.el (ediff-toggle-regexp-match):
* ediff-ptch.el (ediff-prompt-for-patch-file):
* dired-aux.el (dired-diff):
* diff.el (diff):
* cus-edit.el (custom-variable-prompt):
* calendar/timeclock.el (timeclock-ask-for-project):
* calc/calcalg3.el (calc-get-fit-variables):
* calc/calc-store.el (calc-edit-variable)
(calc-permanent-variable):
* vc-mcvs.el (vc-mcvs-register):
* shadowfile.el (shadow-define-literal-group):
* woman.el (woman-file-name):
* vc.el (vc-version-diff, vc-merge):
* textmodes/reftex-index.el (reftex-index-complete-tag):
* format.el (format-decode-buffer, format-decode-region):
* emulation/viper-cmd.el (viper-read-string-with-history):
* emacs-lisp/debug.el (cancel-debug-on-entry):
* emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine):
* ediff.el (ediff-merge-revisions)
(ediff-merge-revisions-with-ancestor, ediff-revision):
* completion.el (interactive-completion-string-reader):
* calc/calc-prog.el (calc-user-define-formula):
Follow convention for reading with the minibuffer.
2005-09-24 13:44:02 +00:00
|
|
|
|
(interactive "zCoding system for file names (default nil): ")
|
2002-12-17 11:56:56 +00:00
|
|
|
|
(check-coding-system coding-system)
|
2005-07-29 06:17:39 +00:00
|
|
|
|
(if (and coding-system
|
|
|
|
|
(not (coding-system-get coding-system :ascii-compatible-p))
|
|
|
|
|
(not (coding-system-get coding-system :suitable-for-file-name)))
|
|
|
|
|
(error "%s is not suitable for file names" coding-system))
|
2002-12-17 11:56:56 +00:00
|
|
|
|
(setq file-name-coding-system coding-system))
|
|
|
|
|
|
1997-08-05 07:05:12 +00:00
|
|
|
|
(defvar default-terminal-coding-system nil
|
|
|
|
|
"Default value for the terminal coding system.
|
|
|
|
|
This is normally set according to the selected language environment.
|
|
|
|
|
See also the command `set-terminal-coding-system'.")
|
|
|
|
|
|
2009-05-20 02:17:50 +00:00
|
|
|
|
(defun set-terminal-coding-system (coding-system &optional terminal)
|
2005-05-03 01:49:33 +00:00
|
|
|
|
"Set coding system of terminal output to CODING-SYSTEM.
|
2009-05-20 02:17:50 +00:00
|
|
|
|
All text output to TERMINAL will be encoded
|
1997-08-05 07:05:12 +00:00
|
|
|
|
with the specified coding system.
|
2005-05-03 01:49:33 +00:00
|
|
|
|
|
1997-08-05 07:05:12 +00:00
|
|
|
|
For a list of possible values of CODING-SYSTEM, use \\[list-coding-systems].
|
|
|
|
|
The default is determined by the selected language environment
|
2005-05-03 01:49:33 +00:00
|
|
|
|
or by the previous use of this command.
|
|
|
|
|
|
2009-05-20 02:17:50 +00:00
|
|
|
|
TERMINAL may be a terminal object, a frame, or nil for the
|
|
|
|
|
selected frame's terminal. The setting has no effect on
|
|
|
|
|
graphical terminals."
|
1997-08-05 07:05:12 +00:00
|
|
|
|
(interactive
|
1997-09-05 05:43:29 +00:00
|
|
|
|
(list (let ((default (if (and (not (terminal-coding-system))
|
|
|
|
|
default-terminal-coding-system)
|
|
|
|
|
default-terminal-coding-system)))
|
|
|
|
|
(read-coding-system
|
2005-09-24 Emilio C. Lopes <eclig@gmx.net>
* woman.el (woman-file-name):
* wid-edit.el (widget-file-prompt-value)
(widget-coding-system-prompt-value):
* w32-fns.el (set-w32-system-coding-system):
* vc.el (vc-version-diff, vc-annotate):
* textmodes/reftex-auc.el (reftex-arg-cite)
(reftex-arg-index-tag):
* textmodes/refer.el (refer-get-bib-files):
* textmodes/artist.el (artist-figlet-choose-font):
* terminal.el (terminal-emulator):
* replace.el (occur-read-primary-args):
* rect.el (string-rectangle, string-insert-rectangle):
* ps-print.el (ps-print-preprint):
* progmodes/pascal.el (pascal-goto-defun):
* progmodes/etags.el (visit-tags-table, visit-tags-table-buffer):
* progmodes/compile.el (compilation-find-file):
* printing.el (pr-interactive-n-up):
* play/animate.el (animate-birthday-present):
* net/rcompile.el (remote-compile):
* man.el (man, Man-goto-section, Man-follow-manual-reference):
* mail/rmailsum.el (rmail-summary-search-backward)
(rmail-summary-search):
* mail/rmailout.el (rmail-output-read-rmail-file-name)
(rmail-output-read-file-name):
* mail/rmail.el (rmail-search, rmail-search-backwards):
* mail/mailabbrev.el (merge-mail-abbrevs, rebuild-mail-abbrevs):
* locate.el (locate):
* international/quail.el (quail-show-keyboard-layout):
* international/mule.el (set-buffer-file-coding-system)
(revert-buffer-with-coding-system, set-file-name-coding-system)
(set-terminal-coding-system, set-keyboard-coding-system)
(set-next-selection-coding-system):
* international/mule-diag.el (describe-coding-system)
(describe-font, describe-fontset):
* international/mule-cmds.el (universal-coding-system-argument)
(search-unencodable-char, describe-input-method)
(set-language-environment, describe-language-environment):
* international/codepage.el (codepage-setup):
* international/code-pages.el (codepage-setup):
* info.el (Info-search, Info-follow-reference)
(Info-search-backward):
* emacs-lisp/advice.el (ad-read-advised-function)
(ad-read-advice-class, ad-clear-cache, ad-activate)
(ad-deactivate, ad-update, ad-unadvise, ad-read-advice-name)
(ad-enable-advice, ad-disable-advice, ad-remove-advice)
(ad-read-regexp):
* ediff-util.el (ediff-toggle-regexp-match):
* ediff-ptch.el (ediff-prompt-for-patch-file):
* dired-aux.el (dired-diff):
* diff.el (diff):
* cus-edit.el (custom-variable-prompt):
* calendar/timeclock.el (timeclock-ask-for-project):
* calc/calcalg3.el (calc-get-fit-variables):
* calc/calc-store.el (calc-edit-variable)
(calc-permanent-variable):
* vc-mcvs.el (vc-mcvs-register):
* shadowfile.el (shadow-define-literal-group):
* woman.el (woman-file-name):
* vc.el (vc-version-diff, vc-merge):
* textmodes/reftex-index.el (reftex-index-complete-tag):
* format.el (format-decode-buffer, format-decode-region):
* emulation/viper-cmd.el (viper-read-string-with-history):
* emacs-lisp/debug.el (cancel-debug-on-entry):
* emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine):
* ediff.el (ediff-merge-revisions)
(ediff-merge-revisions-with-ancestor, ediff-revision):
* completion.el (interactive-completion-string-reader):
* calc/calc-prog.el (calc-user-define-formula):
Follow convention for reading with the minibuffer.
2005-09-24 13:44:02 +00:00
|
|
|
|
(format "Coding system for terminal display (default %s): "
|
1997-09-05 05:43:29 +00:00
|
|
|
|
default)
|
|
|
|
|
default))))
|
1997-08-05 07:05:12 +00:00
|
|
|
|
(if (and (not coding-system)
|
|
|
|
|
(not (terminal-coding-system)))
|
|
|
|
|
(setq coding-system default-terminal-coding-system))
|
|
|
|
|
(if coding-system
|
2001-02-11 17:07:35 +00:00
|
|
|
|
(setq default-terminal-coding-system coding-system))
|
2009-05-20 02:17:50 +00:00
|
|
|
|
(set-terminal-coding-system-internal coding-system terminal)
|
1997-05-28 03:35:33 +00:00
|
|
|
|
(redraw-frame (selected-frame)))
|
|
|
|
|
|
1997-08-05 07:05:12 +00:00
|
|
|
|
(defvar default-keyboard-coding-system nil
|
|
|
|
|
"Default value of the keyboard coding system.
|
|
|
|
|
This is normally set according to the selected language environment.
|
|
|
|
|
See also the command `set-keyboard-coding-system'.")
|
|
|
|
|
|
2009-05-20 02:17:50 +00:00
|
|
|
|
(defun set-keyboard-coding-system (coding-system &optional terminal)
|
|
|
|
|
"Set coding system for keyboard input on TERMINAL to CODING-SYSTEM.
|
2005-05-03 01:49:33 +00:00
|
|
|
|
|
1997-08-05 07:05:12 +00:00
|
|
|
|
For a list of possible values of CODING-SYSTEM, use \\[list-coding-systems].
|
|
|
|
|
The default is determined by the selected language environment
|
2005-05-03 01:49:33 +00:00
|
|
|
|
or by the previous use of this command.
|
|
|
|
|
|
2009-07-01 11:40:03 +00:00
|
|
|
|
If CODING-SYSTEM is nil or the coding-type of CODING-SYSTEM is
|
|
|
|
|
`raw-text', the decoding of keyboard input is disabled.
|
|
|
|
|
|
2009-05-20 02:17:50 +00:00
|
|
|
|
TERMINAL may be a terminal object, a frame, or nil for the
|
|
|
|
|
selected frame's terminal. The setting has no effect on
|
|
|
|
|
graphical terminals."
|
1997-08-05 07:05:12 +00:00
|
|
|
|
(interactive
|
2009-07-01 11:40:03 +00:00
|
|
|
|
(list (let* ((coding (keyboard-coding-system nil))
|
|
|
|
|
(default (if (eq (coding-system-type coding) 'raw-text)
|
|
|
|
|
default-keyboard-coding-system)))
|
1997-09-05 05:43:29 +00:00
|
|
|
|
(read-coding-system
|
2005-09-24 Emilio C. Lopes <eclig@gmx.net>
* woman.el (woman-file-name):
* wid-edit.el (widget-file-prompt-value)
(widget-coding-system-prompt-value):
* w32-fns.el (set-w32-system-coding-system):
* vc.el (vc-version-diff, vc-annotate):
* textmodes/reftex-auc.el (reftex-arg-cite)
(reftex-arg-index-tag):
* textmodes/refer.el (refer-get-bib-files):
* textmodes/artist.el (artist-figlet-choose-font):
* terminal.el (terminal-emulator):
* replace.el (occur-read-primary-args):
* rect.el (string-rectangle, string-insert-rectangle):
* ps-print.el (ps-print-preprint):
* progmodes/pascal.el (pascal-goto-defun):
* progmodes/etags.el (visit-tags-table, visit-tags-table-buffer):
* progmodes/compile.el (compilation-find-file):
* printing.el (pr-interactive-n-up):
* play/animate.el (animate-birthday-present):
* net/rcompile.el (remote-compile):
* man.el (man, Man-goto-section, Man-follow-manual-reference):
* mail/rmailsum.el (rmail-summary-search-backward)
(rmail-summary-search):
* mail/rmailout.el (rmail-output-read-rmail-file-name)
(rmail-output-read-file-name):
* mail/rmail.el (rmail-search, rmail-search-backwards):
* mail/mailabbrev.el (merge-mail-abbrevs, rebuild-mail-abbrevs):
* locate.el (locate):
* international/quail.el (quail-show-keyboard-layout):
* international/mule.el (set-buffer-file-coding-system)
(revert-buffer-with-coding-system, set-file-name-coding-system)
(set-terminal-coding-system, set-keyboard-coding-system)
(set-next-selection-coding-system):
* international/mule-diag.el (describe-coding-system)
(describe-font, describe-fontset):
* international/mule-cmds.el (universal-coding-system-argument)
(search-unencodable-char, describe-input-method)
(set-language-environment, describe-language-environment):
* international/codepage.el (codepage-setup):
* international/code-pages.el (codepage-setup):
* info.el (Info-search, Info-follow-reference)
(Info-search-backward):
* emacs-lisp/advice.el (ad-read-advised-function)
(ad-read-advice-class, ad-clear-cache, ad-activate)
(ad-deactivate, ad-update, ad-unadvise, ad-read-advice-name)
(ad-enable-advice, ad-disable-advice, ad-remove-advice)
(ad-read-regexp):
* ediff-util.el (ediff-toggle-regexp-match):
* ediff-ptch.el (ediff-prompt-for-patch-file):
* dired-aux.el (dired-diff):
* diff.el (diff):
* cus-edit.el (custom-variable-prompt):
* calendar/timeclock.el (timeclock-ask-for-project):
* calc/calcalg3.el (calc-get-fit-variables):
* calc/calc-store.el (calc-edit-variable)
(calc-permanent-variable):
* vc-mcvs.el (vc-mcvs-register):
* shadowfile.el (shadow-define-literal-group):
* woman.el (woman-file-name):
* vc.el (vc-version-diff, vc-merge):
* textmodes/reftex-index.el (reftex-index-complete-tag):
* format.el (format-decode-buffer, format-decode-region):
* emulation/viper-cmd.el (viper-read-string-with-history):
* emacs-lisp/debug.el (cancel-debug-on-entry):
* emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine):
* ediff.el (ediff-merge-revisions)
(ediff-merge-revisions-with-ancestor, ediff-revision):
* completion.el (interactive-completion-string-reader):
* calc/calc-prog.el (calc-user-define-formula):
Follow convention for reading with the minibuffer.
2005-09-24 13:44:02 +00:00
|
|
|
|
(format "Coding system for keyboard input (default %s): "
|
1997-09-05 05:43:29 +00:00
|
|
|
|
default)
|
|
|
|
|
default))))
|
2009-07-01 11:40:03 +00:00
|
|
|
|
(let ((coding-type (coding-system-type coding-system))
|
|
|
|
|
(saved-meta-mode
|
|
|
|
|
(terminal-parameter terminal 'keyboard-coding-saved-meta-mode)))
|
|
|
|
|
(if (not (eq coding-type 'raw-text))
|
|
|
|
|
(let (accept-8-bit)
|
|
|
|
|
(if (not (or (coding-system-get coding-system :suitable-for-keyboard)
|
|
|
|
|
(coding-system-get coding-system :ascii-compatible-p)))
|
|
|
|
|
(error "Unsuitable coding system for keyboard: %s" coding-system))
|
|
|
|
|
(cond ((memq coding-type '(charset utf-8 shift-jis big5 ccl))
|
|
|
|
|
(setq accept-8-bit t))
|
|
|
|
|
((eq coding-type 'iso-2022)
|
|
|
|
|
(let ((flags (coding-system-get coding-system :flags)))
|
|
|
|
|
(or (memq '7-bit flags)
|
|
|
|
|
(setq accept-8-bit t))))
|
|
|
|
|
(t
|
|
|
|
|
(error "Unsupported coding system for keyboard: %s"
|
|
|
|
|
coding-system)))
|
|
|
|
|
(when accept-8-bit
|
|
|
|
|
(or saved-meta-mode
|
|
|
|
|
(set-terminal-parameter terminal
|
|
|
|
|
'keyboard-coding-saved-meta-mode
|
|
|
|
|
(cons (nth 2 (current-input-mode))
|
|
|
|
|
nil)))
|
2009-07-02 06:44:06 +00:00
|
|
|
|
(set-input-meta-mode 8))
|
|
|
|
|
;; Avoid end-of-line conversion.
|
|
|
|
|
(setq coding-system
|
|
|
|
|
(coding-system-change-eol-conversion coding-system 'unix)))
|
2009-07-01 11:40:03 +00:00
|
|
|
|
|
|
|
|
|
(when saved-meta-mode
|
|
|
|
|
(set-input-meta-mode (car saved-meta-mode))
|
|
|
|
|
(set-terminal-parameter terminal
|
|
|
|
|
'keyboard-coding-saved-meta-mode
|
|
|
|
|
nil))))
|
2009-05-20 02:17:50 +00:00
|
|
|
|
(set-keyboard-coding-system-internal coding-system terminal)
|
2009-07-01 11:40:03 +00:00
|
|
|
|
(setq keyboard-coding-system coding-system))
|
1997-05-28 03:35:33 +00:00
|
|
|
|
|
2000-12-18 17:10:08 +00:00
|
|
|
|
(defcustom keyboard-coding-system nil
|
|
|
|
|
"Specify coding system for keyboard input.
|
|
|
|
|
If you set this on a terminal which can't distinguish Meta keys from
|
|
|
|
|
8-bit characters, you will have to use ESC to type Meta characters.
|
2006-04-21 12:22:24 +00:00
|
|
|
|
See Info node `Terminal Coding' and Info node `Unibyte Mode'.
|
2000-12-18 17:10:08 +00:00
|
|
|
|
|
2003-01-03 20:11:15 +00:00
|
|
|
|
On non-windowing terminals, this is set from the locale by default.
|
|
|
|
|
|
2000-12-18 17:10:08 +00:00
|
|
|
|
Setting this variable directly does not take effect;
|
2004-04-16 12:51:06 +00:00
|
|
|
|
use either \\[customize] or \\[set-keyboard-coding-system]."
|
2000-12-18 17:10:08 +00:00
|
|
|
|
:type '(coding-system :tag "Coding system")
|
2006-04-21 12:22:24 +00:00
|
|
|
|
:link '(info-link "(emacs)Terminal Coding")
|
|
|
|
|
:link '(info-link "(emacs)Unibyte Mode")
|
2000-12-18 17:10:08 +00:00
|
|
|
|
:set (lambda (symbol value)
|
2005-06-27 02:08:34 +00:00
|
|
|
|
;; Don't load encoded-kb unnecessarily.
|
|
|
|
|
(if (or value (boundp 'encoded-kbd-setup-display))
|
2000-12-18 17:10:08 +00:00
|
|
|
|
(set-keyboard-coding-system value)
|
|
|
|
|
(set-default 'keyboard-coding-system nil))) ; must initialize
|
2005-02-09 15:50:47 +00:00
|
|
|
|
:version "22.1"
|
2000-12-18 17:10:08 +00:00
|
|
|
|
:group 'keyboard
|
|
|
|
|
:group 'mule)
|
|
|
|
|
|
1997-05-28 03:35:33 +00:00
|
|
|
|
(defun set-buffer-process-coding-system (decoding encoding)
|
1997-08-05 07:05:12 +00:00
|
|
|
|
"Set coding systems for the process associated with the current buffer.
|
1997-05-28 03:35:33 +00:00
|
|
|
|
DECODING is the coding system to be used to decode input from the process,
|
1997-08-05 07:05:12 +00:00
|
|
|
|
ENCODING is the coding system to be used to encode output to the process.
|
|
|
|
|
|
2008-11-12 18:39:08 +00:00
|
|
|
|
For a list of possible coding systems, use \\[list-coding-systems]."
|
1997-02-20 07:02:49 +00:00
|
|
|
|
(interactive
|
2000-08-19 12:37:39 +00:00
|
|
|
|
"zCoding-system for output from the process: \nzCoding-system for input to the process: ")
|
1997-02-20 07:02:49 +00:00
|
|
|
|
(let ((proc (get-buffer-process (current-buffer))))
|
|
|
|
|
(if (null proc)
|
2001-02-11 17:07:35 +00:00
|
|
|
|
(error "No process")
|
1997-05-28 03:35:33 +00:00
|
|
|
|
(check-coding-system decoding)
|
|
|
|
|
(check-coding-system encoding)
|
|
|
|
|
(set-process-coding-system proc decoding encoding)))
|
1997-02-20 07:02:49 +00:00
|
|
|
|
(force-mode-line-update))
|
|
|
|
|
|
1998-07-27 05:39:15 +00:00
|
|
|
|
(defalias 'set-clipboard-coding-system 'set-selection-coding-system)
|
|
|
|
|
|
1998-07-12 05:58:47 +00:00
|
|
|
|
(defun set-selection-coding-system (coding-system)
|
2002-10-14 09:55:47 +00:00
|
|
|
|
"Make CODING-SYSTEM used for communicating with other X clients.
|
1998-05-18 01:01:00 +00:00
|
|
|
|
When sending or receiving text via cut_buffer, selection, and clipboard,
|
|
|
|
|
the text is encoded or decoded by CODING-SYSTEM."
|
1998-08-15 01:28:14 +00:00
|
|
|
|
(interactive "zCoding system for X selection: ")
|
1998-05-18 01:01:00 +00:00
|
|
|
|
(check-coding-system coding-system)
|
1998-07-12 05:58:47 +00:00
|
|
|
|
(setq selection-coding-system coding-system))
|
1998-05-18 01:01:00 +00:00
|
|
|
|
|
1998-09-06 14:31:49 +00:00
|
|
|
|
;; Coding system lastly specified by the command
|
1998-08-15 01:28:14 +00:00
|
|
|
|
;; set-next-selection-coding-system.
|
|
|
|
|
(defvar last-next-selection-coding-system nil)
|
|
|
|
|
|
|
|
|
|
(defun set-next-selection-coding-system (coding-system)
|
2002-06-27 21:40:53 +00:00
|
|
|
|
"Use CODING-SYSTEM for next communication with other window system clients.
|
1998-08-15 01:28:14 +00:00
|
|
|
|
This setting is effective for the next communication only."
|
|
|
|
|
(interactive
|
|
|
|
|
(list (read-coding-system
|
|
|
|
|
(if last-next-selection-coding-system
|
2005-09-25 22:07:01 +00:00
|
|
|
|
(format "Coding system for the next selection (default %S): "
|
1998-08-15 01:28:14 +00:00
|
|
|
|
last-next-selection-coding-system)
|
2002-06-27 21:40:53 +00:00
|
|
|
|
"Coding system for the next selection: ")
|
1998-08-15 01:28:14 +00:00
|
|
|
|
last-next-selection-coding-system)))
|
|
|
|
|
(if coding-system
|
|
|
|
|
(setq last-next-selection-coding-system coding-system)
|
|
|
|
|
(setq coding-system last-next-selection-coding-system))
|
|
|
|
|
(check-coding-system coding-system)
|
|
|
|
|
|
|
|
|
|
(setq next-selection-coding-system coding-system))
|
|
|
|
|
|
1997-02-20 07:02:49 +00:00
|
|
|
|
(defun set-coding-priority (arg)
|
2001-02-11 17:07:35 +00:00
|
|
|
|
"Set priority of coding categories according to ARG.
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
ARG is a list of coding categories ordered by priority.
|
|
|
|
|
|
2008-11-12 18:39:08 +00:00
|
|
|
|
This function is provided for backward compatibility."
|
2003-06-05 23:18:23 +00:00
|
|
|
|
(apply 'set-coding-system-priority
|
|
|
|
|
(mapcar #'(lambda (x) (symbol-value x)) arg)))
|
2005-02-14 03:40:07 +00:00
|
|
|
|
(make-obsolete 'set-coding-priority 'set-coding-system-priority "23.1")
|
1997-02-20 07:02:49 +00:00
|
|
|
|
|
2002-02-22 13:44:21 +00:00
|
|
|
|
;;; X selections
|
|
|
|
|
|
2003-05-29 01:28:24 +00:00
|
|
|
|
(defvar ctext-non-standard-encodings-alist
|
2009-11-12 06:55:39 +00:00
|
|
|
|
(mapcar 'purecopy
|
2006-02-27 01:24:24 +00:00
|
|
|
|
'(("big5-0" big5 2 big5)
|
2004-04-16 12:51:06 +00:00
|
|
|
|
("ISO8859-14" iso-8859-14 1 latin-iso8859-14)
|
2006-02-27 01:24:24 +00:00
|
|
|
|
("ISO8859-15" iso-8859-15 1 latin-iso8859-15)
|
2010-08-04 17:06:52 +09:00
|
|
|
|
("gbk-0" gbk 2 chinese-gbk)
|
|
|
|
|
("koi8-r" koi8-r 1 koi8-r)
|
|
|
|
|
("microsoft-cp1251" windows-1251 1 windows-1251)))
|
2004-04-16 12:51:06 +00:00
|
|
|
|
"Alist of non-standard encoding names vs the corresponding usages in CTEXT.
|
|
|
|
|
|
|
|
|
|
It controls how extended segments of a compound text are handled
|
|
|
|
|
by the coding system `compound-text-with-extensions'.
|
|
|
|
|
|
|
|
|
|
Each element has the form (ENCODING-NAME CODING-SYSTEM N-OCTET CHARSET).
|
|
|
|
|
|
2008-11-12 18:39:08 +00:00
|
|
|
|
ENCODING-NAME is an encoding name of an \"extended segment\".
|
2004-04-16 12:51:06 +00:00
|
|
|
|
|
|
|
|
|
CODING-SYSTEM is the coding-system to encode (or decode) the
|
|
|
|
|
characters into (or from) the extended segment.
|
|
|
|
|
|
|
|
|
|
N-OCTET is the number of octets (bytes) that encodes a character
|
|
|
|
|
in the segment. It can be 0 (meaning the number of octets per
|
|
|
|
|
character is variable), 1, 2, 3, or 4.
|
|
|
|
|
|
2008-11-12 18:39:08 +00:00
|
|
|
|
CHARSET is a character set containing characters that are encoded
|
2006-02-27 01:24:24 +00:00
|
|
|
|
in the segment. It can be a list of character sets.
|
2004-04-16 12:51:06 +00:00
|
|
|
|
|
|
|
|
|
On decoding CTEXT, all encoding names listed here are recognized.
|
|
|
|
|
|
|
|
|
|
On encoding CTEXT, encoding names in the variable
|
|
|
|
|
`ctext-non-standard-encodings' (which see) and in the information
|
|
|
|
|
listed for the current language environment under the key
|
|
|
|
|
`ctext-non-standard-encodings' are used.")
|
|
|
|
|
|
2006-02-27 01:24:24 +00:00
|
|
|
|
(defvar ctext-non-standard-encodings nil
|
2004-04-16 12:51:06 +00:00
|
|
|
|
"List of non-standard encoding names used in extended segments of CTEXT.
|
|
|
|
|
Each element must be one of the names listed in the variable
|
|
|
|
|
`ctext-non-standard-encodings-alist' (which see).")
|
2003-05-29 01:28:24 +00:00
|
|
|
|
|
|
|
|
|
(defvar ctext-non-standard-encodings-regexp
|
2009-11-12 06:55:39 +00:00
|
|
|
|
(purecopy
|
2003-05-29 01:28:24 +00:00
|
|
|
|
(string-to-multibyte
|
|
|
|
|
(concat
|
|
|
|
|
;; For non-standard encodings.
|
|
|
|
|
"\\(\e%/[0-4][\200-\377][\200-\377]\\([^\002]+\\)\002\\)"
|
|
|
|
|
"\\|"
|
|
|
|
|
;; For UTF-8 encoding.
|
2009-11-12 06:55:39 +00:00
|
|
|
|
"\\(\e%G[^\e]*\e%@\\)"))))
|
2002-02-22 13:44:21 +00:00
|
|
|
|
|
|
|
|
|
;; Functions to support "Non-Standard Character Set Encodings" defined
|
2004-04-16 12:51:06 +00:00
|
|
|
|
;; by the COMPOUND-TEXT spec. They also support "The UTF-8 encoding"
|
|
|
|
|
;; described in the section 7 of the documentation of COMPOUND-TEXT
|
|
|
|
|
;; distributed with XFree86.
|
2002-07-29 05:05:19 +00:00
|
|
|
|
|
2002-02-22 13:44:21 +00:00
|
|
|
|
(defun ctext-post-read-conversion (len)
|
|
|
|
|
"Decode LEN characters encoded as Compound Text with Extended Segments."
|
2003-05-28 11:41:17 +00:00
|
|
|
|
;; We don't need the following because it is expected that this
|
|
|
|
|
;; function is mainly used for decoding X selection which is not
|
|
|
|
|
;; that big data.
|
|
|
|
|
;;(buffer-disable-undo) ; minimize consing due to insertions and deletions
|
2002-02-22 13:44:21 +00:00
|
|
|
|
(save-match-data
|
2003-05-29 01:28:24 +00:00
|
|
|
|
(save-restriction
|
2003-05-28 11:41:17 +00:00
|
|
|
|
(narrow-to-region (point) (+ (point) len))
|
2003-05-29 01:28:24 +00:00
|
|
|
|
(let ((case-fold-search nil)
|
|
|
|
|
last-coding-system-used
|
|
|
|
|
pos bytes)
|
|
|
|
|
(decode-coding-region (point-min) (point-max) 'ctext)
|
|
|
|
|
(while (re-search-forward ctext-non-standard-encodings-regexp
|
|
|
|
|
nil 'move)
|
|
|
|
|
(setq pos (match-beginning 0))
|
|
|
|
|
(if (match-beginning 1)
|
|
|
|
|
;; ESC % / [0-4] M L --ENCODING-NAME-- \002 --BYTES--
|
2006-02-27 01:24:24 +00:00
|
|
|
|
(let* ((M (multibyte-char-to-unibyte (char-after (+ pos 4))))
|
|
|
|
|
(L (multibyte-char-to-unibyte (char-after (+ pos 5))))
|
2003-05-29 01:28:24 +00:00
|
|
|
|
(encoding (match-string 2))
|
2004-06-02 00:43:56 +00:00
|
|
|
|
(encoding-info (assoc-string
|
2004-04-16 12:51:06 +00:00
|
|
|
|
encoding
|
2004-04-21 19:17:03 +00:00
|
|
|
|
ctext-non-standard-encodings-alist t))
|
2004-04-16 12:51:06 +00:00
|
|
|
|
(coding (if encoding-info
|
|
|
|
|
(nth 1 encoding-info)
|
|
|
|
|
(setq encoding (intern (downcase encoding)))
|
|
|
|
|
(and (coding-system-p encoding)
|
|
|
|
|
encoding))))
|
2003-05-29 01:28:24 +00:00
|
|
|
|
(setq bytes (- (+ (* (- M 128) 128) (- L 128))
|
|
|
|
|
(- (point) (+ pos 6))))
|
|
|
|
|
(when coding
|
|
|
|
|
(delete-region pos (point))
|
|
|
|
|
(forward-char bytes)
|
|
|
|
|
(decode-coding-region (- (point) bytes) (point) coding)))
|
|
|
|
|
;; ESC % G --UTF-8-BYTES-- ESC % @
|
2004-04-16 12:51:06 +00:00
|
|
|
|
(delete-char -3)
|
|
|
|
|
(delete-region pos (+ pos 3))
|
|
|
|
|
(decode-coding-region pos (point) 'utf-8))))
|
2003-05-29 01:28:24 +00:00
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(- (point-max) (point)))))
|
2002-02-22 13:44:21 +00:00
|
|
|
|
|
2010-08-04 17:06:52 +09:00
|
|
|
|
(defvar ctext-standard-encodings
|
|
|
|
|
'(ascii latin-jisx0201 katakana-jisx0201
|
|
|
|
|
latin-iso8859-1 latin-iso8859-2 latin-iso8859-3 latin-iso8859-4
|
|
|
|
|
greek-iso8859-7 arabic-iso8859-6 hebrew-iso8859-8 cyrillic-iso8859-5
|
|
|
|
|
latin-iso8859-9
|
|
|
|
|
chinese-gb2312 japanese-jisx0208 korean-ksc5601)
|
|
|
|
|
"List of approved standard encodings (i.e. charsets) of X's Compound Text.
|
|
|
|
|
Coding-system `compound-text-with-extensions' encodes a character
|
|
|
|
|
belonging to any of those charsets using the normal ISO2022
|
|
|
|
|
designation sequence unless the current language environment or
|
|
|
|
|
the variable `ctext-non-standard-encodings' decide to use an extended
|
|
|
|
|
segment of CTEXT for that character. See also the documentation
|
|
|
|
|
of `ctext-non-standard-encodings-alist'.")
|
|
|
|
|
|
2006-02-27 01:24:24 +00:00
|
|
|
|
;; Return an alist of CHARSET vs CTEXT-USAGE-INFO generated from
|
|
|
|
|
;; `ctext-non-standard-encodings' and a list specified by the key
|
|
|
|
|
;; `ctext-non-standard-encodings' for the currrent language
|
|
|
|
|
;; environment. CTEXT-USAGE-INFO is one of the element of
|
|
|
|
|
;; `ctext-non-standard-encodings-alist' or nil. In the former case, a
|
|
|
|
|
;; character in CHARSET is encoded using extended segment. In the
|
|
|
|
|
;; latter case, a character in CHARSET is encoded using normal ISO2022
|
|
|
|
|
;; designation sequence. If a character is not in any of CHARSETs, it
|
|
|
|
|
;; is encoded using UTF-8 encoding extention.
|
2004-04-16 12:51:06 +00:00
|
|
|
|
|
|
|
|
|
(defun ctext-non-standard-encodings-table ()
|
2010-08-04 17:06:52 +09:00
|
|
|
|
(let* ((table (append ctext-non-standard-encodings
|
|
|
|
|
(copy-sequence
|
|
|
|
|
(get-language-info current-language-environment
|
|
|
|
|
'ctext-non-standard-encodings))))
|
|
|
|
|
(tail table)
|
|
|
|
|
elt)
|
|
|
|
|
(while tail
|
|
|
|
|
(setq elt (car tail))
|
|
|
|
|
(let* ((slot (assoc elt ctext-non-standard-encodings-alist))
|
2004-04-16 12:51:06 +00:00
|
|
|
|
(charset (nth 3 slot)))
|
2006-02-27 01:24:24 +00:00
|
|
|
|
(if (charsetp charset)
|
2010-08-06 17:11:19 +09:00
|
|
|
|
(setcar tail
|
|
|
|
|
(cons (plist-get (charset-plist charset) :base) slot))
|
2010-08-04 17:06:52 +09:00
|
|
|
|
(setcar tail (cons (car charset) slot))
|
|
|
|
|
(dolist (cs (cdr charset))
|
|
|
|
|
(setcdr tail
|
2010-08-06 17:11:19 +09:00
|
|
|
|
(cons (cons (plist-get (charset-plist (car cs)) :base) slot)
|
|
|
|
|
(cdr tail)))
|
2010-08-04 17:06:52 +09:00
|
|
|
|
(setq tail (cdr tail))))
|
|
|
|
|
(setq tail (cdr tail))))
|
|
|
|
|
table))
|
2002-02-22 13:44:21 +00:00
|
|
|
|
|
|
|
|
|
(defun ctext-pre-write-conversion (from to)
|
2002-02-26 16:27:47 +00:00
|
|
|
|
"Encode characters between FROM and TO as Compound Text w/Extended Segments.
|
|
|
|
|
|
2010-08-04 17:06:52 +09:00
|
|
|
|
If FROM is a string, generate a new temp buffer, insert the text,
|
|
|
|
|
and convert it in the temporary buffer. Otherwise, convert
|
|
|
|
|
in-place."
|
2002-02-22 13:44:21 +00:00
|
|
|
|
(save-match-data
|
2003-05-29 01:28:24 +00:00
|
|
|
|
;; Setup a working buffer if necessary.
|
2003-05-30 06:02:00 +00:00
|
|
|
|
(when (stringp from)
|
|
|
|
|
(set-buffer (generate-new-buffer " *temp"))
|
|
|
|
|
(set-buffer-multibyte (multibyte-string-p from))
|
2010-08-04 17:06:52 +09:00
|
|
|
|
(insert from)
|
2011-01-20 17:36:12 -05:00
|
|
|
|
(setq from (point-min) to (point-max)))
|
2010-08-04 17:06:52 +09:00
|
|
|
|
(save-restriction
|
|
|
|
|
(narrow-to-region from to)
|
2010-08-06 17:11:19 +09:00
|
|
|
|
(goto-char from)
|
2010-08-04 17:06:52 +09:00
|
|
|
|
(let ((encoding-table (ctext-non-standard-encodings-table))
|
2010-08-06 17:11:19 +09:00
|
|
|
|
(charset-list (sort-charsets
|
|
|
|
|
(copy-sequence ctext-standard-encodings)))
|
|
|
|
|
(end-pos (make-marker))
|
2010-08-04 17:06:52 +09:00
|
|
|
|
last-coding-system-used
|
2010-08-06 17:11:19 +09:00
|
|
|
|
last-pos charset encoding-info)
|
2010-08-04 17:06:52 +09:00
|
|
|
|
(dolist (elt encoding-table)
|
|
|
|
|
(push (car elt) charset-list))
|
|
|
|
|
(setq end-pos (point-marker))
|
2010-08-06 17:11:19 +09:00
|
|
|
|
(while (re-search-forward "[^\0-\177]+" nil t)
|
2010-08-04 17:06:52 +09:00
|
|
|
|
;; Found a sequence of non-ASCII characters.
|
|
|
|
|
(set-marker end-pos (match-end 0))
|
2010-08-06 17:11:19 +09:00
|
|
|
|
(goto-char (match-beginning 0))
|
|
|
|
|
(setq last-pos (point)
|
|
|
|
|
charset (char-charset (following-char) charset-list))
|
|
|
|
|
(forward-char 1)
|
|
|
|
|
(while (and (< (point) end-pos)
|
|
|
|
|
(eq charset (char-charset (following-char) charset-list)))
|
|
|
|
|
(forward-char 1))
|
|
|
|
|
(if charset
|
|
|
|
|
(if (setq encoding-info (cdr (assq charset encoding-table)))
|
|
|
|
|
;; Encode this range using an extended segment.
|
|
|
|
|
(let ((encoding-name (car encoding-info))
|
|
|
|
|
(coding-system (nth 1 encoding-info))
|
|
|
|
|
(noctets (nth 2 encoding-info))
|
|
|
|
|
len)
|
|
|
|
|
(encode-coding-region last-pos (point) coding-system)
|
|
|
|
|
(setq len (+ (length encoding-name) 1
|
|
|
|
|
(- (point) last-pos)))
|
|
|
|
|
;; According to the spec of CTEXT, it is not
|
|
|
|
|
;; necessary to produce this extra designation
|
|
|
|
|
;; sequence, but some buggy application
|
|
|
|
|
;; (e.g. crxvt-gb) requires it.
|
|
|
|
|
(insert "\e(B")
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char last-pos)
|
|
|
|
|
(insert (format "\e%%/%d" noctets))
|
|
|
|
|
(insert-byte (+ (/ len 128) 128) 1)
|
|
|
|
|
(insert-byte (+ (% len 128) 128) 1)
|
|
|
|
|
(insert encoding-name)
|
|
|
|
|
(insert 2)))
|
|
|
|
|
;; Encode this range as characters in CHARSET.
|
|
|
|
|
(put-text-property last-pos (point) 'charset charset))
|
|
|
|
|
;; Encode this range using UTF-8 encoding extention.
|
|
|
|
|
(encode-coding-region last-pos (point) 'mule-utf-8)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char last-pos)
|
|
|
|
|
(insert "\e%G"))
|
|
|
|
|
(insert "\e%@")))
|
2010-08-04 17:06:52 +09:00
|
|
|
|
(goto-char (point-min)))))
|
2002-02-26 16:27:47 +00:00
|
|
|
|
;; Must return nil, as build_annotations_2 expects that.
|
2002-02-22 13:44:21 +00:00
|
|
|
|
nil)
|
|
|
|
|
|
1997-02-20 07:02:49 +00:00
|
|
|
|
;;; FILE I/O
|
|
|
|
|
|
2000-12-06 18:48:59 +00:00
|
|
|
|
(defcustom auto-coding-alist
|
2007-04-19 23:51:59 +00:00
|
|
|
|
;; .exe and .EXE are added to support archive-mode looking at DOS
|
|
|
|
|
;; self-extracting exe archives.
|
2011-02-01 16:37:12 -05:00
|
|
|
|
(mapcar (lambda (arg) (cons (purecopy (car arg)) (cdr arg)))
|
|
|
|
|
'(("\\.\\(\
|
2010-04-19 02:08:52 +03:00
|
|
|
|
arc\\|zip\\|lzh\\|lha\\|zoo\\|[jew]ar\\|xpi\\|rar\\|7z\\|\
|
|
|
|
|
ARC\\|ZIP\\|LZH\\|LHA\\|ZOO\\|[JEW]AR\\|XPI\\|RAR\\|7Z\\)\\'"
|
2011-02-01 16:37:12 -05:00
|
|
|
|
. no-conversion-multibyte)
|
2008-03-16 01:54:07 +00:00
|
|
|
|
("\\.\\(exe\\|EXE\\)\\'" . no-conversion)
|
2006-03-11 11:43:27 +00:00
|
|
|
|
("\\.\\(sx[dmicw]\\|odt\\|tar\\|tgz\\)\\'" . no-conversion)
|
2010-09-25 14:42:48 -07:00
|
|
|
|
("\\.\\(gz\\|Z\\|bz\\|bz2\\|xz\\|gpg\\)\\'" . no-conversion)
|
2005-03-28 01:40:34 +00:00
|
|
|
|
("\\.\\(jpe?g\\|png\\|gif\\|tiff?\\|p[bpgn]m\\)\\'" . no-conversion)
|
2007-04-29 14:43:28 +00:00
|
|
|
|
("\\.pdf\\'" . no-conversion)
|
2009-11-11 06:27:23 +00:00
|
|
|
|
("/#[^/]+#\\'" . emacs-mule)))
|
1998-07-25 04:23:13 +00:00
|
|
|
|
"Alist of filename patterns vs corresponding coding systems.
|
|
|
|
|
Each element looks like (REGEXP . CODING-SYSTEM).
|
1998-07-25 04:48:35 +00:00
|
|
|
|
A file whose name matches REGEXP is decoded by CODING-SYSTEM on reading.
|
1998-07-25 04:23:13 +00:00
|
|
|
|
|
1998-07-25 20:56:15 +00:00
|
|
|
|
The settings in this alist take priority over `coding:' tags
|
|
|
|
|
in the file (see the function `set-auto-coding')
|
2000-12-06 18:48:59 +00:00
|
|
|
|
and the contents of `file-coding-system-alist'."
|
2010-09-25 14:42:48 -07:00
|
|
|
|
:version "24.1" ; added xz
|
2000-12-06 18:48:59 +00:00
|
|
|
|
:group 'files
|
|
|
|
|
:group 'mule
|
|
|
|
|
:type '(repeat (cons (regexp :tag "File name regexp")
|
|
|
|
|
(symbol :tag "Coding system"))))
|
1998-07-25 04:23:13 +00:00
|
|
|
|
|
2001-05-16 10:36:54 +00:00
|
|
|
|
(defcustom auto-coding-regexp-alist
|
2011-02-01 16:37:12 -05:00
|
|
|
|
(mapcar (lambda (arg) (cons (purecopy (car arg)) (cdr arg)))
|
2009-07-19 00:40:04 +00:00
|
|
|
|
'(("\\`BABYL OPTIONS:[ \t]*-\\*-[ \t]*rmail[ \t]*-\\*-" . no-conversion)
|
2006-03-16 02:22:20 +00:00
|
|
|
|
("\\`\xFE\xFF" . utf-16be-with-signature)
|
|
|
|
|
("\\`\xFF\xFE" . utf-16le-with-signature)
|
2008-12-20 09:33:52 +00:00
|
|
|
|
("\\`\xEF\xBB\xBF" . utf-8-with-signature)
|
2009-11-11 06:27:23 +00:00
|
|
|
|
("\\`;ELC\024\0\0\0" . emacs-mule))) ; Emacs 20-compiled
|
2001-05-16 10:36:54 +00:00
|
|
|
|
"Alist of patterns vs corresponding coding systems.
|
|
|
|
|
Each element looks like (REGEXP . CODING-SYSTEM).
|
|
|
|
|
A file whose first bytes match REGEXP is decoded by CODING-SYSTEM on reading.
|
|
|
|
|
|
|
|
|
|
The settings in this alist take priority over `coding:' tags
|
|
|
|
|
in the file (see the function `set-auto-coding')
|
|
|
|
|
and the contents of `file-coding-system-alist'."
|
|
|
|
|
:group 'files
|
|
|
|
|
:group 'mule
|
|
|
|
|
:type '(repeat (cons (regexp :tag "Regexp")
|
|
|
|
|
(symbol :tag "Coding system"))))
|
|
|
|
|
|
2006-01-16 12:08:35 +00:00
|
|
|
|
(defun auto-coding-regexp-alist-lookup (from to)
|
|
|
|
|
"Lookup `auto-coding-regexp-alist' for the contents of the current buffer.
|
|
|
|
|
The value is a coding system is specified for the region FROM and TO,
|
|
|
|
|
or nil."
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char from)
|
|
|
|
|
(let ((alist auto-coding-regexp-alist)
|
|
|
|
|
coding-system)
|
|
|
|
|
(while (and alist (not coding-system))
|
|
|
|
|
(let ((regexp (car (car alist))))
|
|
|
|
|
(if enable-multibyte-characters
|
|
|
|
|
(setq regexp (string-to-multibyte regexp)))
|
|
|
|
|
(if (re-search-forward regexp to t)
|
|
|
|
|
(setq coding-system (cdr (car alist)))
|
|
|
|
|
(setq alist (cdr alist)))))
|
|
|
|
|
coding-system)))
|
|
|
|
|
|
2002-05-21 21:14:03 +00:00
|
|
|
|
;; See the bottom of this file for built-in auto coding functions.
|
2002-06-08 20:58:59 +00:00
|
|
|
|
(defcustom auto-coding-functions '(sgml-xml-auto-coding-function
|
|
|
|
|
sgml-html-meta-auto-coding-function)
|
2002-05-21 21:14:03 +00:00
|
|
|
|
"A list of functions which attempt to determine a coding system.
|
|
|
|
|
|
2003-07-21 09:54:09 +00:00
|
|
|
|
Each function in this list should be written to operate on the
|
|
|
|
|
current buffer, but should not modify it in any way. The buffer
|
|
|
|
|
will contain undecoded text of parts of the file. Each function
|
2008-11-12 18:39:08 +00:00
|
|
|
|
should take one argument, SIZE, which says how many characters
|
|
|
|
|
\(starting from point) it should look at.
|
2003-07-21 09:54:09 +00:00
|
|
|
|
|
|
|
|
|
If one of these functions succeeds in determining a coding
|
|
|
|
|
system, it should return that coding system. Otherwise, it
|
|
|
|
|
should return nil.
|
|
|
|
|
|
|
|
|
|
If a file has a `coding:' tag, that takes precedence over these
|
|
|
|
|
functions, so they won't be called at all."
|
2002-05-21 21:14:03 +00:00
|
|
|
|
:group 'files
|
|
|
|
|
:group 'mule
|
|
|
|
|
:type '(repeat function))
|
|
|
|
|
|
1998-07-06 01:52:48 +00:00
|
|
|
|
(defvar set-auto-coding-for-load nil
|
|
|
|
|
"Non-nil means look for `load-coding' property instead of `coding'.
|
|
|
|
|
This is used for loading and byte-compiling Emacs Lisp files.")
|
|
|
|
|
|
1999-04-08 22:27:44 +00:00
|
|
|
|
(defun auto-coding-alist-lookup (filename)
|
|
|
|
|
"Return the coding system specified by `auto-coding-alist' for FILENAME."
|
|
|
|
|
(let ((alist auto-coding-alist)
|
2008-07-31 05:33:56 +00:00
|
|
|
|
(case-fold-search (memq system-type '(windows-nt ms-dos cygwin)))
|
1999-04-08 22:27:44 +00:00
|
|
|
|
coding-system)
|
|
|
|
|
(while (and alist (not coding-system))
|
|
|
|
|
(if (string-match (car (car alist)) filename)
|
|
|
|
|
(setq coding-system (cdr (car alist)))
|
|
|
|
|
(setq alist (cdr alist))))
|
|
|
|
|
coding-system))
|
|
|
|
|
|
2006-06-02 06:28:36 +00:00
|
|
|
|
(put 'enable-character-translation 'permanent-local t)
|
|
|
|
|
(put 'enable-character-translation 'safe-local-variable 'booleanp)
|
|
|
|
|
|
2005-07-19 02:30:54 +00:00
|
|
|
|
(defun find-auto-coding (filename size)
|
|
|
|
|
"Find a coding system for a file FILENAME of which SIZE bytes follow point.
|
1998-07-06 01:52:48 +00:00
|
|
|
|
These bytes should include at least the first 1k of the file
|
|
|
|
|
and the last 3k of the file, but the middle may be omitted.
|
1997-09-01 07:19:38 +00:00
|
|
|
|
|
2002-07-24 22:22:47 +00:00
|
|
|
|
The function checks FILENAME against the variable `auto-coding-alist'.
|
|
|
|
|
If FILENAME doesn't match any entries in the variable, it checks the
|
2001-05-16 10:36:54 +00:00
|
|
|
|
contents of the current buffer following point against
|
2002-06-08 20:58:59 +00:00
|
|
|
|
`auto-coding-regexp-alist'. If no match is found, it checks for a
|
2001-05-16 10:36:54 +00:00
|
|
|
|
`coding:' tag in the first one or two lines following point. If no
|
2002-07-24 22:22:47 +00:00
|
|
|
|
`coding:' tag is found, it checks any local variables list in the last
|
2002-06-08 20:58:59 +00:00
|
|
|
|
3K bytes out of the SIZE bytes. Finally, if none of these methods
|
2002-07-24 22:22:47 +00:00
|
|
|
|
succeed, it checks to see if any function in `auto-coding-functions'
|
|
|
|
|
gives a match.
|
1997-09-01 07:19:38 +00:00
|
|
|
|
|
2008-11-12 18:39:08 +00:00
|
|
|
|
If a coding system is specifed, the return value is a cons
|
|
|
|
|
\(CODING . SOURCE), where CODING is the specified coding system and
|
|
|
|
|
SOURCE is a symbol `auto-coding-alist', `auto-coding-regexp-alist',
|
2008-12-15 15:22:48 +00:00
|
|
|
|
`:coding', or `auto-coding-functions' indicating by what CODING is
|
2008-11-12 18:39:08 +00:00
|
|
|
|
specified. Note that the validity of CODING is not checked;
|
|
|
|
|
it's the caller's responsibility to check it.
|
2005-07-19 02:30:54 +00:00
|
|
|
|
|
2006-01-16 12:08:35 +00:00
|
|
|
|
If nothing is specified, the return value is nil."
|
2005-07-19 02:30:54 +00:00
|
|
|
|
(or (let ((coding-system (auto-coding-alist-lookup filename)))
|
|
|
|
|
(if coding-system
|
|
|
|
|
(cons coding-system 'auto-coding-alist)))
|
2002-06-08 20:58:59 +00:00
|
|
|
|
;; Try using `auto-coding-regexp-alist'.
|
2006-01-16 12:08:35 +00:00
|
|
|
|
(let ((coding-system (auto-coding-regexp-alist-lookup (point)
|
|
|
|
|
(+ (point) size))))
|
|
|
|
|
(if coding-system
|
|
|
|
|
(cons coding-system 'auto-coding-regexp-alist)))
|
2001-05-16 10:36:54 +00:00
|
|
|
|
(let* ((case-fold-search t)
|
|
|
|
|
(head-start (point))
|
|
|
|
|
(head-end (+ head-start (min size 1024)))
|
|
|
|
|
(tail-start (+ head-start (max (- size 3072) 0)))
|
|
|
|
|
(tail-end (+ head-start size))
|
2006-06-02 06:28:36 +00:00
|
|
|
|
coding-system head-found tail-found pos char-trans)
|
2001-05-16 10:36:54 +00:00
|
|
|
|
;; Try a short cut by searching for the string "coding:"
|
|
|
|
|
;; and for "unibyte:" at the head and tail of SIZE bytes.
|
|
|
|
|
(setq head-found (or (search-forward "coding:" head-end t)
|
2006-06-02 06:28:36 +00:00
|
|
|
|
(search-forward "unibyte:" head-end t)
|
2006-11-06 23:05:34 +00:00
|
|
|
|
(search-forward "enable-character-translation:"
|
2006-06-07 01:20:16 +00:00
|
|
|
|
head-end t)))
|
2001-05-16 10:36:54 +00:00
|
|
|
|
(if (and head-found (> head-found tail-start))
|
|
|
|
|
;; Head and tail are overlapped.
|
|
|
|
|
(setq tail-found head-found)
|
|
|
|
|
(goto-char tail-start)
|
|
|
|
|
(setq tail-found (or (search-forward "coding:" tail-end t)
|
2006-06-02 06:28:36 +00:00
|
|
|
|
(search-forward "unibyte:" tail-end t)
|
|
|
|
|
(search-forward "enable-character-translation:"
|
|
|
|
|
tail-end t))))
|
2001-05-16 10:36:54 +00:00
|
|
|
|
|
|
|
|
|
;; At first check the head.
|
|
|
|
|
(when head-found
|
|
|
|
|
(goto-char head-start)
|
2001-12-12 00:13:42 +00:00
|
|
|
|
(setq head-end (set-auto-mode-1))
|
|
|
|
|
(setq head-start (point))
|
2001-12-13 14:42:27 +00:00
|
|
|
|
(when (and head-end (< head-found head-end))
|
1998-07-25 04:23:13 +00:00
|
|
|
|
(goto-char head-start)
|
2001-05-16 10:36:54 +00:00
|
|
|
|
(when (and set-auto-coding-for-load
|
|
|
|
|
(re-search-forward
|
2001-12-12 00:13:42 +00:00
|
|
|
|
"\\(.*;\\)?[ \t]*unibyte:[ \t]*\\([^ ;]+\\)"
|
2001-05-16 10:36:54 +00:00
|
|
|
|
head-end t))
|
|
|
|
|
(setq coding-system 'raw-text))
|
|
|
|
|
(when (and (not coding-system)
|
|
|
|
|
(re-search-forward
|
2001-12-12 00:13:42 +00:00
|
|
|
|
"\\(.*;\\)?[ \t]*coding:[ \t]*\\([^ ;]+\\)"
|
2001-05-16 10:36:54 +00:00
|
|
|
|
head-end t))
|
2006-06-02 06:28:36 +00:00
|
|
|
|
(setq coding-system (intern (match-string 2))))
|
|
|
|
|
(when (re-search-forward
|
2006-06-07 01:20:16 +00:00
|
|
|
|
"\\(.*;\\)?[ \t]*enable-character-translation:[ \t]*\\([^ ;]+\\)"
|
2006-06-02 06:28:36 +00:00
|
|
|
|
head-end t)
|
2006-06-07 01:20:16 +00:00
|
|
|
|
(setq char-trans (match-string 2)))))
|
2001-05-16 10:36:54 +00:00
|
|
|
|
|
|
|
|
|
;; If no coding: tag in the head, check the tail.
|
2004-04-16 12:51:06 +00:00
|
|
|
|
;; Here we must pay attention to the case that the end-of-line
|
|
|
|
|
;; is just "\r" and we can't use "^" nor "$" in regexp.
|
2006-06-02 06:28:36 +00:00
|
|
|
|
(when (and tail-found (or (not coding-system) (not char-trans)))
|
2001-05-16 10:36:54 +00:00
|
|
|
|
(goto-char tail-start)
|
2007-03-03 22:03:04 +00:00
|
|
|
|
(re-search-forward "[\r\n]\^L" tail-end t)
|
2001-05-16 10:36:54 +00:00
|
|
|
|
(if (re-search-forward
|
2004-06-02 00:43:56 +00:00
|
|
|
|
"[\r\n]\\([^[\r\n]*\\)[ \t]*Local Variables:[ \t]*\\([^\r\n]*\\)[\r\n]"
|
2004-04-16 12:51:06 +00:00
|
|
|
|
tail-end t)
|
|
|
|
|
;; The prefix is what comes before "local variables:" in its
|
|
|
|
|
;; line. The suffix is what comes after "local variables:"
|
2001-05-16 10:36:54 +00:00
|
|
|
|
;; in its line.
|
|
|
|
|
(let* ((prefix (regexp-quote (match-string 1)))
|
|
|
|
|
(suffix (regexp-quote (match-string 2)))
|
|
|
|
|
(re-coding
|
|
|
|
|
(concat
|
2004-04-16 12:51:06 +00:00
|
|
|
|
"[\r\n]" prefix
|
2001-10-15 08:47:11 +00:00
|
|
|
|
;; N.B. without the \n below, the regexp can
|
|
|
|
|
;; eat newlines.
|
2004-04-16 12:51:06 +00:00
|
|
|
|
"[ \t]*coding[ \t]*:[ \t]*\\([^ \t\r\n]+\\)[ \t]*"
|
|
|
|
|
suffix "[\r\n]"))
|
2001-05-16 10:36:54 +00:00
|
|
|
|
(re-unibyte
|
|
|
|
|
(concat
|
2004-04-16 12:51:06 +00:00
|
|
|
|
"[\r\n]" prefix
|
|
|
|
|
"[ \t]*unibyte[ \t]*:[ \t]*\\([^ \t\r\n]+\\)[ \t]*"
|
|
|
|
|
suffix "[\r\n]"))
|
2006-06-02 06:28:36 +00:00
|
|
|
|
(re-char-trans
|
|
|
|
|
(concat
|
|
|
|
|
"[\r\n]" prefix
|
2006-06-07 01:20:16 +00:00
|
|
|
|
"[ \t]*enable-character-translation[ \t]*:[ \t]*\\([^ \t\r\n]+\\)[ \t]*"
|
2006-06-02 06:28:36 +00:00
|
|
|
|
suffix "[\r\n]"))
|
2001-05-16 10:36:54 +00:00
|
|
|
|
(re-end
|
2004-06-02 00:43:56 +00:00
|
|
|
|
(concat "[\r\n]" prefix "[ \t]*End *:[ \t]*" suffix
|
2004-04-16 12:51:06 +00:00
|
|
|
|
"[\r\n]?"))
|
|
|
|
|
(pos (1- (point))))
|
|
|
|
|
(forward-char -1) ; skip back \r or \n.
|
2001-05-16 10:36:54 +00:00
|
|
|
|
(re-search-forward re-end tail-end 'move)
|
|
|
|
|
(setq tail-end (point))
|
|
|
|
|
(goto-char pos)
|
|
|
|
|
(when (and set-auto-coding-for-load
|
|
|
|
|
(re-search-forward re-unibyte tail-end t))
|
|
|
|
|
(setq coding-system 'raw-text))
|
|
|
|
|
(when (and (not coding-system)
|
|
|
|
|
(re-search-forward re-coding tail-end t))
|
2006-06-02 06:28:36 +00:00
|
|
|
|
(setq coding-system (intern (match-string 1))))
|
|
|
|
|
(when (and (not char-trans)
|
|
|
|
|
(re-search-forward re-char-trans tail-end t))
|
2006-06-07 01:20:16 +00:00
|
|
|
|
(setq char-trans (match-string 1))))))
|
2006-06-02 06:28:36 +00:00
|
|
|
|
(if coding-system
|
|
|
|
|
;; If the coding-system name ends with "!", remove it and
|
|
|
|
|
;; set char-trans to "nil".
|
|
|
|
|
(let ((name (symbol-name coding-system)))
|
|
|
|
|
(if (= (aref name (1- (length name))) ?!)
|
|
|
|
|
(setq coding-system (intern (substring name 0 -1))
|
|
|
|
|
char-trans "nil"))))
|
|
|
|
|
(when (and char-trans
|
|
|
|
|
(not (setq char-trans (intern char-trans))))
|
|
|
|
|
(make-local-variable 'enable-character-translation)
|
|
|
|
|
(setq enable-character-translation nil))
|
2005-07-19 02:30:54 +00:00
|
|
|
|
(if coding-system
|
|
|
|
|
(cons coding-system :coding)))
|
2002-06-08 20:58:59 +00:00
|
|
|
|
;; Finally, try all the `auto-coding-functions'.
|
|
|
|
|
(let ((funcs auto-coding-functions)
|
|
|
|
|
(coding-system nil))
|
|
|
|
|
(while (and funcs (not coding-system))
|
|
|
|
|
(setq coding-system (condition-case e
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(funcall (pop funcs) size))
|
|
|
|
|
(error nil))))
|
2005-07-19 02:30:54 +00:00
|
|
|
|
(if coding-system
|
|
|
|
|
(cons coding-system 'auto-coding-functions)))))
|
|
|
|
|
|
|
|
|
|
(defun set-auto-coding (filename size)
|
|
|
|
|
"Return coding system for a file FILENAME of which SIZE bytes follow point.
|
|
|
|
|
See `find-auto-coding' for how the coding system is found.
|
2006-01-16 12:08:35 +00:00
|
|
|
|
Return nil if an invalid coding system is found.
|
|
|
|
|
|
|
|
|
|
The variable `set-auto-coding-function' (which see) is set to this
|
|
|
|
|
function by default."
|
2005-07-19 02:30:54 +00:00
|
|
|
|
(let ((found (find-auto-coding filename size)))
|
|
|
|
|
(if (and found (coding-system-p (car found)))
|
|
|
|
|
(car found))))
|
1997-09-01 07:19:38 +00:00
|
|
|
|
|
|
|
|
|
(setq set-auto-coding-function 'set-auto-coding)
|
1997-08-22 01:22:49 +00:00
|
|
|
|
|
2004-12-30 12:39:58 +00:00
|
|
|
|
(defun after-insert-file-set-coding (inserted &optional visit)
|
2003-04-14 10:06:55 +00:00
|
|
|
|
"Set `buffer-file-coding-system' of current buffer after text is inserted.
|
|
|
|
|
INSERTED is the number of characters that were inserted, as figured
|
|
|
|
|
in the situation before this function. Return the number of characters
|
|
|
|
|
inserted, as figured in the situation after. The two numbers can be
|
2004-12-30 12:39:58 +00:00
|
|
|
|
different if the buffer has become unibyte.
|
|
|
|
|
The optional second arg VISIT non-nil means that we are visiting a file."
|
|
|
|
|
(if (and visit
|
|
|
|
|
coding-system-for-read
|
|
|
|
|
(not (eq coding-system-for-read 'auto-save-coding)))
|
2009-03-03 01:56:14 +00:00
|
|
|
|
(setq buffer-file-coding-system-explicit
|
|
|
|
|
(cons coding-system-for-read nil)))
|
1997-02-20 07:02:49 +00:00
|
|
|
|
(if last-coding-system-used
|
|
|
|
|
(let ((coding-system
|
2004-11-19 06:55:13 +00:00
|
|
|
|
(find-new-buffer-file-coding-system last-coding-system-used)))
|
2009-03-18 07:24:52 +00:00
|
|
|
|
(if coding-system
|
|
|
|
|
(setq buffer-file-coding-system coding-system))))
|
1998-11-16 01:17:06 +00:00
|
|
|
|
inserted)
|
1997-02-20 07:02:49 +00:00
|
|
|
|
|
1997-06-10 00:56:15 +00:00
|
|
|
|
;; The coding-spec and eol-type of coding-system returned is decided
|
1997-02-20 07:02:49 +00:00
|
|
|
|
;; independently in the following order.
|
|
|
|
|
;; 1. That of buffer-file-coding-system locally bound.
|
|
|
|
|
;; 2. That of CODING.
|
|
|
|
|
|
|
|
|
|
(defun find-new-buffer-file-coding-system (coding)
|
|
|
|
|
"Return a coding system for a buffer when a file of CODING is inserted.
|
1997-05-12 06:56:25 +00:00
|
|
|
|
The local variable `buffer-file-coding-system' of the current buffer
|
|
|
|
|
is set to the returned value.
|
1999-04-06 19:53:10 +00:00
|
|
|
|
Return nil if there's no need to set `buffer-file-coding-system'."
|
1997-02-20 07:02:49 +00:00
|
|
|
|
(let (local-coding local-eol
|
1997-09-17 06:41:41 +00:00
|
|
|
|
found-coding found-eol
|
1997-02-20 07:02:49 +00:00
|
|
|
|
new-coding new-eol)
|
|
|
|
|
(if (null coding)
|
|
|
|
|
;; Nothing found about coding.
|
|
|
|
|
nil
|
|
|
|
|
|
1997-09-17 06:41:41 +00:00
|
|
|
|
;; Get information of `buffer-file-coding-system' in LOCAL-EOL
|
|
|
|
|
;; and LOCAL-CODING.
|
|
|
|
|
(setq local-eol (coding-system-eol-type buffer-file-coding-system))
|
|
|
|
|
(if (null (numberp local-eol))
|
|
|
|
|
;; But eol-type is not yet set.
|
|
|
|
|
(setq local-eol nil))
|
1997-10-21 10:47:35 +00:00
|
|
|
|
(if (and buffer-file-coding-system
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
(not (eq (coding-system-type buffer-file-coding-system)
|
|
|
|
|
'undecided)))
|
1997-10-21 10:47:35 +00:00
|
|
|
|
(setq local-coding (coding-system-base buffer-file-coding-system)))
|
1997-09-17 06:41:41 +00:00
|
|
|
|
|
|
|
|
|
(if (and (local-variable-p 'buffer-file-coding-system)
|
|
|
|
|
local-eol local-coding)
|
1997-02-20 07:02:49 +00:00
|
|
|
|
;; The current buffer has already set full coding-system, we
|
|
|
|
|
;; had better not change it.
|
|
|
|
|
nil
|
|
|
|
|
|
1997-06-10 00:56:15 +00:00
|
|
|
|
(setq found-eol (coding-system-eol-type coding))
|
1997-02-20 07:02:49 +00:00
|
|
|
|
(if (null (numberp found-eol))
|
1998-08-04 10:27:45 +00:00
|
|
|
|
;; But eol-type is not found.
|
|
|
|
|
;; If EOL conversions are inhibited, force unix eol-type.
|
|
|
|
|
(setq found-eol (if inhibit-eol-conversion 0)))
|
(char-valid-p): Make it an alias of characterp.
(define-charset): Fully re-designed.
(charset-quoted-standard-p): Deleted.
(charsetp): Moved to charset.c.
(charset-info, charset-id, charset-bytes, charset-width,
charset-directioin, charset-iso-graphic-plane,
charset-reverse-charset): Deleted.
(charset-dimension, charset-chars, charset-iso-final-char,
charset-description, charset-short-name, charset-long-name): Call
charset-plist instead of charset-info.
(charset-plist, set-charset-plist): Moved to charset.c.
(get-charset-property, put-charset-property): Moved from
mule-cmds.el. Call charset-plist and set-charset-plist.
(make-char): Deleted.
(generic-char-p): Make it always return nil.
(decode-char, encode-char): Moved to charset.c.
(coding-spec-XXX-idx): Variables deleted.
(coding-system-iso-2022-flags): New variable.
(define-coding-system): New function.
(transform-make-coding-system-args, make-coding-system): Deleted.
(set-coding-priority): Make it obsolete.
(after-insert-file-set-buffer-file-coding-system): Adjusted for
the new coding system structure.
(find-new-buffer-file-coding-system): Likewise.
2002-03-01 02:22:38 +00:00
|
|
|
|
(setq found-coding (coding-system-base coding))
|
1998-08-02 01:06:57 +00:00
|
|
|
|
|
|
|
|
|
(if (and (not found-eol) (eq found-coding 'undecided))
|
|
|
|
|
;; No valid coding information found.
|
|
|
|
|
nil
|
|
|
|
|
|
|
|
|
|
;; Some coding information (eol or text) found.
|
|
|
|
|
|
|
|
|
|
;; The local setting takes precedence over the found one.
|
|
|
|
|
(setq new-coding (if (local-variable-p 'buffer-file-coding-system)
|
|
|
|
|
(or local-coding found-coding)
|
|
|
|
|
(or found-coding local-coding)))
|
|
|
|
|
(setq new-eol (if (local-variable-p 'buffer-file-coding-system)
|
|
|
|
|
(or local-eol found-eol)
|
|
|
|
|
(or found-eol local-eol)))
|
|
|
|
|
|
|
|
|
|
(let ((eol-type (coding-system-eol-type new-coding)))
|
|
|
|
|
(if (and (numberp new-eol) (vectorp eol-type))
|
|
|
|
|
(aref eol-type new-eol)
|
|
|
|
|
new-coding)))))))
|
1997-02-20 07:02:49 +00:00
|
|
|
|
|
1997-07-20 01:31:41 +00:00
|
|
|
|
(defun modify-coding-system-alist (target-type regexp coding-system)
|
|
|
|
|
"Modify one of look up tables for finding a coding system on I/O operation.
|
1997-07-22 23:41:34 +00:00
|
|
|
|
There are three of such tables, `file-coding-system-alist',
|
|
|
|
|
`process-coding-system-alist', and `network-coding-system-alist'.
|
1997-07-20 01:31:41 +00:00
|
|
|
|
|
|
|
|
|
TARGET-TYPE specifies which of them to modify.
|
1997-07-22 23:41:34 +00:00
|
|
|
|
If it is `file', it affects `file-coding-system-alist' (which see).
|
|
|
|
|
If it is `process', it affects `process-coding-system-alist' (which see).
|
1998-09-06 14:31:49 +00:00
|
|
|
|
If it is `network', it affects `network-coding-system-alist' (which see).
|
1997-07-20 01:31:41 +00:00
|
|
|
|
|
|
|
|
|
REGEXP is a regular expression matching a target of I/O operation.
|
|
|
|
|
The target is a file name if TARGET-TYPE is `file', a program name if
|
|
|
|
|
TARGET-TYPE is `process', or a network service name or a port number
|
|
|
|
|
to connect to if TARGET-TYPE is `network'.
|
|
|
|
|
|
|
|
|
|
CODING-SYSTEM is a coding system to perform code conversion on the I/O
|
2008-11-12 18:39:08 +00:00
|
|
|
|
operation, or a cons cell (DECODING . ENCODING) specifying the coding
|
|
|
|
|
systems for decoding and encoding respectively, or a function symbol
|
|
|
|
|
which, when called, returns such a cons cell."
|
1997-07-20 01:31:41 +00:00
|
|
|
|
(or (memq target-type '(file process network))
|
|
|
|
|
(error "Invalid target type: %s" target-type))
|
|
|
|
|
(or (stringp regexp)
|
|
|
|
|
(and (eq target-type 'network) (integerp regexp))
|
|
|
|
|
(error "Invalid regular expression: %s" regexp))
|
|
|
|
|
(if (symbolp coding-system)
|
|
|
|
|
(if (not (fboundp coding-system))
|
|
|
|
|
(progn
|
|
|
|
|
(check-coding-system coding-system)
|
|
|
|
|
(setq coding-system (cons coding-system coding-system))))
|
|
|
|
|
(check-coding-system (car coding-system))
|
|
|
|
|
(check-coding-system (cdr coding-system)))
|
|
|
|
|
(cond ((eq target-type 'file)
|
|
|
|
|
(let ((slot (assoc regexp file-coding-system-alist)))
|
|
|
|
|
(if slot
|
|
|
|
|
(setcdr slot coding-system)
|
|
|
|
|
(setq file-coding-system-alist
|
|
|
|
|
(cons (cons regexp coding-system)
|
|
|
|
|
file-coding-system-alist)))))
|
|
|
|
|
((eq target-type 'process)
|
|
|
|
|
(let ((slot (assoc regexp process-coding-system-alist)))
|
|
|
|
|
(if slot
|
|
|
|
|
(setcdr slot coding-system)
|
|
|
|
|
(setq process-coding-system-alist
|
|
|
|
|
(cons (cons regexp coding-system)
|
|
|
|
|
process-coding-system-alist)))))
|
|
|
|
|
(t
|
|
|
|
|
(let ((slot (assoc regexp network-coding-system-alist)))
|
|
|
|
|
(if slot
|
|
|
|
|
(setcdr slot coding-system)
|
|
|
|
|
(setq network-coding-system-alist
|
|
|
|
|
(cons (cons regexp coding-system)
|
|
|
|
|
network-coding-system-alist)))))))
|
|
|
|
|
|
2003-01-24 13:28:00 +00:00
|
|
|
|
(defun decode-coding-inserted-region (from to filename
|
|
|
|
|
&optional visit beg end replace)
|
2003-01-22 02:33:07 +00:00
|
|
|
|
"Decode the region between FROM and TO as if it is read from file FILENAME.
|
2004-12-27 16:12:11 +00:00
|
|
|
|
The idea is that the text between FROM and TO was just inserted somehow.
|
2003-01-22 02:33:07 +00:00
|
|
|
|
Optional arguments VISIT, BEG, END, and REPLACE are the same as those
|
2004-12-27 16:12:11 +00:00
|
|
|
|
of the function `insert-file-contents'.
|
|
|
|
|
Part of the job of this function is setting `buffer-undo-list' appropriately."
|
2003-01-22 02:33:07 +00:00
|
|
|
|
(save-excursion
|
|
|
|
|
(save-restriction
|
2004-12-27 16:12:11 +00:00
|
|
|
|
(let ((coding coding-system-for-read)
|
|
|
|
|
undo-list-saved)
|
|
|
|
|
(if visit
|
|
|
|
|
;; Temporarily turn off undo recording, if we're decoding the
|
|
|
|
|
;; text of a visited file.
|
|
|
|
|
(setq buffer-undo-list t)
|
|
|
|
|
;; Otherwise, if we can recognize the undo elt for the insertion,
|
|
|
|
|
;; remove it and get ready to replace it later.
|
|
|
|
|
;; In the mean time, turn off undo recording.
|
2005-02-09 15:50:47 +00:00
|
|
|
|
(let ((last (car-safe buffer-undo-list)))
|
2004-12-27 16:12:11 +00:00
|
|
|
|
(if (and (consp last) (eql (car last) from) (eql (cdr last) to))
|
|
|
|
|
(setq undo-list-saved (cdr buffer-undo-list)
|
|
|
|
|
buffer-undo-list t))))
|
|
|
|
|
(narrow-to-region from to)
|
|
|
|
|
(goto-char (point-min))
|
2003-01-22 02:33:07 +00:00
|
|
|
|
(or coding
|
|
|
|
|
(setq coding (funcall set-auto-coding-function
|
|
|
|
|
filename (- (point-max) (point-min)))))
|
|
|
|
|
(or coding
|
2004-04-16 12:51:06 +00:00
|
|
|
|
(setq coding (car (find-operation-coding-system
|
|
|
|
|
'insert-file-contents
|
2006-05-26 04:47:47 +00:00
|
|
|
|
(cons filename (current-buffer))
|
|
|
|
|
visit beg end replace))))
|
2003-01-22 02:33:07 +00:00
|
|
|
|
(if (coding-system-p coding)
|
|
|
|
|
(or enable-multibyte-characters
|
|
|
|
|
(setq coding
|
|
|
|
|
(coding-system-change-text-conversion coding 'raw-text)))
|
|
|
|
|
(setq coding nil))
|
|
|
|
|
(if coding
|
2004-07-04 23:22:28 +00:00
|
|
|
|
(decode-coding-region (point-min) (point-max) coding)
|
2004-12-27 16:12:11 +00:00
|
|
|
|
(setq last-coding-system-used coding))
|
|
|
|
|
;; If we're decoding the text of a visited file,
|
|
|
|
|
;; the undo list should start out empty.
|
|
|
|
|
(if visit
|
|
|
|
|
(setq buffer-undo-list nil)
|
|
|
|
|
;; If we decided to replace the undo entry for the insertion,
|
|
|
|
|
;; do so now.
|
|
|
|
|
(if undo-list-saved
|
|
|
|
|
(setq buffer-undo-list
|
|
|
|
|
(cons (cons from (point-max)) undo-list-saved))))))))
|
2003-01-22 02:33:07 +00:00
|
|
|
|
|
2004-12-29 01:25:15 +00:00
|
|
|
|
(defun recode-region (start end new-coding coding)
|
|
|
|
|
"Re-decode the region (previously decoded by CODING) by NEW-CODING."
|
|
|
|
|
(interactive
|
|
|
|
|
(list (region-beginning) (region-end)
|
|
|
|
|
(read-coding-system "Text was really in: ")
|
|
|
|
|
(let ((coding (or buffer-file-coding-system last-coding-system-used)))
|
|
|
|
|
(read-coding-system
|
|
|
|
|
(concat "But was interpreted as"
|
|
|
|
|
(if coding (format " (default %S): " coding) ": "))
|
|
|
|
|
coding))))
|
|
|
|
|
(or (and new-coding coding)
|
|
|
|
|
(error "Coding system not specified"))
|
|
|
|
|
;; Check it before we encode the region.
|
|
|
|
|
(check-coding-system new-coding)
|
|
|
|
|
(save-restriction
|
|
|
|
|
(narrow-to-region start end)
|
|
|
|
|
(encode-coding-region (point-min) (point-max) coding)
|
2008-07-23 22:40:07 +00:00
|
|
|
|
(decode-coding-region (point-min) (point-max) new-coding))
|
|
|
|
|
(if (region-active-p)
|
|
|
|
|
(deactivate-mark)))
|
2003-01-22 02:33:07 +00:00
|
|
|
|
|
1998-05-18 01:01:00 +00:00
|
|
|
|
(defun make-translation-table (&rest args)
|
2001-02-21 14:58:35 +00:00
|
|
|
|
"Make a translation table from arguments.
|
2001-11-08 11:34:00 +00:00
|
|
|
|
A translation table is a char table intended for character
|
2001-02-21 14:58:35 +00:00
|
|
|
|
translation in CCL programs.
|
|
|
|
|
|
2001-11-08 11:34:00 +00:00
|
|
|
|
Each argument is a list of elements of the form (FROM . TO), where FROM
|
2001-02-21 14:58:35 +00:00
|
|
|
|
is a character to be translated to TO.
|
1997-05-16 00:58:57 +00:00
|
|
|
|
|
2001-01-23 01:36:19 +00:00
|
|
|
|
The arguments and forms in each argument are processed in the given
|
|
|
|
|
order, and if a previous form already translates TO to some other
|
|
|
|
|
character, say TO-ALT, FROM is also translated to TO-ALT."
|
1998-05-22 09:45:34 +00:00
|
|
|
|
(let ((table (make-char-table 'translation-table))
|
1997-05-12 06:56:25 +00:00
|
|
|
|
revlist)
|
2003-06-05 23:18:23 +00:00
|
|
|
|
(dolist (elts args)
|
|
|
|
|
(dolist (elt elts)
|
|
|
|
|
(let ((from (car elt))
|
|
|
|
|
(to (cdr elt))
|
|
|
|
|
to-alt rev-from rev-to)
|
|
|
|
|
;; If we have already translated TO to TO-ALT, FROM should
|
|
|
|
|
;; also be translated to TO-ALT.
|
|
|
|
|
(if (setq to-alt (aref table to))
|
|
|
|
|
(setq to to-alt))
|
|
|
|
|
(aset table from to)
|
|
|
|
|
;; If we have already translated some chars to FROM, they
|
|
|
|
|
;; should also be translated to TO.
|
|
|
|
|
(when (setq rev-from (assq from revlist))
|
|
|
|
|
(dolist (elt (cdr rev-from))
|
|
|
|
|
(aset table elt to))
|
|
|
|
|
(setq revlist (delq rev-from revlist)
|
|
|
|
|
rev-from (cdr rev-from)))
|
|
|
|
|
;; Now update REVLIST.
|
|
|
|
|
(setq rev-to (assq to revlist))
|
|
|
|
|
(if rev-to
|
|
|
|
|
(setcdr rev-to (cons from (cdr rev-to)))
|
|
|
|
|
(setq rev-to (list to from)
|
|
|
|
|
revlist (cons rev-to revlist)))
|
|
|
|
|
(if rev-from
|
|
|
|
|
(setcdr rev-to (append rev-from (cdr rev-to)))))))
|
1997-05-12 06:56:25 +00:00
|
|
|
|
;; Return TABLE just created.
|
2004-04-07 07:22:10 +00:00
|
|
|
|
(set-char-table-extra-slot table 1 1)
|
1997-05-12 06:56:25 +00:00
|
|
|
|
table))
|
|
|
|
|
|
1998-08-02 01:06:57 +00:00
|
|
|
|
(defun make-translation-table-from-vector (vec)
|
|
|
|
|
"Make translation table from decoding vector VEC.
|
2001-12-12 19:55:31 +00:00
|
|
|
|
VEC is an array of 256 elements to map unibyte codes to multibyte
|
2010-06-04 03:38:12 +02:00
|
|
|
|
characters. Elements may be nil for undefined code points."
|
1998-08-02 01:06:57 +00:00
|
|
|
|
(let ((table (make-char-table 'translation-table))
|
|
|
|
|
(rev-table (make-char-table 'translation-table))
|
|
|
|
|
ch)
|
2001-12-12 19:55:31 +00:00
|
|
|
|
(dotimes (i 256)
|
1998-08-02 01:06:57 +00:00
|
|
|
|
(setq ch (aref vec i))
|
2001-12-12 19:55:31 +00:00
|
|
|
|
(when ch
|
|
|
|
|
(aset table i ch)
|
|
|
|
|
(if (>= ch 256)
|
|
|
|
|
(aset rev-table ch i))))
|
1998-08-02 01:06:57 +00:00
|
|
|
|
(set-char-table-extra-slot table 0 rev-table)
|
2004-04-07 07:22:10 +00:00
|
|
|
|
(set-char-table-extra-slot table 1 1)
|
|
|
|
|
(set-char-table-extra-slot rev-table 1 1)
|
1998-08-02 01:06:57 +00:00
|
|
|
|
table))
|
|
|
|
|
|
2004-03-11 02:12:36 +00:00
|
|
|
|
(defun make-translation-table-from-alist (alist)
|
|
|
|
|
"Make translation table from N<->M mapping in ALIST.
|
|
|
|
|
ALIST is an alist, each element has the form (FROM . TO).
|
|
|
|
|
FROM and TO are a character or a vector of characters.
|
|
|
|
|
If FROM is a character, that character is translated to TO.
|
|
|
|
|
If FROM is a vector of characters, that sequence is translated to TO.
|
2004-04-07 07:22:10 +00:00
|
|
|
|
The first extra-slot of the value is a translation table for reverse mapping."
|
|
|
|
|
(let ((tables (vector (make-char-table 'translation-table)
|
|
|
|
|
(make-char-table 'translation-table)))
|
|
|
|
|
table max-lookup from to idx val)
|
|
|
|
|
(dotimes (i 2)
|
|
|
|
|
(setq table (aref tables i))
|
|
|
|
|
(setq max-lookup 1)
|
|
|
|
|
(dolist (elt alist)
|
|
|
|
|
(if (= i 0)
|
|
|
|
|
(setq from (car elt) to (cdr elt))
|
|
|
|
|
(setq from (cdr elt) to (car elt)))
|
|
|
|
|
(if (characterp from)
|
|
|
|
|
(setq idx from)
|
|
|
|
|
(setq idx (aref from 0)
|
|
|
|
|
max-lookup (max max-lookup (length from))))
|
|
|
|
|
(setq val (aref table idx))
|
|
|
|
|
(if val
|
|
|
|
|
(progn
|
|
|
|
|
(or (consp val)
|
|
|
|
|
(setq val (list (cons (vector idx) val))))
|
|
|
|
|
(if (characterp from)
|
|
|
|
|
(setq from (vector from)))
|
|
|
|
|
(setq val (nconc val (list (cons from to)))))
|
|
|
|
|
(if (characterp from)
|
|
|
|
|
(setq val to)
|
|
|
|
|
(setq val (list (cons from to)))))
|
|
|
|
|
(aset table idx val))
|
|
|
|
|
(set-char-table-extra-slot table 1 max-lookup))
|
|
|
|
|
(set-char-table-extra-slot (aref tables 0) 0 (aref tables 1))
|
|
|
|
|
(aref tables 0)))
|
2004-03-11 02:12:36 +00:00
|
|
|
|
|
1998-05-22 09:45:34 +00:00
|
|
|
|
(defun define-translation-table (symbol &rest args)
|
2001-02-21 14:58:35 +00:00
|
|
|
|
"Define SYMBOL as the name of translation table made by ARGS.
|
|
|
|
|
This sets up information so that the table can be used for
|
|
|
|
|
translations in a CCL program.
|
1998-05-18 01:01:00 +00:00
|
|
|
|
|
2001-02-21 14:58:35 +00:00
|
|
|
|
If the first element of ARGS is a char-table whose purpose is
|
|
|
|
|
`translation-table', just define SYMBOL to name it. (Note that this
|
|
|
|
|
function does not bind SYMBOL.)
|
1998-11-26 08:12:12 +00:00
|
|
|
|
|
2001-02-21 14:58:35 +00:00
|
|
|
|
Any other ARGS should be suitable as arguments of the function
|
1998-11-26 08:12:12 +00:00
|
|
|
|
`make-translation-table' (which see).
|
1998-05-18 01:01:00 +00:00
|
|
|
|
|
1998-05-25 07:23:08 +00:00
|
|
|
|
This function sets properties `translation-table' and
|
2001-02-11 17:07:35 +00:00
|
|
|
|
`translation-table-id' of SYMBOL to the created table itself and the
|
|
|
|
|
identification number of the table respectively. It also registers
|
|
|
|
|
the table in `translation-table-vector'."
|
1998-11-26 08:12:12 +00:00
|
|
|
|
(let ((table (if (and (char-table-p (car args))
|
|
|
|
|
(eq (char-table-subtype (car args))
|
|
|
|
|
'translation-table))
|
|
|
|
|
(car args)
|
|
|
|
|
(apply 'make-translation-table args)))
|
1998-05-22 09:45:34 +00:00
|
|
|
|
(len (length translation-table-vector))
|
1998-01-22 01:42:20 +00:00
|
|
|
|
(id 0)
|
1998-05-18 01:01:00 +00:00
|
|
|
|
(done nil))
|
1998-05-22 09:45:34 +00:00
|
|
|
|
(put symbol 'translation-table table)
|
1998-05-18 01:01:00 +00:00
|
|
|
|
(while (not done)
|
|
|
|
|
(if (>= id len)
|
1998-05-22 09:45:34 +00:00
|
|
|
|
(setq translation-table-vector
|
|
|
|
|
(vconcat translation-table-vector (make-vector len nil))))
|
|
|
|
|
(let ((slot (aref translation-table-vector id)))
|
1998-05-18 01:01:00 +00:00
|
|
|
|
(if (or (not slot)
|
|
|
|
|
(eq (car slot) symbol))
|
|
|
|
|
(progn
|
1998-05-22 09:45:34 +00:00
|
|
|
|
(aset translation-table-vector id (cons symbol table))
|
1998-11-26 08:12:12 +00:00
|
|
|
|
(setq done t))
|
|
|
|
|
(setq id (1+ id)))))
|
1998-05-22 09:45:34 +00:00
|
|
|
|
(put symbol 'translation-table-id id)
|
1998-01-22 01:42:20 +00:00
|
|
|
|
id))
|
|
|
|
|
|
2004-03-04 00:52:45 +00:00
|
|
|
|
(defun translate-region (start end table)
|
|
|
|
|
"From START to END, translate characters according to TABLE.
|
|
|
|
|
TABLE is a string or a char-table.
|
|
|
|
|
If TABLE is a string, the Nth character in it is the mapping
|
|
|
|
|
for the character with code N.
|
|
|
|
|
If TABLE is a char-table, the element for character N is the mapping
|
|
|
|
|
for the character with code N.
|
|
|
|
|
It returns the number of characters changed."
|
|
|
|
|
(interactive
|
|
|
|
|
(list (region-beginning)
|
|
|
|
|
(region-end)
|
|
|
|
|
(let (table l)
|
|
|
|
|
(dotimes (i (length translation-table-vector))
|
|
|
|
|
(if (consp (aref translation-table-vector i))
|
|
|
|
|
(push (list (symbol-name
|
|
|
|
|
(car (aref translation-table-vector i)))) l)))
|
|
|
|
|
(if (not l)
|
|
|
|
|
(error "No translation table defined"))
|
|
|
|
|
(while (not table)
|
|
|
|
|
(setq table (completing-read "Translation table: " l nil t)))
|
|
|
|
|
(intern table))))
|
|
|
|
|
(if (symbolp table)
|
|
|
|
|
(let ((val (get table 'translation-table)))
|
|
|
|
|
(or (char-table-p val)
|
|
|
|
|
(error "Invalid translation table name: %s" table))
|
|
|
|
|
(setq table val)))
|
|
|
|
|
(translate-region-internal start end table))
|
|
|
|
|
|
2003-03-29 02:57:19 +00:00
|
|
|
|
(defmacro with-category-table (table &rest body)
|
2008-11-12 18:39:08 +00:00
|
|
|
|
"Execute BODY like `progn' with TABLE the current category table.
|
2003-03-29 02:57:19 +00:00
|
|
|
|
The category table of the current buffer is saved, BODY is evaluated,
|
|
|
|
|
then the saved table is restored, even in case of an abnormal exit.
|
|
|
|
|
Value is what BODY returns."
|
Use `declare' in defmacros.
* lisp/window.el (save-selected-window):
* lisp/subr.el (with-temp-file, with-temp-message, with-syntax-table):
* lisp/progmodes/python.el (def-python-skeleton):
* lisp/net/dbus.el (dbus-ignore-errors):
* lisp/jka-cmpr-hook.el (with-auto-compression-mode):
* lisp/international/mule.el (with-category-table):
* lisp/emacs-lisp/timer.el (with-timeout):
* lisp/emacs-lisp/lisp-mnt.el (lm-with-file):
* lisp/emacs-lisp/eieio.el (with-slots):
* lisp/emacs-lisp/easymenu.el (easy-menu-define):
* lisp/emacs-lisp/debug.el (debugger-env-macro):
* lisp/emacs-lisp/cl-compat.el (Multiple-value-bind, Multiple-value-setq)
(Multiple-value-call, Multiple-value-prog1):
* lisp/emacs-lisp/cl-seq.el (cl-parsing-keywords, cl-check-key)
(cl-check-test-nokey, cl-check-test, cl-check-match): Move indent and
edebug rule to definition.
* lisp/emacs-lisp/lisp-mode.el (save-selected-window)
(with-current-buffer, combine-after-change-calls)
(with-output-to-string, with-temp-file, with-temp-buffer)
(with-temp-message, with-syntax-table, read-if, eval-after-load)
(dolist, dotimes, when, unless):
* lisp/emacs-lisp/byte-run.el (inline): Remove indent rule, redundant.
2010-08-30 15:03:05 +02:00
|
|
|
|
(declare (indent 1) (debug t))
|
2003-03-29 02:57:19 +00:00
|
|
|
|
(let ((old-table (make-symbol "old-table"))
|
|
|
|
|
(old-buffer (make-symbol "old-buffer")))
|
|
|
|
|
`(let ((,old-table (category-table))
|
|
|
|
|
(,old-buffer (current-buffer)))
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
|
|
|
|
(set-category-table ,table)
|
|
|
|
|
,@body)
|
2006-11-24 18:43:58 +00:00
|
|
|
|
(with-current-buffer ,old-buffer
|
2003-03-29 02:57:19 +00:00
|
|
|
|
(set-category-table ,old-table))))))
|
1999-12-15 00:40:48 +00:00
|
|
|
|
|
2002-07-17 19:06:52 +00:00
|
|
|
|
(defun define-translation-hash-table (symbol table)
|
|
|
|
|
"Define SYMBOL as the name of the hash translation TABLE for use in CCL.
|
|
|
|
|
|
|
|
|
|
Analogous to `define-translation-table', but updates
|
|
|
|
|
`translation-hash-table-vector' and the table is for use in the CCL
|
|
|
|
|
`lookup-integer' and `lookup-character' functions."
|
|
|
|
|
(unless (and (symbolp symbol)
|
|
|
|
|
(hash-table-p table))
|
|
|
|
|
(error "Bad args to define-translation-hash-table"))
|
|
|
|
|
(let ((len (length translation-hash-table-vector))
|
|
|
|
|
(id 0)
|
|
|
|
|
done)
|
|
|
|
|
(put symbol 'translation-hash-table table)
|
|
|
|
|
(while (not done)
|
|
|
|
|
(if (>= id len)
|
|
|
|
|
(setq translation-hash-table-vector
|
|
|
|
|
(vconcat translation-hash-table-vector [nil])))
|
|
|
|
|
(let ((slot (aref translation-hash-table-vector id)))
|
|
|
|
|
(if (or (not slot)
|
|
|
|
|
(eq (car slot) symbol))
|
|
|
|
|
(progn
|
|
|
|
|
(aset translation-hash-table-vector id (cons symbol table))
|
|
|
|
|
(setq done t))
|
|
|
|
|
(setq id (1+ id)))))
|
|
|
|
|
(put symbol 'translation-hash-table-id id)
|
|
|
|
|
id))
|
|
|
|
|
|
1997-02-26 13:01:42 +00:00
|
|
|
|
;;; Initialize some variables.
|
|
|
|
|
|
|
|
|
|
(put 'use-default-ascent 'char-table-extra-slots 0)
|
|
|
|
|
(setq use-default-ascent (make-char-table 'use-default-ascent))
|
1997-08-10 04:07:03 +00:00
|
|
|
|
(put 'ignore-relative-composition 'char-table-extra-slots 0)
|
|
|
|
|
(setq ignore-relative-composition
|
|
|
|
|
(make-char-table 'ignore-relative-composition))
|
1997-02-26 13:01:42 +00:00
|
|
|
|
|
2002-07-03 22:37:38 +00:00
|
|
|
|
(make-obsolete 'set-char-table-default
|
2008-04-18 10:17:43 +00:00
|
|
|
|
"generic characters no longer exist." "23.1")
|
2002-05-21 21:14:03 +00:00
|
|
|
|
|
|
|
|
|
;;; Built-in auto-coding-functions:
|
|
|
|
|
|
|
|
|
|
(defun sgml-xml-auto-coding-function (size)
|
|
|
|
|
"Determine whether the buffer is XML, and if so, its encoding.
|
|
|
|
|
This function is intended to be added to `auto-coding-functions'."
|
2003-05-18 21:07:01 +00:00
|
|
|
|
(setq size (+ (point) size))
|
|
|
|
|
(when (re-search-forward "\\`[[:space:]\n]*<\\?xml" size t)
|
2002-05-21 21:14:03 +00:00
|
|
|
|
(let ((end (save-excursion
|
|
|
|
|
;; This is a hack.
|
2005-05-07 15:55:59 +00:00
|
|
|
|
(re-search-forward "[\"']\\s-*\\?>" size t))))
|
2002-05-21 21:14:03 +00:00
|
|
|
|
(when end
|
2005-05-07 15:55:59 +00:00
|
|
|
|
(if (re-search-forward "encoding=[\"']\\(.+?\\)[\"']" end t)
|
2002-06-08 20:58:59 +00:00
|
|
|
|
(let* ((match (match-string 1))
|
|
|
|
|
(sym (intern (downcase match))))
|
|
|
|
|
(if (coding-system-p sym)
|
|
|
|
|
sym
|
|
|
|
|
(message "Warning: unknown coding system \"%s\"" match)
|
|
|
|
|
nil))
|
2008-02-18 01:45:54 +00:00
|
|
|
|
;; Files without an encoding tag should be UTF-8. But users
|
|
|
|
|
;; may be naive about encodings, and have saved the file from
|
|
|
|
|
;; another editor that does not help them get the encoding right.
|
|
|
|
|
;; Detect the encoding and warn the user if it is detected as
|
|
|
|
|
;; something other than UTF-8.
|
|
|
|
|
(let ((detected
|
|
|
|
|
(with-coding-priority '(utf-8)
|
|
|
|
|
(coding-system-base
|
|
|
|
|
(detect-coding-region (point-min) size t)))))
|
|
|
|
|
;; Pure ASCII always comes back as undecided.
|
|
|
|
|
(if (memq detected '(utf-8 undecided))
|
|
|
|
|
'utf-8
|
|
|
|
|
(warn "File contents detected as %s.
|
|
|
|
|
Consider adding an encoding attribute to the xml declaration,
|
|
|
|
|
or saving as utf-8, as mandated by the xml specification." detected)
|
|
|
|
|
detected)))))))
|
2002-05-21 21:14:03 +00:00
|
|
|
|
|
2002-06-08 20:58:59 +00:00
|
|
|
|
(defun sgml-html-meta-auto-coding-function (size)
|
|
|
|
|
"If the buffer has an HTML meta tag, use it to determine encoding.
|
|
|
|
|
This function is intended to be added to `auto-coding-functions'."
|
2007-09-21 03:19:43 +00:00
|
|
|
|
(let ((case-fold-search t))
|
|
|
|
|
(setq size (min (+ (point) size)
|
|
|
|
|
(save-excursion
|
|
|
|
|
;; Limit the search by the end of the HTML header.
|
2008-02-12 21:21:02 +00:00
|
|
|
|
(or (search-forward "</head>" (+ (point) size) t)
|
2007-09-21 03:19:43 +00:00
|
|
|
|
;; In case of no header, search only 10 lines.
|
|
|
|
|
(forward-line 10))
|
|
|
|
|
(point))))
|
|
|
|
|
;; Make sure that the buffer really contains an HTML document, by
|
|
|
|
|
;; checking that it starts with a doctype or a <HTML> start tag
|
|
|
|
|
;; (allowing for whitespace at bob). Note: 'DOCTYPE NETSCAPE' is
|
|
|
|
|
;; useful for Mozilla bookmark files.
|
|
|
|
|
(when (and (re-search-forward "\\`[[:space:]\n]*\\(<!doctype[[:space:]\n]+\\(html\\|netscape\\)\\|<html\\)" size t)
|
|
|
|
|
(re-search-forward "<meta\\s-+http-equiv=[\"']?content-type[\"']?\\s-+content=[\"']text/\\sw+;\\s-*charset=\\(.+?\\)[\"']" size t))
|
|
|
|
|
(let* ((match (match-string 1))
|
|
|
|
|
(sym (intern (downcase match))))
|
|
|
|
|
(if (coding-system-p sym)
|
|
|
|
|
sym
|
|
|
|
|
(message "Warning: unknown coding system \"%s\"" match)
|
|
|
|
|
nil)))))
|
2002-07-05 23:16:08 +00:00
|
|
|
|
|
2008-02-18 01:45:54 +00:00
|
|
|
|
(defun xml-find-file-coding-system (args)
|
|
|
|
|
"Determine the coding system of an XML file without a declaration.
|
|
|
|
|
Strictly speaking, the file should be utf-8, but mistakes are
|
|
|
|
|
made, and there are genuine cases where XML fragments are saved,
|
|
|
|
|
with the encoding properly specified in a master document, or
|
|
|
|
|
added by processing software."
|
|
|
|
|
(if (eq (car args) 'insert-file-contents)
|
|
|
|
|
(let ((detected
|
|
|
|
|
(with-coding-priority '(utf-8)
|
|
|
|
|
(coding-system-base
|
|
|
|
|
(detect-coding-region (point-min) (point-max) t)))))
|
|
|
|
|
;; Pure ASCII always comes back as undecided.
|
2008-02-18 02:41:11 +00:00
|
|
|
|
(cond
|
|
|
|
|
((memq detected '(utf-8 undecided))
|
|
|
|
|
'utf-8)
|
|
|
|
|
((eq detected 'utf-16le-with-signature) 'utf-16le-with-signature)
|
|
|
|
|
((eq detected 'utf-16be-with-signature) 'utf-16be-with-signature)
|
|
|
|
|
(t
|
2008-02-18 01:45:54 +00:00
|
|
|
|
(warn "File contents detected as %s.
|
|
|
|
|
Consider adding an xml declaration with the encoding specified,
|
|
|
|
|
or saving as utf-8, as mandated by the xml specification." detected)
|
2008-02-18 02:41:11 +00:00
|
|
|
|
detected)))
|
2008-02-18 01:45:54 +00:00
|
|
|
|
;; Don't interfere with the user's wishes for saving the buffer.
|
|
|
|
|
;; We did what we could when the buffer was created to ensure the
|
|
|
|
|
;; correct encoding was used, or the user was warned, so any
|
|
|
|
|
;; non-conformity here is deliberate on the part of the user.
|
|
|
|
|
'undecided))
|
|
|
|
|
|
1997-02-26 13:01:42 +00:00
|
|
|
|
;;;
|
1997-02-20 07:02:49 +00:00
|
|
|
|
(provide 'mule)
|
|
|
|
|
|
|
|
|
|
;;; mule.el ends here
|