aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa1997-06-10 00:56:15 +0000
committerKenichi Handa1997-06-10 00:56:15 +0000
commit8057896bd0cebe95f318652991708182f8a6c53c (patch)
tree68ddd822e0edff934850bce420865165945c2d48
parent54e42e2dbd280f86d0366996da23a7bb83b04849 (diff)
downloademacs-8057896bd0cebe95f318652991708182f8a6c53c.tar.gz
emacs-8057896bd0cebe95f318652991708182f8a6c53c.zip
Delete declaration for buffer-file-coding-system. It
is done in buffer.c now. In the comment, change coding-system to coding system. The name coding-vector is changed to coding-spec. (coding-vector-type, coding-vector-mnemonic, coding-vector-docstring, coding-vector-flags): Deleted. (coding-system-spec-ref): New function. (coding-system-type, coding-system-mnemonic, coding-system-flags): Use coding-system-spec-ref. (coding-system-doc-string): Renamed from coding-system-docstring. (coding-system-eol-type): Renamed from coding-system-eoltype. (coding-system-eol-type-mnemonic): Moved to mule-util.el. (coding-system-post-read-conversion): Likewise. (coding-system-pre-write-conversion): Likewise. (default-process-coding-system): Deleted. Now declared in buffer.c. (make-subsidiary-coding-system): New function. (make-coding-system): Check arguments more strictly. Do not make -unix, -dos, -mac variants for TYPE 4. (define-coding-system-alias): Call make-subsidiary-coding-system. (set-buffer-file-coding-system): Adjusted for the function name changes. (find-new-buffer-file-coding-system): Likewise. (default-process-coding-system): Deleted. Now defined in coding.c.
-rw-r--r--lisp/international/mule.el217
1 files changed, 93 insertions, 124 deletions
diff --git a/lisp/international/mule.el b/lisp/international/mule.el
index fa56bd84b52..44e651112ed 100644
--- a/lisp/international/mule.el
+++ b/lisp/international/mule.el
@@ -211,29 +211,37 @@ See also the documentation of make-char."
211 (and (or (= (nth 1 l) 0) (eq (nth 2 l) 0)) 211 (and (or (= (nth 1 l) 0) (eq (nth 2 l) 0))
212 (not (eq (car l) 'composition))))) 212 (not (eq (car l) 'composition)))))
213 213
214;; Coding-system staffs 214;; Coding system staffs
215 215
216;; Coding-system object is a symbol that has the property 216;; Coding system is a symbol that has the property `coding-system'.
217;; `coding-system' and `eol-type'.
218;; 217;;
219;; The value of the property `coding-system' is a coding-vector of the 218;; The value of the property `coding-system' is a vector of the
220;; format: [TYPE MNEMONIC DOCSTRING NOT-USED-NOW FLAGS]. 219;; following format:
221;; See comments in src/coding.c for more detail. The property value 220;; [TYPE MNEMONIC DOC-STRING NOT-USED-NOW FLAGS]
222;; may be another coding-system, in which case, the coding-vector 221;; We call this vector as coding-spec. See comments in src/coding.c
223;; should be taken from that coding-system. 222;; for more detail. The property value may be another coding system,
224;; 223;; in which case, the coding-spec should be taken from that
225;; The value of the property `eol-type' is integer 0..2 or a vector of 224;; coding-system. The 4th element NOT-USED-NOW is kept just for
226;; length 3. The integer value 0, 1, and 2 indicate the format of 225;; backward compatibility with old version of Mule.
226
227(defconst coding-spec-type-idx 0)
228(defconst coding-spec-mnemonic-idx 1)
229(defconst coding-spec-doc-string-idx 2)
230(defconst coding-spec-flags-idx 4)
231
232;; Coding system may have proerpty `eol-type'. The value of the
233;; property `eol-type' is integer 0..2 or a vector of three coding
234;; systems. The integer value 0, 1, and 2 indicate the format of
227;; end-of-line LF, CRLF, and CR respectively. The vector value 235;; end-of-line LF, CRLF, and CR respectively. The vector value
228;; indicates that the format of end-of-line should be detected 236;; indicates that the format of end-of-line should be detected
229;; automatically. Nth element of the vector is the subsidiary 237;; automatically. Nth element of the vector is the subsidiary coding
230;; coding-system whose `eol-type' property is integer value. 238;; system whose `eol-type' property is N.
231;; 239;;
232;; Coding-system may also have properties `post-read-conversion' and 240;; Coding system may also have properties `post-read-conversion' and
233;; `pre-write-conversion and the values are functions. 241;; `pre-write-conversion. Values of these properties are functions.
234;; 242;;
235;; The function in `post-read-conversion' is called after some text is 243;; The function in `post-read-conversion' is called after some text is
236;; inserted and decoded along the coding-system and before any 244;; inserted and decoded along the coding system and before any
237;; functions in `after-insert-functions' are called. The arguments to 245;; functions in `after-insert-functions' are called. The arguments to
238;; this function is the same as those of a function in 246;; this function is the same as those of a function in
239;; `after-insert-functions', i.e. LENGTH of a text while putting point 247;; `after-insert-functions', i.e. LENGTH of a text while putting point
@@ -242,76 +250,59 @@ See also the documentation of make-char."
242;; The function in `pre-write-conversion' is called after all 250;; The function in `pre-write-conversion' is called after all
243;; functions in `write-region-annotate-functions' and 251;; functions in `write-region-annotate-functions' and
244;; `buffer-file-format' are called, and before the text is encoded by 252;; `buffer-file-format' are called, and before the text is encoded by
245;; the coding-system. The arguments to this function is the same as 253;; the coding system. The arguments to this function is the same as
246;; those of a function in `write-region-annotate-functions', i.e. FROM 254;; those of a function in `write-region-annotate-functions', i.e. FROM
247;; and TO specifying region of a text. 255;; and TO specifying region of a text.
248 256
249(defsubst coding-vector-type (vec) (aref vec 0)) 257;; Return Nth element of coding-spec of CODING-SYSTEM.
250(defsubst coding-vector-mnemonic (vec) (aref vec 1)) 258(defun coding-system-spec-ref (coding-system n)
251(defsubst coding-vector-docstring (vec) (aref vec 2)) 259 (check-coding-system coding-system)
252(defsubst coding-vector-flags (vec) (aref vec 4)) 260 (let ((vec (coding-system-spec coding-system)))
261 (and vec (aref vec n))))
253 262
254;; Return type of CODING-SYSTEM.
255(defun coding-system-type (coding-system) 263(defun coding-system-type (coding-system)
256 (check-coding-system coding-system) 264 "Return TYPE element in coding-spec of CODING-SYSTEM."
257 (let ((vec (coding-system-vector coding-system))) 265 (coding-system-spec-ref coding-system coding-spec-type-idx))
258 (if vec (coding-vector-type vec))))
259 266
260;; Return mnemonic character of CODING-SYSTEM.
261(defun coding-system-mnemonic (coding-system) 267(defun coding-system-mnemonic (coding-system)
262 (check-coding-system coding-system) 268 "Return MNEMONIC element in coding-spec of CODING-SYSTEM."
263 (let ((vec (coding-system-vector coding-system))) 269 (or (coding-system-spec-ref coding-system coding-spec-mnemonic-idx)
264 (if vec (coding-vector-mnemonic vec) 270 ?-))
265 ?-)))
266 271
267;; Return docstring of CODING-SYSTEM. 272(defun coding-system-doc-string (coding-system)
268(defun coding-system-docstring (coding-system) 273 "Return DOC-STRING element in coding-spec of CODING-SYSTEM."
269 (check-coding-system coding-system) 274 (coding-system-spec-ref coding-system coding-spec-doc-string-idx))
270 (let ((vec (coding-system-vector coding-system)))
271 (if vec (coding-vector-docstring vec))))
272 275
273;; Return flags of CODING-SYSTEM.
274(defun coding-system-flags (coding-system) 276(defun coding-system-flags (coding-system)
275 (check-coding-system coding-system) 277 "Return FLAGS element in coding-spec of CODING-SYSTEM."
276 (let ((vec (coding-system-vector coding-system))) 278 (coding-system-spec-ref coding-system coding-spec-flags-idx))
277 (if vec (coding-vector-flags vec))))
278 279
279;; Return eol-type of CODING-SYSTEM. 280(defun coding-system-eol-type (coding-system)
280(defun coding-system-eoltype (coding-system) 281 "Return eol-type property of CODING-SYSTEM."
281 (check-coding-system coding-system) 282 (check-coding-system coding-system)
282 (and coding-system 283 (and coding-system
283 (or (get coding-system 'eol-type) 284 (or (get coding-system 'eol-type)
284 (coding-system-eoltype (get coding-system 'coding-system))))) 285 (coding-system-eol-type (get coding-system 'coding-system)))))
285
286;; Return mnemonic character of eol-type of CODING-SYSTEM.
287(defun coding-system-eoltype-mnemonic (coding-system)
288 (let ((eol-type (coding-system-eoltype coding-system)))
289 (cond ((vectorp eol-type) eol-mnemonic-undecided)
290 ((eq eol-type 0) eol-mnemonic-unix)
291 ((eq eol-type 1) eol-mnemonic-unix)
292 ((eq eol-type 2) eol-mnemonic-unix)
293 (t ?-))))
294
295;; Return function for post-read-conversion of CODING-SYSTEM.
296(defun coding-system-post-read-conversion (coding-system)
297 (and coding-system
298 (symbolp coding-system)
299 (or (get coding-system 'post-read-conversion)
300 (coding-system-post-read-conversion
301 (get coding-system 'coding-system)))))
302 286
303;; Return function for pre-write-conversion of CODING-SYSTEM. 287;; Make subsidiear coding systems of CODING-SYSTEM whose base is BASE.
304(defun coding-system-pre-write-conversion (coding-system) 288(defun make-subsidiary-coding-system (coding-system base)
305 (and coding-system 289 (let ((subsidiaries (vector (intern (format "%s-unix" coding-system))
306 (symbolp coding-system) 290 (intern (format "%s-dos" coding-system))
307 (or (get coding-system 'pre-write-conversion) 291 (intern (format "%s-mac" coding-system))))
308 (coding-system-pre-write-conversion 292 (i 0))
309 (get coding-system 'coding-system))))) 293 (while (< i 3)
294 (put (aref subsidiaries i) 'coding-system base)
295 (put (aref subsidiaries i) 'eol-type i)
296 (put (aref subsidiaries i) 'eol-variant t)
297 (setq i (1+ i)))
298 subsidiaries))
310 299
311(defun make-coding-system (coding-system type mnemonic docstring 300(defun make-coding-system (coding-system type mnemonic doc-string
312 &optional flags) 301 &optional flags)
313 "Define a new CODING-SYSTEM (symbol). 302 "Define a new CODING-SYSTEM (symbol).
314Remaining arguments are TYPE, MNEMONIC, DOCSTRING, and FLAGS (optional). 303Remaining arguments are TYPE, MNEMONIC, DOC-STRING, and FLAGS (optional) which
304construct a coding-spec of CODING-SYSTEM in the following format:
305 [TYPE MNEMONIC DOC-STRING nil FLAGS]
315TYPE is an integer value indicating the type of coding-system as follows: 306TYPE is an integer value indicating the type of coding-system as follows:
316 0: Emacs internal format, 307 0: Emacs internal format,
317 1: Shift-JIS (or MS-Kanji) used mainly on Japanese PC, 308 1: Shift-JIS (or MS-Kanji) used mainly on Japanese PC,
@@ -319,7 +310,7 @@ TYPE is an integer value indicating the type of coding-system as follows:
319 3: Big5 used mainly on Chinese PC, 310 3: Big5 used mainly on Chinese PC,
320 4: private, CCL programs provide encoding/decoding algorithm. 311 4: private, CCL programs provide encoding/decoding algorithm.
321MNEMONIC is a character to be displayed on mode line for the coding-system. 312MNEMONIC is a character to be displayed on mode line for the coding-system.
322DOCSTRING is a documentation string for the coding-system. 313DOC-STRING is a documentation string for the coding-system.
323FLAGS specifies more precise information of each TYPE. 314FLAGS specifies more precise information of each TYPE.
324 If TYPE is 2 (ISO-2022), FLAGS should be a list of: 315 If TYPE is 2 (ISO-2022), FLAGS should be a list of:
325 CHARSET0, CHARSET1, CHARSET2, CHARSET3, SHORT-FORM, 316 CHARSET0, CHARSET1, CHARSET2, CHARSET3, SHORT-FORM,
@@ -348,13 +339,15 @@ FLAGS specifies more precise information of each TYPE.
348 for encoding and decoding. See the documentation of CCL for more detail." 339 for encoding and decoding. See the documentation of CCL for more detail."
349 340
350 ;; At first, set a value of `coding-system' property. 341 ;; At first, set a value of `coding-system' property.
351 (let ((coding-vector (make-vector 5 nil))) 342 (let ((coding-spec (make-vector 5 nil)))
352 (aset coding-vector 0 type) 343 (if (or (not (integerp type)) (< type 0) (> type 4))
353 (aset coding-vector 1 344 (error "TYPE argument must be 0..4"))
354 ;; MNEMONIC must be a printable character. 345 (if (or (not (integerp mnemonic)) (<= mnemonic ? ) (> mnemonic 127))
355 (if (and (> mnemonic ? ) (< mnemonic 127)) mnemonic ? )) 346 (error "MNEMONIC arguemnt must be a printable character."))
356 (aset coding-vector 2 (if (stringp docstring) docstring "")) 347 (aset coding-spec 0 type)
357 (aset coding-vector 3 nil) ; obsolete element 348 (aset coding-spec 1 mnemonic)
349 (aset coding-spec 2 (if (stringp doc-string) doc-string ""))
350 (aset coding-spec 3 nil) ; obsolete element
358 (cond ((eq type 2) ; ISO2022 351 (cond ((eq type 2) ; ISO2022
359 (let ((i 0) 352 (let ((i 0)
360 (vec (make-vector 32 nil))) 353 (vec (make-vector 32 nil)))
@@ -376,51 +369,30 @@ FLAGS specifies more precise information of each TYPE.
376 (while (and (< i 32) flags) 369 (while (and (< i 32) flags)
377 (aset vec i (car flags)) 370 (aset vec i (car flags))
378 (setq flags (cdr flags) i (1+ i))) 371 (setq flags (cdr flags) i (1+ i)))
379 (aset coding-vector 4 vec))) 372 (aset coding-spec 4 vec)))
380 ((eq type 4) ; private 373 ((eq type 4) ; private
381 (if (and (consp flags) 374 (if (and (consp flags)
382 (vectorp (car flags)) 375 (vectorp (car flags))
383 (vectorp (cdr flags))) 376 (vectorp (cdr flags)))
384 (aset coding-vector 4 flags) 377 (aset coding-spec 4 flags)
385 (error "Invalid FLAGS argument for TYPE 4 (CCL)"))) 378 (error "Invalid FLAGS argument for TYPE 4 (CCL)")))
386 (t (aset coding-vector 4 flags))) 379 (t (aset coding-spec 4 flags)))
387 (put coding-system 'coding-system coding-vector)) 380 (put coding-system 'coding-system coding-spec))
388 381
389 ;; Next, set a value of `eol-type' property. The value is a vector 382 ;; Next, set a value of `eol-type' property. The value is a vector
390 ;; of subsidiary coding-systems, each corresponds to a coding-system 383 ;; of subsidiary coding systems, each corresponds to a coding-system
391 ;; for the detected end-of-line format. 384 ;; for the detected end-of-line format.
392 (let ((codings (vector (intern (format "%s-unix" coding-system)) 385 (put coding-system 'eol-type
393 (intern (format "%s-dos" coding-system)) 386 (if (<= type 3)
394 (intern (format "%s-mac" coding-system)))) 387 (make-subsidiary-coding-system coding-system coding-system)
395 (i 0)) 388 0)))
396 (while (< i 3) 389
397 (put (aref codings i) 'coding-system coding-system) 390(defun define-coding-system-alias (coding-system alias)
398 (put (aref codings i) 'eol-type i) 391 "Define ALIAS as an alias coding system of CODING-SYSTEM."
399 (setq i (1+ i))) 392 (check-coding-system coding-system)
400 (put coding-system 'eol-type codings)) 393 (put alias 'coding-system coding-system)
401 ) 394 (if (vectorp (coding-system-eol-type coding-system))
402 395 (make-subsidiary-coding-system alias coding-system)))
403(defun define-coding-system-alias (symbol new-symbol)
404 "Define NEW-SYMBOL as the same coding system as SYMBOL."
405 (check-coding-system symbol)
406 (put new-symbol 'coding-system symbol)
407 (let ((eol-type (coding-system-eoltype symbol)))
408 (if (vectorp eol-type)
409 (let* ((name (symbol-name new-symbol))
410 (new-eol-type (vector (intern (concat name "-unix"))
411 (intern (concat name "-dos"))
412 (intern (concat name "-mac")))))
413 (define-coding-system-alias (aref eol-type 0) (aref new-eol-type 0))
414 (define-coding-system-alias (aref eol-type 1) (aref new-eol-type 1))
415 (define-coding-system-alias (aref eol-type 2) (aref new-eol-type 2))
416 (setq eol-type new-eol-type)))
417 (put new-symbol 'eol-type eol-type)))
418
419(defvar buffer-file-coding-system nil
420 "Coding-system of the file which the current-buffer is visiting.")
421(make-variable-buffer-local 'buffer-file-coding-system)
422;; This value should not be reset by changing major mode.
423(put 'buffer-file-coding-system 'permanent-local t)
424 396
425(defun set-buffer-file-coding-system (coding-system &optional force) 397(defun set-buffer-file-coding-system (coding-system &optional force)
426 "Set buffer-file-coding-system of the current buffer to CODING-SYSTEM. 398 "Set buffer-file-coding-system of the current buffer to CODING-SYSTEM.
@@ -432,8 +404,8 @@ Optional prefix argument FORCE non-nil means CODING-SYSTEM is set
432 (interactive "zBuffer-file-coding-system: \nP") 404 (interactive "zBuffer-file-coding-system: \nP")
433 (check-coding-system coding-system) 405 (check-coding-system coding-system)
434 (if (null force) 406 (if (null force)
435 (let ((x (coding-system-eoltype buffer-file-coding-system)) 407 (let ((x (coding-system-eol-type buffer-file-coding-system))
436 (y (coding-system-eoltype coding-system))) 408 (y (coding-system-eol-type coding-system)))
437 (if (and (numberp x) (>= x 0) (<= x 2) (vectorp y)) 409 (if (and (numberp x) (>= x 0) (<= x 2) (vectorp y))
438 (setq coding-system (aref y x))))) 410 (setq coding-system (aref y x)))))
439 (setq buffer-file-coding-system coding-system) 411 (setq buffer-file-coding-system coding-system)
@@ -471,9 +443,6 @@ ENCODING is to be used to encode output to the process."
471 (set-process-coding-system proc decoding encoding))) 443 (set-process-coding-system proc decoding encoding)))
472 (force-mode-line-update)) 444 (force-mode-line-update))
473 445
474(defvar default-process-coding-system (cons nil nil)
475 "Cons of default values used to read from and write to process.")
476
477(defun set-coding-priority (arg) 446(defun set-coding-priority (arg)
478 "Set priority of coding-category according to LIST. 447 "Set priority of coding-category according to LIST.
479LIST is a list of coding-categories ordered by priority." 448LIST is a list of coding-categories ordered by priority."
@@ -512,7 +481,7 @@ LIST is a list of coding-categories ordered by priority."
512 (cons 'after-insert-file-set-buffer-file-coding-system 481 (cons 'after-insert-file-set-buffer-file-coding-system
513 after-insert-file-functions)) 482 after-insert-file-functions))
514 483
515;; The coding-vector and eol-type of coding-system returned is decided 484;; The coding-spec and eol-type of coding-system returned is decided
516;; independently in the following order. 485;; independently in the following order.
517;; 1. That of buffer-file-coding-system locally bound. 486;; 1. That of buffer-file-coding-system locally bound.
518;; 2. That of CODING. 487;; 2. That of CODING.
@@ -534,7 +503,7 @@ Return nil if there's no need of setting new buffer-file-coding-system."
534 (if (local-variable-p 'buffer-file-coding-system) 503 (if (local-variable-p 'buffer-file-coding-system)
535 ;; Something already set locally. 504 ;; Something already set locally.
536 (progn 505 (progn
537 (setq local-eol (coding-system-eoltype buffer-file-coding-system)) 506 (setq local-eol (coding-system-eol-type buffer-file-coding-system))
538 (if (null (numberp local-eol)) 507 (if (null (numberp local-eol))
539 ;; But eol-type is not yet set. 508 ;; But eol-type is not yet set.
540 (setq local-eol nil)) 509 (setq local-eol nil))
@@ -551,7 +520,7 @@ Return nil if there's no need of setting new buffer-file-coding-system."
551 ;; had better not change it. 520 ;; had better not change it.
552 nil 521 nil
553 522
554 (setq found-eol (coding-system-eoltype coding)) 523 (setq found-eol (coding-system-eol-type coding))
555 (if (null (numberp found-eol)) 524 (if (null (numberp found-eol))
556 ;; But eol-type is not found. 525 ;; But eol-type is not found.
557 (setq found-eol nil)) 526 (setq found-eol nil))
@@ -564,9 +533,9 @@ Return nil if there's no need of setting new buffer-file-coding-system."
564 (setq new-coding (or local-coding coding)) 533 (setq new-coding (or local-coding coding))
565 (setq new-eol (or local-eol found-eol)) 534 (setq new-eol (or local-eol found-eol))
566 (if (and (numberp new-eol) 535 (if (and (numberp new-eol)
567 (vectorp (coding-system-eoltype new-coding))) 536 (vectorp (coding-system-eol-type new-coding)))
568 (setq new-coding 537 (setq new-coding
569 (aref (coding-system-eoltype new-coding) new-eol))) 538 (aref (coding-system-eol-type new-coding) new-eol)))
570 new-coding)))) 539 new-coding))))
571 540
572(defun make-unification-table (&rest args) 541(defun make-unification-table (&rest args)