From: yoichi Date: Fri, 18 Oct 2002 06:23:46 +0000 (+0000) Subject: * wl-mime.el (wl-mime-preview-follow-current-region): New function X-Git-Tag: wl-2_11_1~98 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c4e7ce1dade928921d2ef82110694e365ca55dc2;p=elisp%2Fwanderlust.git * wl-mime.el (wl-mime-preview-follow-current-region): New function that originates in mime-preview-follow-current-entity. (wl-draft-yank-current-message-entity): Use it if region is active. * wl-mime.el (wl-message-delete-current-part): Remove restriction. * wl-e21.el (wl-message-define-keymap): Bind "D" for `wl-message-delete-current-part'. * wl-mule.el (wl-message-define-keymap): Ditto. * wl-xmas.el (wl-message-define-keymap): Ditto. --- diff --git a/wl/ChangeLog b/wl/ChangeLog index 132a34e..37c73bf 100644 --- a/wl/ChangeLog +++ b/wl/ChangeLog @@ -1,3 +1,15 @@ +2002-10-18 Yoichi NAKAYAMA + + * wl-mime.el (wl-mime-preview-follow-current-region): New function + that originates in mime-preview-follow-current-entity. + (wl-draft-yank-current-message-entity): Use it if region is active. + + * wl-mime.el (wl-message-delete-current-part): Remove restriction. + * wl-e21.el (wl-message-define-keymap): Bind "D" for + `wl-message-delete-current-part'. + * wl-mule.el (wl-message-define-keymap): Ditto. + * wl-xmas.el (wl-message-define-keymap): Ditto. + 2002-10-18 Yuuichi Teranishi * wl-mime.el (wl-message-delete-current-part): Check the class of diff --git a/wl/wl-e21.el b/wl/wl-e21.el index bd8c203..49110ef 100644 --- a/wl/wl-e21.el +++ b/wl/wl-e21.el @@ -528,6 +528,7 @@ (defun wl-message-define-keymap () (let ((keymap (make-sparse-keymap))) + (define-key keymap "D" 'wl-message-delete-current-part) (define-key keymap "l" 'wl-message-toggle-disp-summary) (define-key keymap [mouse-4] 'wl-message-wheel-down) (define-key keymap [mouse-5] 'wl-message-wheel-up) diff --git a/wl/wl-mime.el b/wl/wl-mime.el index 9df89f8..9d0c402 100644 --- a/wl/wl-mime.el +++ b/wl/wl-mime.el @@ -51,7 +51,11 @@ (defun wl-draft-yank-current-message-entity () "Yank currently displayed message entity. -By setting following-method as yank-content." +By setting following-method as yank-content. + +If region is active, yank region contents instead. \(this feature is available +if and only if `transient-mark-mode' \(GNU Emacs\) or `zmacs-regions' \(XEmacs\) +has Non-nil value\)" (let ((wl-draft-buffer (current-buffer)) (mime-view-following-method-alist (list (cons 'wl-original-message-mode @@ -61,10 +65,84 @@ By setting following-method as yank-content." (function wl-draft-yank-to-draft-buffer))))) (if (get-buffer (wl-current-message-buffer)) (save-excursion + (set-buffer (wl-current-message-buffer)) (save-restriction - (set-buffer (wl-current-message-buffer)) (widen) - (mime-preview-follow-current-entity)))))) + (if (or (and wl-on-xemacs + zmacs-regions zmacs-region-active-p) + (and transient-mark-mode mark-active)) + (wl-mime-preview-follow-current-region) + (mime-preview-follow-current-entity))))))) + +;; modified mime-preview-follow-current-entity from mime-view.el +(defun wl-mime-preview-follow-current-region () + "Write follow message to current region. +It calls following-method selected from variable +`mime-preview-following-method-alist'." + (interactive) + (let ((r-beg (region-beginning)) + (r-end (region-end)) + (entity (get-text-property (point-min) + 'mime-view-entity))) + (let* ((mode (mime-preview-original-major-mode 'recursive)) + (new-name + (format "%s-active-region" (buffer-name))) + new-buf + (the-buf (current-buffer)) + fields) + (save-excursion + (set-buffer (setq new-buf (get-buffer-create new-name))) + (erase-buffer) + (insert ?\n) + (insert-buffer-substring the-buf r-beg r-end) + (goto-char (point-min)) + (let ((current-entity + (if (and (eq (mime-entity-media-type entity) 'message) + (eq (mime-entity-media-subtype entity) 'rfc822)) + (car (mime-entity-children entity)) + entity))) + (while (and current-entity + (if (and (eq (mime-entity-media-type + current-entity) 'message) + (eq (mime-entity-media-subtype + current-entity) 'rfc822)) + nil + (mime-insert-header current-entity fields) + t)) + (setq fields (std11-collect-field-names) + current-entity (mime-entity-parent current-entity)) + )) + (let ((rest mime-view-following-required-fields-list) + field-name ret) + (while rest + (setq field-name (car rest)) + (or (std11-field-body field-name) + (progn + (save-excursion + (set-buffer the-buf) + (let ((entity (when mime-mother-buffer + (set-buffer mime-mother-buffer) + (get-text-property (point) + 'mime-view-entity)))) + (while (and entity + (null (setq ret (mime-entity-fetch-field + entity field-name)))) + (setq entity (mime-entity-parent entity))))) + (if ret + (insert (concat field-name ": " ret "\n")) + ))) + (setq rest (cdr rest)) + )) + ) + (let ((f (cdr (assq mode mime-preview-following-method-alist)))) + (if (functionp f) + (funcall f new-buf) + (message + (format + "Sorry, following method for %s is not implemented yet." + mode)) + )) + ))) (defalias 'wl-draft-enclose-digest-region 'mime-edit-enclose-digest-region) @@ -176,47 +254,49 @@ By setting following-method as yank-content." (defun wl-message-delete-current-part () "Delete a part under the cursor from the multipart message." (interactive) - (let* ((entity (get-text-property (point) 'mime-view-entity)) - (node-id (mime-entity-node-id entity)) - (header-start (mime-buffer-entity-header-start-internal entity)) - (body-end (mime-buffer-entity-body-end-internal entity)) - (folder (wl-folder-get-elmo-folder wl-message-buffer-cur-folder)) - (number wl-message-buffer-cur-number) - (msgid (elmo-message-field folder number 'message-id)) - (orig-buf wl-message-buffer-original-buffer)) - (if (eq (luna-class-name entity) 'mime-elmo-imap-entity) - (error "Please fetch the entire message (by typing 'C-u .') and try again")) - (with-current-buffer orig-buf - (unless (string-equal - (buffer-string) - (elmo-message-fetch folder number - (elmo-make-fetch-strategy 'entire))) - (error "Buffer content differs from actual message"))) - (when (and (elmo-folder-writable-p folder) - (buffer-live-p orig-buf) - node-id - (yes-or-no-p - (format "Do you really want to delete part %s? " - (wl-mime-node-id-to-string node-id)))) - (with-temp-buffer - (insert-buffer orig-buf) - (kill-region header-start body-end) - (goto-char header-start) - (insert "Content-Type: text/plain; charset=US-ASCII\n\n") - (insert "** This part has been removed by Wanderlust **\n\n") - (elmo-folder-append-buffer folder t)) - - (elmo-folder-append-messages - (wl-folder-get-elmo-folder wl-trash-folder) - folder (list number) nil) - (elmo-folder-delete-messages folder (list number)) - - (when (file-exists-p (elmo-cache-get-path msgid)) - (delete-file (elmo-cache-get-path msgid))) - - (mime-preview-quit) - (wl-summary-toggle-disp-msg 'off) - (wl-summary-sync nil "update")))) + (save-restriction + (widen) + (let* ((entity (get-text-property (point) 'mime-view-entity)) + (node-id (mime-entity-node-id entity)) + (header-start (mime-buffer-entity-header-start-internal entity)) + (body-end (mime-buffer-entity-body-end-internal entity)) + (folder (wl-folder-get-elmo-folder wl-message-buffer-cur-folder)) + (number wl-message-buffer-cur-number) + (msgid (elmo-message-field folder number 'message-id)) + (orig-buf wl-message-buffer-original-buffer)) + (if (eq (luna-class-name entity) 'mime-elmo-imap-entity) + (error "Please fetch the entire message (by typing 'C-u .') and try again")) + (with-current-buffer orig-buf + (unless (string-equal + (buffer-string) + (elmo-message-fetch folder number + (elmo-make-fetch-strategy 'entire))) + (error "Buffer content differs from actual message"))) + (when (and (elmo-folder-writable-p folder) + (buffer-live-p orig-buf) + node-id + (yes-or-no-p + (format "Do you really want to delete part %s? " + (wl-mime-node-id-to-string node-id)))) + (with-temp-buffer + (insert-buffer orig-buf) + (kill-region header-start body-end) + (goto-char header-start) + (insert "Content-Type: text/plain; charset=US-ASCII\n\n") + (insert "** This part has been removed by Wanderlust **\n\n") + (elmo-folder-append-buffer folder t)) + + (elmo-folder-append-messages + (wl-folder-get-elmo-folder wl-trash-folder) + folder (list number) nil) + (elmo-folder-delete-messages folder (list number)) + + (when (file-exists-p (elmo-cache-get-path msgid)) + (delete-file (elmo-cache-get-path msgid))) + + (mime-preview-quit) + (wl-summary-toggle-disp-msg 'off) + (wl-summary-sync nil "update"))))) ;;; Summary (defun wl-summary-burst-subr (message-entity target number) diff --git a/wl/wl-mule.el b/wl/wl-mule.el index 7dc9f6e..985768d 100644 --- a/wl/wl-mule.el +++ b/wl/wl-mule.el @@ -100,6 +100,7 @@ Special commands: (defun wl-message-define-keymap () (let ((keymap (make-sparse-keymap))) + (define-key keymap "D" 'wl-message-delete-current-part) (define-key keymap "l" 'wl-message-toggle-disp-summary) (define-key keymap [mouse-4] 'wl-message-wheel-down) (define-key keymap [mouse-5] 'wl-message-wheel-up) diff --git a/wl/wl-xmas.el b/wl/wl-xmas.el index d3d42b5..93da3a2 100644 --- a/wl/wl-xmas.el +++ b/wl/wl-xmas.el @@ -446,6 +446,7 @@ (defun wl-message-define-keymap () (let ((keymap (make-sparse-keymap))) + (define-key keymap "D" 'wl-message-delete-current-part) (define-key keymap "l" 'wl-message-toggle-disp-summary) (define-key keymap 'button4 'wl-message-wheel-down) (define-key keymap 'button5 'wl-message-wheel-up)