X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=ew-data.el;h=962c455f3ae84176c574ea53664d3a6cae846280;hb=733c8dc5119f2b5df1fb571d0882c5f4350f21d5;hp=bccd7e5cb576998f2d918934f60beb7ec7343425;hpb=78a33e3e6fffbebddc10ade7a980201dad30acd8;p=elisp%2Fflim.git diff --git a/ew-data.el b/ew-data.el index bccd7e5..962c455 100644 --- a/ew-data.el +++ b/ew-data.el @@ -56,21 +56,47 @@ 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)) @@ -78,19 +104,19 @@ (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)) @@ -118,16 +144,13 @@ '(ew:atom))) (setq frag1 (get (get frag1 'prev-frag) 'next-frag))) (while (not (eq frag1 frag2)) + (setq frag2 (get frag2 'prev-frag)) (unless (ew-comment-frag-p frag2) - (put frag2 'decode 'ew-decode-phrase)) - (setq frag2 (get frag2 'prev-frag))) - (unless (ew-comment-frag-p frag2) - (put frag2 'decode 'ew-decode-phrase)) - (setq frag2 (get frag2 'prev-frag)) - (while (not (ew-token-last-frag-p frag2)) + (put frag2 'decode 'ew-decode-phrase))) + (while (not (ew-token-last-frag-p + (setq frag2 (get frag2 'prev-frag)))) (unless (ew-comment-frag-p frag2) - (put frag2 'decode 'ew-decode-phrase)) - (setq frag2 (get frag2 'prev-frag)))) + (put frag2 'decode 'ew-decode-phrase)))) ;;; frag predicate