Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 150F8431FD0 for ; Sat, 16 Jul 2011 12:31:36 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.699 X-Spam-Level: X-Spam-Status: No, score=-0.699 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id z7BeW0-8hQ2j for ; Sat, 16 Jul 2011 12:31:34 -0700 (PDT) Received: from mail-qy0-f181.google.com (mail-qy0-f181.google.com [209.85.216.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 0F3C8431FB6 for ; Sat, 16 Jul 2011 12:31:34 -0700 (PDT) Received: by qyk9 with SMTP id 9so1416290qyk.5 for ; Sat, 16 Jul 2011 12:31:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=mp84a5lCy+y0LfMQvD0KCKrwd/QKyw6kpmKcgxOXP3M=; b=Tn8odq3+esV+k4yJL11ko7u89pwZUDL1m/U1AhYPXPpr1PPb5KA6RYcJSGimau/GQu Qyt8MOTscKcL/9UhshOD9feKXvpCXrrjhNhGfnc+Xqq7LFexJGp2LZE07iG28GODBqNX dUy3YohcjajxB6NfOsLSbN97PmkeKxZcCD21k= MIME-Version: 1.0 Received: by 10.229.27.198 with SMTP id j6mr3708789qcc.10.1310844691654; Sat, 16 Jul 2011 12:31:31 -0700 (PDT) Sender: amdragon@gmail.com Received: by 10.229.250.208 with HTTP; Sat, 16 Jul 2011 12:31:31 -0700 (PDT) In-Reply-To: <1310841685-29167-1-git-send-email-anarcat@koumbit.org> References: <1310807540-29960-1-git-send-email-anarcat@koumbit.org> <1310841685-29167-1-git-send-email-anarcat@koumbit.org> Date: Sat, 16 Jul 2011 15:31:31 -0400 X-Google-Sender-Auth: PO4J04y2Ix-Ob6Dy6yP9n_VHI34 Message-ID: Subject: Re: [PATCH 2/2] add edit function to resume postponed emails From: Austin Clements To: =?ISO-8859-1?Q?Antoine_Beaupr=E9?= Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: notmuch@notmuchmail.org X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Jul 2011 19:31:36 -0000 I think this could be simplified a lot and many of the known issues addressed if this were narrowed to *only* resuming from drafts. message-mode draft files aren't MIME messages (or, at least, they're never multipart, and message-mode has its own special annotations over basic RFC 822), so rather than treating the draft as a MIME message and trying to transform it back into a message-mode-compatible draft (which, in full generality, would be somewhere between hard and impossible), what about just dumping the raw contents of the draft file into a buffer and pointing message-mode at it? If the draft file is available, you could even open it directly (this wouldn't work for remote usage, but remote drafts introduce many other problems, too). 2011/7/16 Antoine Beaupr=E9 : > Add a new function to allow editing a new message starting from an > existing one, roughly the equivalent of Mutt's resend-message > functionality. > > Hooks into the search and show views through the "e" keybinding. > > "draft" tag is removed after the email is sent and the target thread > is marked as deleted. > > Known issues: > > =A01. only the first MIME part of the email is used > =A02. running this on a thread with more than one message has not been > =A0tested > =A03. encoding is broken when files are reloaded, because we don't parse > =A0MIME back > =A04. draft files are left around when mails are written, even if they > =A0are not postponed > > Todo: > > =A01. use the proper gnus hooks to resume emails: > =A0https://www.gnu.org/software/emacs/manual/html_node/message/Message-Ac= tions.html#index-message_002dpostpone_002dactions-334 > > =A02. write tests > > Signed-off-by: Antoine Beaupr=E9 > --- > =A0emacs/notmuch-mua.el =A0| =A0 50 +++++++++++++++++++++++++++++++++++++= ++++++++++++ > =A0emacs/notmuch-show.el | =A0 =A06 +++++ > =A0emacs/notmuch.el =A0 =A0 =A0| =A0 =A07 ++++++ > =A03 files changed, 63 insertions(+), 0 deletions(-) > > diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el > index 274c5da..11d014d 100644 > --- a/emacs/notmuch-mua.el > +++ b/emacs/notmuch-mua.el > @@ -201,6 +201,56 @@ the From: address first." > =A0 =A0 =A0 =A0 =A0 (list (cons 'from (notmuch-mua-prompt-for-sender)))))= ) > =A0 =A0 (notmuch-mua-mail nil nil other-headers))) > > +(defun notmuch-mua-delete-postponed (query-string) > + =A0"Delete postponed mail after sending." > + =A0(notmuch-tag query-string "+deleted") > + =A0(notmuch-tag query-string "-draft") > +) > + > +(defun notmuch-mua-edit-mail (query-string) > + =A0"Create a new mail composition window based on the current mail." > + =A0(interactive) > + =A0(let (headers > + =A0 =A0 =A0 body > + =A0 =A0 =A0 (args '("show" "--format=3Draw"))) > + =A0 =A0(if notmuch-show-process-crypto > + =A0 =A0 =A0 (setq args (append args '("--decrypt")))) > + =A0 =A0(setq args (append args (list query-string))) > + =A0 =A0;; This make assumptions about the output of `notmuch show', but > + =A0 =A0;; really only that the headers come first followed by a blank > + =A0 =A0;; line and then the body. > + =A0 =A0(with-temp-buffer > + =A0 =A0 =A0(apply 'call-process (append (list notmuch-command nil (list= t t) nil) args)) > + =A0 =A0 =A0(goto-char (point-min)) > + =A0 =A0 =A0(if (re-search-forward "^$" nil t) > + =A0 =A0 =A0 =A0 (save-excursion > + =A0 =A0 =A0 =A0 =A0 (save-restriction > + =A0 =A0 =A0 =A0 =A0 =A0 (narrow-to-region (point-min) (point)) > + =A0 =A0 =A0 =A0 =A0 =A0 (goto-char (point-min)) > + =A0 =A0 =A0 =A0 =A0 =A0 (setq headers (mail-header-extract)))) > + =A0 =A0 =A0 =A0 ) > + =A0 =A0 =A0(forward-line 1) > + =A0 =A0 =A0(setq body (buffer-substring (point) (point-max))) > + =A0 =A0 =A0) > + > + =A0 =A0(let ((message-signature nil)) > + =A0 =A0 =A0(notmuch-mua-mail (mail-header 'to headers) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (mail-header 'subject heade= rs) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (message-headers-to-generat= e headers t '(to subject)) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 t nil nil (notmuch-mua-dele= te-postponed query-string)) > + =A0 =A0) > + > + =A0 =A0;; insert the message body - but put it in front of the signatur= e > + =A0 =A0;; if one is present > + =A0 =A0(goto-char (point-max)) > + =A0 =A0(if (re-search-backward message-signature-separator nil t) > + =A0 =A0 =A0 =A0 (forward-line -1) > + =A0 =A0 =A0(goto-char (point-max))) > + =A0 =A0(insert body)) > + =A0(set-buffer-modified-p nil) > + > + =A0(message-goto-body)) > + > =A0(defun notmuch-mua-new-forward-message (&optional prompt-for-sender) > =A0 "Invoke the notmuch message forwarding window. > > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el > index c83b992..1efde1c 100644 > --- a/emacs/notmuch-show.el > +++ b/emacs/notmuch-show.el > @@ -865,6 +865,7 @@ function is used. " > =A0 =A0 =A0 =A0(define-key map "m" 'notmuch-mua-new-mail) > =A0 =A0 =A0 =A0(define-key map "f" 'notmuch-show-forward-message) > =A0 =A0 =A0 =A0(define-key map "r" 'notmuch-show-reply) > + =A0 =A0 =A0 (define-key map "e" 'notmuch-show-edit) > =A0 =A0 =A0 =A0(define-key map "|" 'notmuch-show-pipe-message) > =A0 =A0 =A0 =A0(define-key map "w" 'notmuch-show-save-attachments) > =A0 =A0 =A0 =A0(define-key map "V" 'notmuch-show-view-raw-message) > @@ -1165,6 +1166,11 @@ any effects from previous calls to > =A0 (interactive "P") > =A0 (notmuch-mua-new-reply (notmuch-show-get-message-id) prompt-for-sende= r)) > > +(defun notmuch-show-edit () > + =A0"Edit the current message as new." > + =A0(interactive) > + =A0(notmuch-mua-edit-mail (notmuch-show-get-message-id))) > + > =A0(defun notmuch-show-forward-message (&optional prompt-for-sender) > =A0 "Forward the current message." > =A0 (interactive "P") > diff --git a/emacs/notmuch.el b/emacs/notmuch.el > index f6fb07b..b522715 100644 > --- a/emacs/notmuch.el > +++ b/emacs/notmuch.el > @@ -204,6 +204,7 @@ For a mouse binding, return nil." > =A0 =A0 (define-key map "p" 'notmuch-search-previous-thread) > =A0 =A0 (define-key map "n" 'notmuch-search-next-thread) > =A0 =A0 (define-key map "r" 'notmuch-search-reply-to-thread) > + =A0 =A0(define-key map "e" 'notmuch-search-edit) > =A0 =A0 (define-key map "m" 'notmuch-mua-new-mail) > =A0 =A0 (define-key map "s" 'notmuch-search) > =A0 =A0 (define-key map "o" 'notmuch-search-toggle-order) > @@ -449,6 +450,12 @@ Complete list of currently available key bindings: > =A0 (let ((message-id (notmuch-search-find-thread-id))) > =A0 =A0 (notmuch-mua-new-reply message-id prompt-for-sender))) > > +(defun notmuch-search-edit () > + =A0"Edit the current message as new." > + =A0(interactive) > + =A0(let ((message-id (notmuch-search-find-thread-id))) > + =A0 =A0(notmuch-mua-edit-mail message-id))) > + > =A0(defun notmuch-call-notmuch-process (&rest args) > =A0 "Synchronously invoke \"notmuch\" with the given list of arguments. > > -- > 1.7.5.4 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch >