(point-at-bol): New function.
[elisp/apel.git] / emu-mule.el
index f6642ab..59cc665 100644 (file)
@@ -28,9 +28,9 @@
 ;;; @ version specific features
 ;;;
 
+(require 'poe)
+
 (cond (running-emacs-19
-       (require 'emu-e19)
-       
        ;; Suggested by SASAKI Osamu <osamu@shuugr.bekkoame.or.jp>
        ;; (cf. [os2-emacs-ja:78])
        (defun fontset-pixel-size (fontset)
@@ -49,7 +49,6 @@
               ))))
        )
       (running-emacs-18
-       (require 'emu-18)
        (defun make-overlay (beg end &optional buffer type))
        (defun overlay-put (overlay prop value))
        ))
@@ -245,10 +244,21 @@ find-file-hooks, etc.
 
 (defun decode-mime-charset-region (start end charset &optional lbt)
   "Decode the text between START and END as MIME CHARSET."
-  (let ((cs (mime-charset-to-coding-system charset lbt)))
+  (let ((cs (mime-charset-to-coding-system charset lbt))
+       newline)
     (if cs
        (code-convert start end cs *internal*)
-      )))
+      (if (and lbt (setq cs (mime-charset-to-coding-system charset)))
+         (progn
+           (if (setq newline (cdr (assq lbt '((CRLF . "\r\n") (CR . "\r")))))
+               (save-excursion
+                 (save-restriction
+                   (narrow-to-region start end)
+                   (goto-char (point-min))
+                   (while (search-forward newline nil t)
+                     (replace-match "\n")))
+                 (code-convert (point-min) (point-max) cs *internal*))
+             (code-convert start end cs *internal*)))))))
 
 (defun encode-mime-charset-string (string charset)
   "Encode the STRING as MIME CHARSET."
@@ -259,10 +269,22 @@ find-file-hooks, etc.
 
 (defun decode-mime-charset-string (string charset &optional lbt)
   "Decode the STRING which is encoded in MIME CHARSET."
-  (let ((cs (mime-charset-to-coding-system charset lbt)))
+  (let ((cs (mime-charset-to-coding-system charset lbt))
+       newline)
     (if cs
        (decode-coding-string string cs)
-      string)))
+      (if (and lbt (setq cs (mime-charset-to-coding-system charset)))
+         (progn
+           (if (setq newline (cdr (assq lbt '((CRLF . "\r\n") (CR . "\r")))))
+               (with-temp-buffer
+                (insert string)
+                (goto-char (point-min))
+                (while (search-forward newline nil t)
+                  (replace-match "\n"))
+                (code-convert (point-min) (point-max) cs *internal*)
+                (buffer-string))
+             (decode-coding-string string cs)))
+       string))))
 
 (cond
  (running-emacs-19_29-or-later
@@ -290,6 +312,8 @@ find-file-hooks, etc.
 ;;; @@ to coding-system
 ;;;
 
+(require 'cyrillic)
+
 (defvar mime-charset-coding-system-alist
   '((iso-8859-1      . *ctext*)
     (x-ctext         . *ctext*)
@@ -553,7 +577,7 @@ If CCL-PROG is symbol, it is dereferenced.
 \[Emacs 20.3 emulating function]"
   (exec-ccl-string
    (if (symbolp ccl-prog) (symbol-value ccl-prog) ccl-prog)
-   string status))
+   status string))
 
 
 ;;; @ end