X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=mime-view.el;h=31b8979f047a1e38e8a34a9ee492db456de9ba4a;hb=1dc398f11cf935a529b21fadca5ee8b391925edc;hp=517be3861a797c3f4eb617cfab4b355a24ca4ac0;hpb=161121661bccbbf008d3153520a3a76dfdd34b9f;p=elisp%2Fsemi.git diff --git a/mime-view.el b/mime-view.el index 517be38..31b8979 100644 --- a/mime-view.el +++ b/mime-view.el @@ -421,7 +421,8 @@ mother-buffer." (defun mime-save-situation-examples () (if (or mime-preview-situation-example-list mime-acting-situation-example-list) - (let ((file mime-situation-examples-file)) + (let ((file mime-situation-examples-file) + print-length print-level) (with-temp-buffer (insert ";;; " (file-name-nondirectory file) "\n") (insert "\n;; This file is generated automatically by " @@ -438,7 +439,7 @@ mother-buffer." (insert "\n;;; " (file-name-nondirectory file) " ends here.\n") - (static-cond + (static-cond ((boundp 'buffer-file-coding-system) (setq buffer-file-coding-system mime-situation-examples-file-coding-system)) @@ -446,7 +447,7 @@ mother-buffer." (setq file-coding-system mime-situation-examples-file-coding-system))) ;; (setq buffer-file-coding-system - ;; mime-situation-examples-file-coding-system) + ;; mime-situation-examples-file-coding-system) (setq buffer-file-name file) (save-buffer))))) @@ -598,24 +599,22 @@ mother-buffer." ))) ) (t - (let ((media-type (mime-entity-media-type entity)) - (media-subtype (mime-entity-media-subtype entity)) - (charset (cdr (assoc "charset" params))) - (encoding (mime-entity-encoding entity))) + (let* ((charset (cdr (assoc "charset" params))) + (encoding (mime-entity-encoding entity)) + (rest (format " <%s/%s%s%s>" + (mime-entity-media-type entity) + (mime-entity-media-subtype entity) + (if charset + (concat "; " charset) + "") + (if encoding + (concat " (" encoding ")") + "")))) (concat num " " subject - (let ((rest - (format " <%s/%s%s%s>" - media-type media-subtype - (if charset - (concat "; " charset) - "") - (if encoding - (concat " (" encoding ")") - "")))) - (if (>= (+ (current-column)(length rest))(window-width)) - "\n\t") - rest))) + (if (>= (+ (current-column)(length rest))(window-width)) + "\n\t") + rest)) ))) (function mime-preview-play-current-entity)) )) @@ -806,7 +805,8 @@ Each elements are regexp of field-name.") (narrow-to-region (point-max)(point-max)) (mime-insert-text-content entity) (run-hooks 'mime-text-decode-hook) - (let ((beg (point-min))) + (let ((beg (point-min)) + (adaptive-fill-mode nil)) (remove-text-properties beg (point-max) '(face nil)) (richtext-decode beg (point-max)) ))) @@ -816,7 +816,8 @@ Each elements are regexp of field-name.") (narrow-to-region (point-max)(point-max)) (mime-insert-text-content entity) (run-hooks 'mime-text-decode-hook) - (let ((beg (point-min))) + (let ((beg (point-min)) + (adaptive-fill-mode nil)) (remove-text-properties beg (point-max) '(face nil)) (enriched-decode beg (point-max)) ))) @@ -940,10 +941,11 @@ MEDIA-TYPE must be (TYPE . SUBTYPE), TYPE or t. t means default." (car (mime-entity-children entity)))) (original-major-mode-cell (assq 'major-mode situation)) (default-situation (cdr (assq 'childrens-situation situation)))) - (if original-major-mode-cell - (setq default-situation - (cons original-major-mode-cell default-situation))) - (mime-display-entity start nil default-situation))) + (when start + (if original-major-mode-cell + (setq default-situation + (cons original-major-mode-cell default-situation))) + (mime-display-entity start nil default-situation)))) ;;; @ acting-condition ;;; @@ -1472,17 +1474,19 @@ button-2 Move to point under the mouse cursor ;;; @@ utility ;;; -(defun mime-preview-find-boundary-info (&optional get-mother) +(defun mime-preview-find-boundary-info (&optional with-children) "Return boundary information of current part. -If GET-MOTHER, refer boundary surrounding current part and its branches." +If WITH-CHILDREN, refer boundary surrounding current part and its branches." (let (entity p-beg p-end entity-node-id len) - (while (null (setq entity - (get-text-property (point) 'mime-view-entity))) + (while (and + (null (setq entity + (get-text-property (point) 'mime-view-entity))) + (> (point) (point-min))) (backward-char)) (setq p-beg (previous-single-property-change (point) 'mime-view-entity)) - (setq entity-node-id (mime-entity-node-id entity)) + (setq entity-node-id (and entity (mime-entity-node-id entity))) (setq len (length entity-node-id)) (cond ((null p-beg) (setq p-beg @@ -1503,7 +1507,7 @@ If GET-MOTHER, refer boundary surrounding current part and its branches." ((null entity-node-id) (setq p-end (point-max)) ) - (get-mother + (with-children (save-excursion (catch 'tag (let (e i) @@ -1558,13 +1562,13 @@ It decodes current entity to call internal or external method as It calls following-method selected from variable `mime-preview-following-method-alist'." (interactive) - (let ((entity (mime-preview-find-boundary-info t)) - p-beg p-end - pb-beg) - (setq p-beg (aref entity 0) - p-end (aref entity 1) - entity (aref entity 2)) - (if (get-text-property p-beg 'mime-view-entity-body) + (let* ((boundary-info (mime-preview-find-boundary-info t)) + (p-beg (aref boundary-info 0)) + (p-end (aref boundary-info 1)) + (entity (aref boundary-info 2)) + pb-beg) + (if (or (get-text-property p-beg 'mime-view-entity-body) + (null entity)) (setq pb-beg p-beg) (setq pb-beg (next-single-property-change @@ -1572,7 +1576,7 @@ It calls following-method selected from variable (or (next-single-property-change p-beg 'mime-view-entity) p-end)))) (let* ((mode (mime-preview-original-major-mode 'recursive)) - (entity-node-id (mime-entity-node-id entity)) + (entity-node-id (and entity (mime-entity-node-id entity))) (new-name (format "%s-%s" (buffer-name) (reverse entity-node-id))) new-buf @@ -1585,7 +1589,8 @@ It calls following-method selected from variable (insert-buffer-substring the-buf pb-beg p-end) (goto-char (point-min)) (let ((current-entity - (if (and (eq (mime-entity-media-type entity) 'message) + (if (and entity + (eq (mime-entity-media-type entity) 'message) (eq (mime-entity-media-subtype entity) 'rfc822)) (car (mime-entity-children entity)) entity))) @@ -1626,9 +1631,8 @@ It calls following-method selected from variable (if (functionp f) (funcall f new-buf) (message - (format - "Sorry, following method for %s is not implemented yet." - mode)) + "Sorry, following method for %s is not implemented yet." + mode) )) ))) @@ -1805,7 +1809,7 @@ If LINES is negative, scroll up LINES lines." ;;; (defun mime-preview-toggle-display (type &optional display) - (let ((situation (mime-preview-find-boundary-info)) + (let ((situation (mime-preview-find-boundary-info t)) (sym (intern (concat "*" (symbol-name type)))) entity p-beg p-end) (setq p-beg (aref situation 0) @@ -1817,9 +1821,9 @@ If LINES is negative, scroll up LINES lines." (display) (t (setq display - (eq (cdr (or (assq sym situation) - (assq type situation))) - 'invisible)))) + (memq (cdr (or (assq sym situation) + (assq type situation))) + '(nil invisible))))) (setq situation (put-alist sym (if display 'visible 'invisible)