From: Mark Walters Date: Fri, 10 Jun 2016 23:02:51 +0000 (+0100) Subject: [PATCH 5/6] Modify our local copy of message-do-fcc X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=37dc9e5a4a09e275e7d986b11493ce66c906a97d;p=notmuch-archives.git [PATCH 5/6] Modify our local copy of message-do-fcc --- diff --git a/8a/4f1b29fbafb56b750d17756d6319ba52fe8bf1 b/8a/4f1b29fbafb56b750d17756d6319ba52fe8bf1 new file mode 100644 index 000000000..708425600 --- /dev/null +++ b/8a/4f1b29fbafb56b750d17756d6319ba52fe8bf1 @@ -0,0 +1,174 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id 7C7B06DE02DB + for ; Fri, 10 Jun 2016 16:03:57 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: -0.337 +X-Spam-Level: +X-Spam-Status: No, score=-0.337 tagged_above=-999 required=5 tests=[AWL=0.233, + DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, + RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] + autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id wtglnB6TC_gw for ; + Fri, 10 Jun 2016 16:03:49 -0700 (PDT) +Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com + [74.125.82.67]) by arlo.cworth.org (Postfix) with ESMTPS id A4D1D6DE02B0 for + ; Fri, 10 Jun 2016 16:03:11 -0700 (PDT) +Received: by mail-wm0-f67.google.com with SMTP id n184so1714263wmn.1 + for ; Fri, 10 Jun 2016 16:03:11 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:cc:subject:date:message-id:in-reply-to:references; + bh=pp1RSXCfv2ceqixYzO11izXYsYYj4rhW8xqXg1BdG1E=; + b=yXqyXhsOkAD+0K9VifqfFu5f3JgvBgwIgBORmpp2Qbo2wdkW3iTXXMOecp7q0hBw4r + Iv5EO/Xup33CQWSqZtJnyJbsnnx/bHwAqmndFSF9UX1EMuElR9GqtENr1P5fTwSm9o38 + nEIGQyiNXaqZgARNwibRMT0uaE81lcB+yaff8R1ElhLYdwJUGhejE0iSAPtj+jI6mLhD + DqJVOa/2e8lP8k13SQ6MOb926dv9se7v8E2jCyc8HqwcUEWaUCnZF6pGBBT07sYgrxNw + +q38Yy/6jhgNNnK9P7L/m8Z/0yOKftknDIDKROsX7t/RnhyEMZix7CMo+Y9PDiZcfOUU + 8UUw== +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20130820; + h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to + :references; + bh=pp1RSXCfv2ceqixYzO11izXYsYYj4rhW8xqXg1BdG1E=; + b=Dqs/E7dLSJP71jQQr1hQxzG442NmovKPkUwbK4mA33ZO90Wzc1PaYci2sbVhMlkXbH + XxqgXV9pbXP29xuWs5GEirmN/EUbbgBuQ8X5V85WIvBC71/F18lVKFwg9nMCtE6YK1DW + hwgaih/1Vo6Tt5raCAdUsion/YLffa+WsY850UQ4OsdvetwzzGS+sU8E+/23f7dt3ytO + a/e+64037s7wpm5Lhe0bJP0JBC4yzMMDCHIW/GmorSfwgZEwMxyJJq43tJ+eb2xrlU/q + Yo9nUxNgcTCoOyHdn2+TLqQESbrnhOSzhPAFb35saD8wjV/eid+TwOEUao+ZippgYk9o + aeiQ== +X-Gm-Message-State: + ALyK8tL0V4OAHdR+BpaEZPMWT6x0uIJYYcYO3DDcDb0orvHkjt9ZavLDMTmuHhWJKsvW5A== +X-Received: by 10.28.4.7 with SMTP id 7mr1093599wme.77.1465599790321; + Fri, 10 Jun 2016 16:03:10 -0700 (PDT) +Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162]) + by smtp.gmail.com with ESMTPSA id s10sm14487020wjt.29.2016.06.10.16.03.09 + (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); + Fri, 10 Jun 2016 16:03:09 -0700 (PDT) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [PATCH 5/6] Modify our local copy of message-do-fcc +Date: Sat, 11 Jun 2016 00:02:51 +0100 +Message-Id: <1465599772-10297-6-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 2.1.4 +In-Reply-To: <1465599772-10297-1-git-send-email-markwalters1009@gmail.com> +References: <1465599772-10297-1-git-send-email-markwalters1009@gmail.com> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.20 +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: Fri, 10 Jun 2016 23:03:57 -0000 + +Since we also need to use this code for the draft handling we split +message-do-fcc into convenient sub-chunks (functions or macros as +appropriate). +--- + emacs/notmuch-maildir-fcc.el | 71 ++++++++++++++++++++++++++------------------ + 1 file changed, 42 insertions(+), 29 deletions(-) + +diff --git a/emacs/notmuch-maildir-fcc.el b/emacs/notmuch-maildir-fcc.el +index 7b3f232..fc645c5 100644 +--- a/emacs/notmuch-maildir-fcc.el ++++ b/emacs/notmuch-maildir-fcc.el +@@ -124,43 +124,56 @@ by notmuch-mua-mail" + ;; Functions for saving a message either using notmuch insert or file + ;; fcc. First functions common to the two cases. + ++(defmacro with-temporary-notmuch-message-buffer (&rest body) ++ "Set-up a temporary copy of the current message-mode buffer." ++ `(let ((case-fold-search t) ++ (buf (current-buffer)) ++ (mml-externalize-attachments message-fcc-externalize-attachments)) ++ (with-current-buffer (get-buffer-create " *message temp*") ++ (erase-buffer) ++ (insert-buffer-substring buf) ++ ,@body))) ++ ++(defun notmuch-maildir-setup-message-for-saving () ++ "Setup message for saving. Should be called on a temporary copy. ++ ++This is taken from the function message-do-fcc." ++ (message-encode-message-body) ++ (save-restriction ++ (message-narrow-to-headers) ++ (let ((mail-parse-charset message-default-charset) ++ (rfc2047-header-encoding-alist ++ (cons '("Newsgroups" . default) ++ rfc2047-header-encoding-alist))) ++ (mail-encode-encoded-word-buffer))) ++ (goto-char (point-min)) ++ (when (re-search-forward ++ (concat "^" (regexp-quote mail-header-separator) "$") ++ nil t) ++ (replace-match "" t t ))) ++ + (defun notmuch-maildir-message-do-fcc () + "Process Fcc headers in the current buffer. + +-This is a direct copy from message-mode's message-do-fcc." +- (let ((case-fold-search t) +- (buf (current-buffer)) +- list file +- (mml-externalize-attachments message-fcc-externalize-attachments)) ++This is a rearranged version of message mode's message-do-fcc." ++ (let (list file) + (save-excursion + (save-restriction + (message-narrow-to-headers) + (setq file (message-fetch-field "fcc" t))) + (when file +- (set-buffer (get-buffer-create " *message temp*")) +- (erase-buffer) +- (insert-buffer-substring buf) +- (message-encode-message-body) +- (save-restriction +- (message-narrow-to-headers) +- (while (setq file (message-fetch-field "fcc" t)) +- (push file list) +- (message-remove-header "fcc" nil t)) +- (let ((mail-parse-charset message-default-charset) +- (rfc2047-header-encoding-alist +- (cons '("Newsgroups" . default) +- rfc2047-header-encoding-alist))) +- (mail-encode-encoded-word-buffer))) +- (goto-char (point-min)) +- (when (re-search-forward +- (concat "^" (regexp-quote mail-header-separator) "$") +- nil t) +- (replace-match "" t t )) +- ;; Process FCC operations. +- (while list +- (setq file (pop list)) +- (notmuch-fcc-handler file)) +- (kill-buffer (current-buffer)))))) ++ (with-temporary-notmuch-message-buffer ++ (save-restriction ++ (message-narrow-to-headers) ++ (while (setq file (message-fetch-field "fcc" t)) ++ (push file list) ++ (message-remove-header "fcc" nil t))) ++ (notmuch-maildir-setup-message-for-saving) ++ ;; Process FCC operations. ++ (while list ++ (setq file (pop list)) ++ (notmuch-fcc-handler file)) ++ (kill-buffer (current-buffer))))))) + + (defun notmuch-fcc-handler (fcc-header) + "Store message with file fcc." +-- +2.1.4 +