(point-at-bol): New function.
[elisp/apel.git] / emu-20.el
index 50d55d0..b750e41 100644 (file)
--- a/emu-20.el
+++ b/emu-20.el
@@ -33,7 +33,7 @@
 (eval-when-compile (require 'wid-edit))
 
 
-;;; @ binary access
+;;; @ without code-conversion
 ;;;
 
 (defmacro as-binary-process (&rest body)
                                     &optional append visit lockname)
   "Like `write-region', q.v., but don't encode."
   (let ((coding-system-for-write 'binary))
-    (write-region start end filename append visit lockname)
-    ))
+    (write-region start end filename append visit lockname)))
+
+(defun insert-file-contents-as-binary (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.
+
+Namely this function ensures that only format decoding and character
+code conversion will not take place."
+  (let ((coding-system-for-read 'binary)
+       format-alist)
+    ;; Returns list of absolute file name and length of data inserted.
+    (insert-file-contents filename visit beg end replace)))
+
+(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."
+  (let ((coding-system-for-read 'raw-text)
+       format-alist)
+    ;; Returns list of absolute file name and length of data inserted.
+    (insert-file-contents filename visit beg end replace)))
+
+(defun write-region-as-raw-text-CRLF (start end filename
+                                           &optional append visit lockname)
+  "Like `write-region', q.v., but write as network representation."
+  (let ((coding-system-for-write 'raw-text-dos))
+    (write-region start end filename append visit lockname)))
 
 
 ;;; @@ Mule emulating aliases
@@ -77,6 +107,8 @@ This constant is defined to emulate old MULE anything older than MULE
             (gb2312        . cn-gb-2312)
             (iso-2022-jp-2 . iso-2022-7bit-ss2)
             (x-ctext       . ctext)
+            (unknown       . undecided)
+            (x-unknown     . undecided)
             ))
          dest)
       (while rest
@@ -95,8 +127,8 @@ MIME CHARSET and CODING-SYSTEM must be symbol."
 (defsubst mime-charset-to-coding-system (charset &optional lbt)
   "Return coding-system corresponding with CHARSET.
 CHARSET is a symbol whose name is MIME charset.
-If optional argument LBT (`unix', `dos' or `mac') is specified, it is
-used as line break code type of coding-system."
+If optional argument LBT (`CRLF', `LF', `CR', `unix', `dos' or `mac')
+is specified, it is used as line break code type of coding-system."
   (if (stringp charset)
       (setq charset (intern (downcase charset)))
     )
@@ -105,10 +137,15 @@ used as line break code type of coding-system."
        (setq charset (cdr ret))
       ))
   (if lbt
-      (setq charset (intern (format "%s-%s" charset lbt)))
+      (setq charset (intern (format "%s-%s" charset
+                                   (cond ((eq lbt 'CRLF) 'dos)
+                                         ((eq lbt 'LF) 'unix)
+                                         ((eq lbt 'CR) 'mac)
+                                         (t lbt)))))
     )
   (if (find-coding-system charset)
-      charset))
+      charset
+    ))
 
 (defsubst mime-charset-list ()
   "Return a list of all existing MIME-charset."
@@ -133,8 +170,7 @@ used as line break code type of coding-system."
    (completing-read (format "%s (default %s) " prompt value)
                    (mapcar (function
                             (lambda (sym)
-                              (list (symbol-name sym))
-                              ))
+                              (list (symbol-name sym))))
                            (mime-charset-list)))))
 
 (defun widget-mime-charset-action (widget &optional event)
@@ -166,8 +202,7 @@ It must be symbol."
   (let ((coding-system-for-write
         (or (mime-charset-to-coding-system charset)
             'binary)))
-    (write-region start end filename append visit lockname)
-    ))
+    (write-region start end filename append visit lockname)))
 
 
 ;;; @ end