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 12F3A404954 for ; Wed, 17 Mar 2010 03:04:37 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -2.442 X-Spam-Level: X-Spam-Status: No, score=-2.442 tagged_above=-999 required=5 tests=[AWL=0.157, BAYES_00=-2.599] autolearn=ham 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 3qJ9iIQL8wxE for ; Wed, 17 Mar 2010 03:04:36 -0700 (PDT) Received: from mail-ew0-f219.google.com (mail-ew0-f219.google.com [209.85.219.219]) by olra.theworths.org (Postfix) with ESMTP id EB15A404946 for ; Wed, 17 Mar 2010 03:04:35 -0700 (PDT) Received: by ewy19 with SMTP id 19so57801ewy.2 for ; Wed, 17 Mar 2010 03:04:35 -0700 (PDT) Received: by 10.213.37.82 with SMTP id w18mr2276707ebd.97.1268820274896; Wed, 17 Mar 2010 03:04:34 -0700 (PDT) Received: from ellen.idiomdrottning.org.handgranat.org ([83.251.93.216]) by mx.google.com with ESMTPS id 16sm3942583ewy.3.2010.03.17.03.04.33 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 17 Mar 2010 03:04:33 -0700 (PDT) Message-ID: <4ba0a931.1067f10a.15c2.5e9f@mx.google.com> Date: Wed, 17 Mar 2010 11:05:57 +0100 From: Sandra Snan To: notmuch@notmuchmail.org User-Agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.7 Emacs/23.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) References: <4b9fe142.0f67f10a.268d.0312@mx.google.com> In-Reply-To: <4b9fe142.0f67f10a.268d.0312@mx.google.com> MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [notmuch] [PATCH] To use compose-mail 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: Wed, 17 Mar 2010 10:04:37 -0000 I wrote earlier: > As I wrote in the other mail, Emacs has an interface called compose-mail = which uses whatever mailing mode that you=E2=80=99ve selected in mail-user-= agent > so if you like the message mode that=E2=80=99s been hard-coded into notmu= ch.el, (setq mail-user-agent 'message-user-agent) and this will use that. >=20 > This is a simpler patch that uses as much of the output of notmuch reply = as possible, at the expense of emacs more flexible hooks and citing. Both o= f the patches (unfortunately) still just call message-modes signature funct= ion without one of the standard hooks and wrappers, because I haven=E2=80= =99t looked into that yet. That=E2=80=99s not right, I sent the same patch twice. Here=E2=80=99s the one for just compose-mail because the other one has prob= lems with non-ascii characters. I guess I=E2=80=99d need to re-implement mo= re and more of notmuch reply in the elisp. I started doing that but I figur= e that I=E2=80=99d send these patches and see if it was something you like = at all. Signed-off-by: Sandra Snan --- emacs/notmuch.el | 61 ++++++++++++++++++++++++++++++++++++++++++--------= --- 1 files changed, 48 insertions(+), 13 deletions(-) diff --git a/emacs/notmuch.el b/emacs/notmuch.el index 117a365..baafac8 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -49,7 +49,7 @@ =20 (require 'cl) (require 'mm-view) -(require 'message) +(require 'message) ; not sure if this is needed now =20 (defvar notmuch-show-stash-map (let ((map (make-sparse-keymap))) @@ -76,7 +76,7 @@ (define-key map (kbd "M-TAB") 'notmuch-show-previous-button) (define-key map (kbd "TAB") 'notmuch-show-next-button) (define-key map "s" 'notmuch-search) - (define-key map "m" 'message-mail) + (define-key map "m" 'compose-mail) (define-key map "f" 'notmuch-show-forward-current) (define-key map "r" 'notmuch-show-reply) (define-key map "|" 'notmuch-show-pipe-message) @@ -435,16 +435,51 @@ buffer." mm-handle (> (notmuch-count-attachments mm-handle) 1)))) (message "Done")) =20 -(defun notmuch-reply (query-string) - (switch-to-buffer (generate-new-buffer "notmuch-draft")) - (call-process notmuch-command nil t nil "reply" query-string) - (message-insert-signature) + +(defun jump-to-end-of-header () + (re-search-forward "^[^:]*.: \\|^$") + (beginning-of-line) + (backward-char) + (point)) + +(defun notmuch-regex-header (re) (goto-char (point-min)) - (if (re-search-forward "^$" nil t) - (progn - (insert "--text follows this line--") - (forward-line))) - (message-mode)) + (if (re-search-forward re nil t) + (buffer-substring-no-properties (point) (jump-to-end-of-header)) + "")) + +(defun notmuch-other-headers (al) + (beginning-of-line) + (if (eq (point-at-bol) (point-at-eol)) + al + (if (re-search-forward "^[^:]*.: \\|^$" nil t) + (notmuch-other-headers + (let ((header (buffer-substring-no-properties (point-at-bol) (- (point)= 2))) + (header-value (buffer-substring-no-properties (point) (jump-to-end-of-he= ader)))) + (forward-char) + (if (or (string=3D "To" header) (string=3D "Subject" header)) + al + (acons + header + header-value + al)))) + al))) + +(defun notmuch-reply (query-string) + (with-temp-buffer + (call-process notmuch-command nil t nil "reply" query-string) + (let ((body + (progn (goto-char (point-min)) + (if (re-search-forward "^$" nil t) + (buffer-substring-no-properties (+ (point) 1) (point-max)) + "")))) + (compose-mail + (notmuch-regex-header "^To: ") + (notmuch-regex-header "^Subject: ") + (progn (goto-char (point-min)) + (notmuch-other-headers '()))) + (goto-char (point-max)) + (insert body)))) =20 (defun notmuch-show-reply () "Begin composing a reply to the current message in a new buffer." @@ -1229,7 +1264,7 @@ matching this search term are shown if non-nil. " (define-key map "p" 'notmuch-search-previous-thread) (define-key map "n" 'notmuch-search-next-thread) (define-key map "r" 'notmuch-search-reply-to-thread) - (define-key map "m" 'message-mail) + (define-key map "m" 'compose-mail) (define-key map "s" 'notmuch-search) (define-key map "o" 'notmuch-search-toggle-order) (define-key map "=3D" 'notmuch-search-refresh-view) @@ -1651,7 +1686,7 @@ current search results AND that are tagged with the g= iven tag." (define-key map "?" 'notmuch-help) (define-key map "x" 'kill-this-buffer) (define-key map "q" 'kill-this-buffer) - (define-key map "m" 'message-mail) + (define-key map "m" 'compose-mail) (define-key map "e" 'notmuch-folder-show-empty-toggle) (define-key map ">" 'notmuch-folder-last) (define-key map "<" 'notmuch-folder-first) --=20 1.7.0