* mime-def.el (mime-library-product): Fix typo.
[elisp/flim.git] / ew-data.el
index 436b014..962c455 100644 (file)
            frag))
    (ew-frag-list anchor)))
 
+(defun ew-search-sticked-eword (frag start)
+  (let* ((texts (symbol-name frag)) (len (length texts)))
+    (catch 'return
+      (while (string-match ew-encoded-word-regexp texts start)
+       (when (and (or ew-permit-null-encoded-text
+                      (< (match-beginning 3) (match-end 3)))
+                  (or ew-ignore-75bytes-limit
+                      (<= (- (match-end 0) (match-beginning 0)) 75))
+                  (or ew-permit-sticked-comment
+                      (not (= (match-beginning 0) 0))
+                      (not (ew-comment-frag-p (get frag 'prev-frag))))
+                  (or ew-permit-sticked-comment
+                      (not (= (match-end 0) (length texts)))
+                      (not (ew-comment-frag-p (get frag 'next-frag))))
+                  (or ew-permit-sticked-special
+                      (not (= (match-beginning 0) 0))
+                      (ew-comment-frag-p (get frag 'prev-frag))
+                      (not (ew-special-frag-p (get frag 'prev-frag))))
+                  (or ew-permit-sticked-special
+                      (not (= (match-end 0) (length texts)))
+                      (ew-comment-frag-p (get frag 'next-frag))
+                      (not (ew-special-frag-p (get frag 'next-frag))))
+                  )
+         (throw 'return t))
+       (setq start (1- (match-end 0))))
+      nil)))
+
 (defun ew-separate-eword (frag1 frag2 targets)
   (while (not (eq frag1 frag2))
     (when (and (memq (get frag1 'type) targets)
-              (string-match ew-encoded-word-regexp
-                            (symbol-name frag1))
+              (ew-search-sticked-eword frag1 0)
               (or (< 0 (match-beginning 0))
                   (< (match-end 0) (length (symbol-name frag1)))))
-      (let ((atom (symbol-name frag1))
+      (let ((texts (symbol-name frag1))
            (start (match-end 0))
            result
            frag)
        (when (< 0 (match-beginning 0))
-         (setq frag (make-symbol (substring atom 0 (match-beginning 0)))
+         (setq frag (make-symbol (substring texts 0 (match-beginning 0)))
                result (ew-rcons* result frag)))
-       (setq frag (make-symbol (substring atom (match-beginning 0) (match-end 0)))
+       (setq frag (make-symbol (substring texts (match-beginning 0) (match-end 0)))
              result (ew-rcons* result frag))
        (when (cdr result)
          (put frag 'prev-frag (cadr result))
          (setq frag (cadr result)))
        (put frag 'prev-frag (get frag1 'prev-frag))
        (put (get frag1 'prev-frag) 'next-frag frag)
-       (while (string-match ew-encoded-word-regexp atom start)
+       (while (ew-search-sticked-eword frag1 start)
          (when (< start (match-beginning 0))
-           (setq frag (make-symbol (substring atom start (match-beginning 0)))
+           (setq frag (make-symbol (substring texts start (match-beginning 0)))
                  result (ew-rcons* result frag))
            (put frag 'prev-frag (cadr result))
            (put (cadr result) 'next-frag frag))
-         (setq frag (make-symbol (substring atom (match-beginning 0) (match-end 0)))
+         (setq frag (make-symbol (substring texts (match-beginning 0) (match-end 0)))
                result (ew-rcons* result frag)
                start (match-end 0))
          (put frag 'prev-frag (cadr result))
          (put (cadr result) 'next-frag frag))
        (when (< start (length (symbol-name frag1)))
-         (setq frag (make-symbol (substring atom start))
+         (setq frag (make-symbol (substring texts start))
                result (ew-rcons* result frag))
          (put frag 'prev-frag (cadr result))
          (put (cadr result) 'next-frag frag))