;---------^ ここから ; mew-send-hook for check sum-size of atached (defvar mew-attach-max-file-size (* 5 1024 1024)) ; 5M byte (defun mew-attach-check-file-size (&optional verbose nocompare) "添付ファイルサイズの概算合計を求める。nocompare でなく mew-attach-max-file-size を超えるとき、実行を中断する" (interactive "p") (save-excursion (let ( (beg (mew-attach-begin)) (end (point-max)) (sum 0) ) (unless (not beg) (goto-char (1+ beg)) (while (< (point) end) (setq sum (+ sum (or (mew-attach-file-size) 0))) (forward-line) ) ) (if verbose (princ (to-string-GMKbyte sum))) (if (and (not verbose) (not nocompare) (> sum mew-attach-max-file-size) (not (yes-or-no-p (concat "合計" (to-string-GMKbyte sum) "です。本当に送信しますか?")))) (error "Stop because of large file atached.") ) sum ))) (defun mew-attach-file-size (&optional verbose) "File size attached to cusor" (interactive "p") (unless (not (mew-attach-not-line012-1-dot)) (let* ((nums (mew-syntax-nums)) (subdir (mew-attach-expand-path mew-encode-syntax nums)) (attachdir (mew-attachdir)) (syntax (mew-syntax-get-entry mew-encode-syntax nums)) (file (mew-syntax-get-file syntax)) efile FILE size) (setq efile (if (string= subdir "") file (concat subdir file))) (setq FILE (expand-file-name efile attachdir)) (setq size (mew-file-get-size FILE)) (if verbose (princ (to-string-GMKbyte size))) size ) ) ) (defun to-string-GMKbyte (num) "数値を ..byte、..Kbyte、 ..Mbyte または ..Gbyte の文字列に変換して返す。" (if (numberp num) (cond ((> num (* 10 1024 1024 1024)) (format "%dG byte" (/ num (* 1024 1024 1024)))) ((> num (* 10 1024 1024 )) (format "%dM byte" (/ num (* 1024 1024 )))) ((> num (* 10 1024 )) (format "%dK byte" (/ num (* 1024 )))) (t (format "%d byte" num )) ))) (add-hook 'mew-send-hook 'mew-attach-check-file-size) ;---------$ ここまで