From: yamaoka Date: Thu, 4 Oct 2001 07:04:01 +0000 (+0000) Subject: * message.el (message-fix-before-sending): Don't expose invisible MIME parts; X-Git-Tag: t-gnus-6_15_4-08-quimby-last-~57 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f245e902ddac8215ff05e77b8dd3b4cca726bd44;p=elisp%2Fgnus.git- * message.el (message-fix-before-sending): Don't expose invisible MIME parts; don't use `message-find-invisible-regions'. (message-find-invisible-regions): Remove. (invisible-region): Advise the function to add the text property `mime-edit-invisible'. (message-invisible-region): Remove. (message-save-drafts): Copy all the text properties from the editing buffer to the encoding buffer. (message-send): Ditto. --- diff --git a/ChangeLog b/ChangeLog index b33b92b..df56309 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2001-10-04 Katsumi Yamaoka + + * lisp/message.el (message-fix-before-sending): Don't expose + invisible MIME parts; don't use `message-find-invisible-regions'. + (message-find-invisible-regions): Remove. + (invisible-region): Advise the function to add the text property + `mime-edit-invisible'. + (message-invisible-region): Remove. + (message-save-drafts): Copy all the text properties from the + editing buffer to the encoding buffer. + (message-send): Ditto. + 2001-10-01 Katsumi Yamaoka * lisp/nndoc.el (nndoc-oe-dbx-type-p): Use `string-as-multibyte' diff --git a/lisp/message.el b/lisp/message.el index 2457d7b..43f1068 100644 --- a/lisp/message.el +++ b/lisp/message.el @@ -2780,17 +2780,10 @@ It should typically alter the sending method in some way or other." (save-excursion (set-buffer message-encoding-buffer) (erase-buffer) - ;; Avoid copying text props. - (let (message-invisibles) - (insert - (with-current-buffer message-edit-buffer - (setq message-invisibles (message-find-invisible-regions)) - (buffer-substring-no-properties (point-min) (point-max)))) - ;; Inherit the invisible property of texts to make MIME-Edit - ;; find the MIME part boundaries. - (dolist (region message-invisibles) - (add-text-properties (car region) (cdr region) - '(invisible t mime-edit-invisible t)))) + ;; ;; Avoid copying text props. + ;; T-gnus change: copy all text props from the editing buffer + ;; into the encoding buffer. + (insert-buffer message-edit-buffer) (funcall message-encode-function) (while (and success (setq elem (pop alist))) @@ -2842,55 +2835,25 @@ It should typically alter the sending method in some way or other." (put 'message-check 'lisp-indent-function 1) (put 'message-check 'edebug-form-spec '(form body)) -;; This function will be used by MIME-Edit when inserting invisible parts. -(defun message-invisible-region (start end) - (if (featurep 'xemacs) - (if (save-excursion - (goto-char start) - (eq (following-char) ?\n)) - (setq start (1+ start))) - (if (save-excursion - (goto-char (1- end)) - (eq (following-char) ?\n)) - (setq end (1- end)))) - (put-text-property start end 'invisible t) - (if (eq 'message-mode major-mode) - (put-text-property start end 'message-invisible t))) - -(eval-after-load "invisible" - '(defalias 'invisible-region 'message-invisible-region)) - -(defun message-find-invisible-regions () - "Find invisible texts with the property `message-invisible' or -`mime-edit-invisible' and return a list of points." - (let* (emiko - (from (or (setq emiko (text-property-any (point-min) (point-max) - 'mime-edit-invisible t)) - (text-property-any (point-min) (point-max) - 'message-invisible t))) - to regions) - (when from - (setq to (or (if emiko - (text-property-not-all from (point-max) - 'mime-edit-invisible t) - (text-property-not-all from (point-max) - 'message-invisible t)) - (point-max))) - (push (cons from to) regions) - (if emiko - (while (setq from (text-property-any to (point-max) - 'mime-edit-invisible t)) - (setq to (or (text-property-not-all from (point-max) - 'mime-edit-invisible t) - (point-max))) - (push (cons from to) regions)) - (while (setq from (text-property-any to (point-max) - 'message-invisible t)) - (setq to (or (text-property-not-all from (point-max) - 'message-invisible t) - (point-max))) - (push (cons from to) regions))) - regions))) +;; Advise the function `invisible-region'. +(let (current-load-list) + (eval + `(defadvice invisible-region (around add-mime-edit-invisible (start end) + activate) + "Advised by T-gnus Message. +Add the text property `mime-edit-invisible' to an invisible text when +the buffer's major mode is `message-mode'. The added property will be +used to distinguish whether the invisible text is a MIME part or not." + ,(if (featurep 'xemacs) + '(if (eq ?\n (char-after start)) + (setq start (1+ start))) + '(if (eq ?\n (char-after (1- end))) + (setq end (1- end)))) + (setq ad-return-value + (if (eq 'message-mode major-mode) + (add-text-properties start end + '(invisible t mime-edit-invisible t)) + (put-text-property start end 'invisible t)))))) (defun message-fix-before-sending () "Do various things to make the message nice before sending it." @@ -2899,24 +2862,33 @@ It should typically alter the sending method in some way or other." (goto-char (point-max)) (unless (bolp) (insert "\n")) - ;; Expose all invisible text with the property `message-invisible' - ;; or `mime-edit-invisible'. We should believe that the things - ;; might be created by MIME-Edit. - (let ((message-invisibles (message-find-invisible-regions))) - (dolist (region message-invisibles) - (put-text-property (car region) (cdr region) 'invisible nil)) - ;; Expose all invisible text. - (message-check 'invisible-text - (when (text-property-any (point-min) (point-max) 'invisible t) - (put-text-property (point-min) (point-max) 'invisible nil) + ;; Delete all invisible text except for the mime parts which might + ;; be inserted by the MIME-Edit. + (message-check 'invisible-text + (let (from + (to (point-min)) + mime-from mime-to hidden-start) + (while (setq from (text-property-any to (point-max) 'invisible t)) + (setq to (or (text-property-not-all from (point-max) 'invisible t) + (point-max)) + mime-to from) + (while (setq mime-from (text-property-any mime-to to + 'mime-edit-invisible t)) + (when (> mime-from mime-to) + (setq hidden-start (or hidden-start mime-to)) + (put-text-property mime-to mime-from 'invisible nil)) + (setq mime-to (or (text-property-not-all mime-from to + 'mime-edit-invisible t) + to))) + (when (< mime-to to) + (setq hidden-start (or hidden-start mime-to)) + (put-text-property mime-to to 'invisible nil))) + (when hidden-start + (goto-char hidden-start) + (set-window-start (selected-window) (gnus-point-at-bol)) (unless (yes-or-no-p "Invisible text found and made visible; continue posting? ") - (error "Invisible text found and made visible")))) - ;; Hide again all text with the property `message-invisible' or - ;; `mime-edit-invisible'. It is needed to make MIME-Edit find the - ;; MIME part boundaries. - (dolist (region message-invisibles) - (put-text-property (car region) (cdr region) 'invisible t)))) + (error "Invisible text found and made visible")))))) (defun message-add-action (action &rest types) "Add ACTION to be performed when doing an exit of type TYPES." @@ -5913,15 +5885,9 @@ regexp varstr." (interactive) (message "Saving %s..." buffer-file-name) (let ((reply-headers message-reply-headers) - (msg (buffer-substring-no-properties (point-min) (point-max))) - (message-invisibles (message-find-invisible-regions))) + (buffer (current-buffer))) (with-temp-file buffer-file-name - (insert msg) - ;; Inherit the invisible property of texts to make MIME-Edit - ;; find the MIME part boundaries. - (dolist (region message-invisibles) - (add-text-properties (car region) (cdr region) - '(invisible t mime-edit-invisible t))) + (insert-buffer buffer) (setq message-reply-headers reply-headers) (message-generate-headers '((optional . In-Reply-To))) (mime-edit-translate-buffer))