rearrangement.
[elisp/apel.git] / emu-mule.el
index 2f0b476..9821aec 100644 (file)
 (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.
@@ -320,11 +342,36 @@ 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)
 
+(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)
+    ))
+
 (defmacro char-next-index (char index)
   "Return index of character succeeding CHAR whose index is INDEX."
   (` (+ (, index) (char-bytes (, char)))))