mel of MEL 2.0.
[elisp/flim.git] / mel-q.el
index ca11faf..6539033 100644 (file)
--- a/mel-q.el
+++ b/mel-q.el
@@ -1,5 +1,5 @@
 ;;;
-;;; $Id: mel-q.el,v 1.5 1995/06/26 05:56:39 morioka Exp $
+;;; $Id: mel-q.el,v 2.0 1995/09/11 11:33:47 morioka Exp $
 ;;;
 
 ;;; @ constants
@@ -106,12 +106,23 @@ external decoder is called.")
     (save-restriction
       (narrow-to-region beg end)
       (goto-char (point-min))
-      (while (re-search-forward "^.*$" nil t)
-       (replace-match
-        (quoted-printable-encode-string
-         (buffer-substring (match-beginning 0)(match-end 0))
-         ))
-       ))))
+      (catch 'tag
+       (let (b e str)
+         (while t
+           (beginning-of-line) (setq b (point))
+           (end-of-line)       (setq e (point))
+           (if (< b e)
+               (progn
+                 (setq str (buffer-substring b e))
+                 (delete-region b e)
+                 (insert (quoted-printable-encode-string str))
+                 ))
+           (if (eobp)
+               (throw 'tag nil)
+             )
+           (forward-char 1)
+           )))
+      )))
 
 (defun quoted-printable-internal-decode-region (beg end)
   (save-excursion
@@ -127,7 +138,8 @@ external decoder is called.")
          (setq b (match-beginning 0))
          (setq e (match-end 0))
          (setq str (buffer-substring b e))
-         (replace-match (quoted-printable-decode-string str))
+         (delete-region b e)
+         (insert (quoted-printable-decode-string str))
          ))
       )))
 
@@ -205,7 +217,8 @@ external decoder is called.")
 (defun q-encoding-encode-string-for-phrase (str)
   (mapconcat (function
              (lambda (chr)
-               (cond ((or (and (<= ?A chr)(<= chr ?Z))
+               (cond ((eq chr 32) "_")
+                     ((or (and (<= ?A chr)(<= chr ?Z))
                           (and (<= ?a chr)(<= chr ?z))
                           (and (<= ?0 chr)(<= chr ?9))
                           (memq chr '(?! ?* ?+ ?- ?/))
@@ -223,11 +236,9 @@ external decoder is called.")
        ((eq mode 'comment)
         (q-encoding-encode-string-for-comment str)
         )
-       ((eq mode 'phrase)
+       (t
         (q-encoding-encode-string-for-phrase str)
-        )
-       (t (quoted-printable-encode-string str))
-       ))
+        )))
 
 (defun q-encoding-decode-string (str)
   (let (q h l)
@@ -275,4 +286,4 @@ external decoder is called.")
 ;;; @ end
 ;;;
 
-(provide 'qprint)
+(provide 'mel-q)