[notmuch] [PATCH] To use compose-mail
authorSandra Snan <sandra.snan@handgranat.org>
Tue, 16 Mar 2010 19:52:53 +0000 (20:52 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:36:23 +0000 (09:36 -0800)
b9/c15fe6ef45c105b7487e14063f7ed27336bd02 [new file with mode: 0644]

diff --git a/b9/c15fe6ef45c105b7487e14063f7ed27336bd02 b/b9/c15fe6ef45c105b7487e14063f7ed27336bd02
new file mode 100644 (file)
index 0000000..81a3c04
--- /dev/null
@@ -0,0 +1,186 @@
+Return-Path: <sandra.snan@handgranat.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id B68D7404947\r
+       for <notmuch@notmuchmail.org>; Tue, 16 Mar 2010 12:51:33 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -2.395\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-2.395 tagged_above=-999 required=5 tests=[AWL=0.204,\r
+       BAYES_00=-2.599] autolearn=ham\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id ZU5sqXHv3VNJ for <notmuch@notmuchmail.org>;\r
+       Tue, 16 Mar 2010 12:51:32 -0700 (PDT)\r
+Received: from mail-ww0-f53.google.com (mail-ww0-f53.google.com\r
+ [74.125.82.53])       by olra.theworths.org (Postfix) with ESMTP id 364AD404946       for\r
+ <notmuch@notmuchmail.org>; Tue, 16 Mar 2010 12:51:32 -0700 (PDT)\r
+Received: by wwi17 with SMTP id 17so229073wwi.26\r
+       for <notmuch@notmuchmail.org>; Tue, 16 Mar 2010 12:51:31 -0700 (PDT)\r
+Received: by 10.216.86.19 with SMTP id v19mr3860wee.236.1268769090810;\r
+       Tue, 16 Mar 2010 12:51:30 -0700 (PDT)\r
+Received: from ellen.idiomdrottning.org.handgranat.org\r
+       (c83-251-93-216.bredband.comhem.se [83.251.93.216])\r
+       by mx.google.com with ESMTPS id 15sm20721ewy.4.2010.03.16.12.51.30\r
+       (version=TLSv1/SSLv3 cipher=RC4-MD5);\r
+       Tue, 16 Mar 2010 12:51:30 -0700 (PDT)\r
+Message-ID: <4b9fe142.0f67f10a.268d.0312@mx.google.com>\r
+Date: Tue, 16 Mar 2010 20:52:53 +0100\r
+From: Sandra Snan <sandra.snan@handgranat.org>\r
+To: notmuch@notmuchmail.org\r
+User-Agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.9\r
+       (=?UTF-8?B?R29qxY0=?=) APEL/10.7 Emacs/23.1 (x86_64-pc-linux-gnu)\r
+       MULE/6.0 (HANACHIRUSATO)\r
+MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka")\r
+Content-Type: text/plain; charset=UTF-8\r
+Content-Transfer-Encoding: quoted-printable\r
+Subject: [notmuch] [PATCH] To use compose-mail\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Tue, 16 Mar 2010 19:51:33 -0000\r
+\r
+As I wrote in the other mail, Emacs has an interface called compose-mail wh=\r
+ich uses whatever mailing mode that you=E2=80=99ve selected in mail-user-ag=\r
+ent\r
+so if you like the message mode that=E2=80=99s been hard-coded into notmuch=\r
+.el, (setq mail-user-agent 'message-user-agent) and this will use that.\r
+\r
+This is a simpler patch that uses as much of the output of notmuch reply as=\r
+ possible, at the expense of emacs more flexible hooks and citing. Both of =\r
+the patches (unfortunately) still just call message-modes signature functio=\r
+n without one of the standard hooks and wrappers, because I haven=E2=80=99t=\r
+ looked into that yet.\r
+\r
+Sandra\r
+\r
+Signed-off-by: Sandra Snan <sandra.snan@handgranat.org>\r
+---\r
+ emacs/notmuch.el |   66 +++++++++++++++++++++++++++++++++++++++++++-------=\r
+---\r
+ 1 files changed, 53 insertions(+), 13 deletions(-)\r
+\r
+diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+index 117a365..68e2d43 100644\r
+--- a/emacs/notmuch.el\r
++++ b/emacs/notmuch.el\r
+@@ -49,7 +49,7 @@\r
+=20\r
+ (require 'cl)\r
+ (require 'mm-view)\r
+-(require 'message)\r
++(require 'message) ; not sure if this is needed now\r
+=20\r
+ (defvar notmuch-show-stash-map\r
+   (let ((map (make-sparse-keymap)))\r
+@@ -76,7 +76,7 @@\r
+     (define-key map (kbd "M-TAB") 'notmuch-show-previous-button)\r
+     (define-key map (kbd "TAB") 'notmuch-show-next-button)\r
+     (define-key map "s" 'notmuch-search)\r
+-    (define-key map "m" 'message-mail)\r
++    (define-key map "m" 'compose-mail)\r
+     (define-key map "f" 'notmuch-show-forward-current)\r
+     (define-key map "r" 'notmuch-show-reply)\r
+     (define-key map "|" 'notmuch-show-pipe-message)\r
+@@ -435,16 +435,56 @@ buffer."\r
+       mm-handle (> (notmuch-count-attachments mm-handle) 1))))\r
+   (message "Done"))\r
+=20\r
+-(defun notmuch-reply (query-string)\r
+-  (switch-to-buffer (generate-new-buffer "notmuch-draft"))\r
+-  (call-process notmuch-command nil t nil "reply" query-string)\r
+-  (message-insert-signature)\r
++\r
++(defun jump-to-end-of-header ()\r
++  (re-search-forward "^[^:]*.: \\|^$")\r
++  (beginning-of-line)\r
++  (backward-char)\r
++  (point))\r
++\r
++(defun notmuch-regex-header (re)\r
+   (goto-char (point-min))\r
+-  (if (re-search-forward "^$" nil t)\r
+-      (progn\r
+-      (insert "--text follows this line--")\r
+-      (forward-line)))\r
+-  (message-mode))\r
++  (if (re-search-forward re nil t)\r
++      (buffer-substring-no-properties (point) (jump-to-end-of-header))\r
++    ""))\r
++\r
++(defun notmuch-other-headers (al)\r
++  (beginning-of-line)\r
++  (if (eq (point-at-bol) (point-at-eol))\r
++      al\r
++    (if (re-search-forward "^[^:]*.: \\|^$" nil t)\r
++      (notmuch-other-headers\r
++        (let ((header (buffer-substring-no-properties (point-at-bol) (- (point)=\r
+ 2)))\r
++              (header-value (buffer-substring-no-properties (point) (jump-to-end-of-he=\r
+ader))))\r
++          (forward-char)\r
++          (if (or (string=3D "To" header) (string=3D "Subject" header))\r
++              al\r
++            (acons\r
++             header\r
++             header-value\r
++             al))))\r
++      al)))\r
++\r
++(defun notmuch-reply (query-string)\r
++  (let ((body\r
++       (save-excursion\r
++         (let ((filename (notmuch-show-get-filename)))\r
++           (with-temp-buffer\r
++             (insert-file-contents filename)\r
++             (set-mark (point-max))\r
++             (goto-char (point-min))\r
++             (run-hooks 'mail-citation-hook)\r
++             (message-insert-signature) ;; FIXME is there a standard hook for s=\r
+ignatures, too?\r
++             (buffer-substring (point-min) (point-max)))))))\r
++    (with-temp-buffer\r
++      (call-process notmuch-command nil t nil "reply" query-string)\r
++      (compose-mail\r
++       (notmuch-regex-header "^To: ")\r
++       (notmuch-regex-header "^Subject: ")\r
++       (progn (goto-char (point-min))\r
++            (notmuch-other-headers '())))\r
++      (goto-char (point-max))\r
++      (insert body))))\r
+=20\r
+ (defun notmuch-show-reply ()\r
+   "Begin composing a reply to the current message in a new buffer."\r
+@@ -1229,7 +1269,7 @@ matching this search term are shown if non-nil. "\r
+     (define-key map "p" 'notmuch-search-previous-thread)\r
+     (define-key map "n" 'notmuch-search-next-thread)\r
+     (define-key map "r" 'notmuch-search-reply-to-thread)\r
+-    (define-key map "m" 'message-mail)\r
++    (define-key map "m" 'compose-mail)\r
+     (define-key map "s" 'notmuch-search)\r
+     (define-key map "o" 'notmuch-search-toggle-order)\r
+     (define-key map "=3D" 'notmuch-search-refresh-view)\r
+@@ -1651,7 +1691,7 @@ current search results AND that are tagged with the g=\r
+iven tag."\r
+     (define-key map "?" 'notmuch-help)\r
+     (define-key map "x" 'kill-this-buffer)\r
+     (define-key map "q" 'kill-this-buffer)\r
+-    (define-key map "m" 'message-mail)\r
++    (define-key map "m" 'compose-mail)\r
+     (define-key map "e" 'notmuch-folder-show-empty-toggle)\r
+     (define-key map ">" 'notmuch-folder-last)\r
+     (define-key map "<" 'notmuch-folder-first)\r
+--=20\r
+1.7.0\r
+\r