rearrangement.
[elisp/apel.git] / emu-mule.el
index c726ab9..9821aec 100644 (file)
@@ -29,7 +29,7 @@
 ;;;
 
 (cond (running-emacs-19
-       (require 'emu-19)
+       (require 'emu-e19)
        
        ;; Suggested by SASAKI Osamu <osamu@shuugr.bekkoame.or.jp>
        ;; (cf. [os2-emacs-ja:78])
 (defalias 'charset-columns     'char-width)
 (defalias 'charset-direction   'char-direction)
 
+(defun charset-chars (charset)
+  "Return the number of characters per dimension of CHARSET."
+  (if (= (logand (nth 2 (character-set charset)) 1) 1)
+      96
+    94))
+
 
 ;;; @ coding system
 ;;;
@@ -150,13 +156,29 @@ automatic uncompression, etc.
 Namely this function ensures that only format decoding and character
 code conversion will not take place."
   (let (mc-flag
-       (file-coding-system *noconv*))
+       (file-coding-system-for-read *noconv*))
     (insert-file-contents filename visit beg end replace)
     ))
 
 (defalias 'insert-binary-file-contents 'insert-file-contents-as-binary)
 (make-obsolete 'insert-binary-file-contents 'insert-file-contents-as-binary)
 
+(defun insert-file-contents-as-raw-text (filename
+                                        &optional visit beg end replace)
+  "Like `insert-file-contents', q.v., but don't code and format conversion.
+Like `insert-file-contents-literary', but it allows find-file-hooks,
+automatic uncompression, etc.
+Like `insert-file-contents-as-binary', but it converts line-break
+code."
+  (save-excursion
+    (save-restriction
+      (narrow-to-region (point)(point))
+      (insert-file-contents-as-binary filename visit beg end replace)
+      (goto-char (point-min))
+      (while (re-search-forward "\r$" nil t)
+       (replace-match "")
+       ))))
+
 (defun insert-binary-file-contents-literally (filename
                                              &optional visit beg end replace)
   "Like `insert-file-contents-literally', q.v., but don't code conversion.
@@ -220,6 +242,14 @@ find-file-hooks, etc.
        (decode-coding-string string cs)
       string)))
 
+(defun write-region-as-mime-charset (charset start end filename)
+  "Like `write-region', q.v., but code-convert by MIME CHARSET."
+  (let ((file-coding-system
+        (or (mime-charset-to-coding-system charset)
+            *noconv*)))
+    (write-region start end filename append visit)
+    ))
+
 
 ;;; @@ to coding-system
 ;;;
@@ -312,14 +342,46 @@ It must be symbol.")
    (cons lc-ascii (find-charset-region start end))))
 
 
+;;; @ buffer representation
+;;;
+
+(defsubst-maybe set-buffer-multibyte (flag)
+  "Set the multibyte flag of the current buffer to FLAG.
+If FLAG is t, this makes the buffer a multibyte buffer.
+If FLAG is nil, this makes the buffer a single-byte buffer.
+The buffer contents remain unchanged as a sequence of bytes
+but the contents viewed as characters do change.
+\[Emacs 20.3 emulating function]"
+  (setq mc-flag flag)
+  )
+
+
 ;;; @ character
 ;;;
 
 (defalias 'char-charset 'char-leading-char)
 
-(defalias 'char-length 'char-bytes)
+(defun split-char (character)
+  "Return list of charset and one or two position-codes of CHARACTER."
+  (let ((p (1- (char-bytes character)))
+       dest)
+    (while (>= p 1)
+      (setq dest (cons (- (char-component character p) 128) dest)
+           p (1- p))
+      )
+    (cons (char-charset character) dest)
+    ))
 
-(defalias 'char-columns 'char-width)
+(defmacro char-next-index (char index)
+  "Return index of character succeeding CHAR whose index is INDEX."
+  (` (+ (, index) (char-bytes (, char)))))
+
+;;; @@ obsoleted aliases
+;;;
+;;; You should not use them.
+
+(defalias 'char-length 'char-bytes)
+;;(defalias 'char-columns 'char-width)
 
 
 ;;; @ string
@@ -363,6 +425,8 @@ Optional non-nil arg START-COLUMN specifies the starting column.
 ;;;
   )
 
+(defalias 'looking-at-as-unibyte 'looking-at)
+
 
 ;;; @ regulation
 ;;;