From 8a87406419ba95e05c51dd0fc4ecd760711f3abd Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Sat, 11 Jun 2016 00:02:49 +0100 Subject: [PATCH] [PATCH 3/6] emacs: maildir import message-do-fcc --- ba/7560db1c8ca91251f7de37cdd1b5313735dd23 | 189 ++++++++++++++++++++++ 1 file changed, 189 insertions(+) create mode 100644 ba/7560db1c8ca91251f7de37cdd1b5313735dd23 diff --git a/ba/7560db1c8ca91251f7de37cdd1b5313735dd23 b/ba/7560db1c8ca91251f7de37cdd1b5313735dd23 new file mode 100644 index 000000000..5db7e965b --- /dev/null +++ b/ba/7560db1c8ca91251f7de37cdd1b5313735dd23 @@ -0,0 +1,189 @@ +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 92C576DE0362 + for ; Fri, 10 Jun 2016 16:03:20 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: -0.336 +X-Spam-Level: +X-Spam-Status: No, score=-0.336 tagged_above=-999 required=5 tests=[AWL=0.234, + 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 DfwZuyHUjZzk for ; + Fri, 10 Jun 2016 16:03:12 -0700 (PDT) +Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com + [74.125.82.68]) by arlo.cworth.org (Postfix) with ESMTPS id 04C456DE028C for + ; Fri, 10 Jun 2016 16:03:07 -0700 (PDT) +Received: by mail-wm0-f68.google.com with SMTP id n184so1713931wmn.1 + for ; Fri, 10 Jun 2016 16:03:06 -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=H13giCxp+nFIGIfShZNMKX/UBWbQdRoglR47WE8VNgs=; + b=y6eQYfyv96WXxU6VeF7F9GiDKOV4+9b0QF4mrTTcQ0B3vCyv+FCkO+CFrIDKkf+wee + NrHBr+2ttVjLAZqCnGwaHEgKlL2LEfFI28F1lYNjI0DBRcGA30fCNFZGa2rY5WWh1Zfu + 8Q5hOVx3FujhIFMhU60BtNQrR3E//bHXvsE0m6I7pXrsI15/08eASzmuVJ8VB4Conzu+ + cIMuYekgU7+dNMr+2FRKXvvFBd6hkHrhIF8YDVEgTc/UNwmksmIaktc66Y1JoHt1xpvE + K7M2bMLSg3XCJ+DMM/cPrZWyUibl6W+gSx1XHN26lNbp0tEX4hxKmcvV+JT/SLQXXHd3 + 9oZg== +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=H13giCxp+nFIGIfShZNMKX/UBWbQdRoglR47WE8VNgs=; + b=NQ2EOeRJYq/5yUwDYylxpsS+JsAZDIQmqyzYAVHmlsnXXEtLwgiGr8ZQHkB1VScKVg + E31v+DsJbCrJrjP2U+y0efpZgiIbxbRiyNO4DagpFlI5j7dfOB14ADnX2bDb7KM4mHZy + U1lqLb1+ohLutHVqcLeEkFg6Z0YKCXmYSYUJsdypMUnyRNQCFSM6c//skkXNFXVZIWLq + qmGw4f/7Yek1La+nYMb9bDzZk5Q/3EWT7B/GrlcwL7n3RwxENAXuhtjnNHEKX9ZmzEis + kzO6N/eG3Rj5ezwrTAA3sS5TD4DlRODN9jQhCShRC+5W0jN93USxatCvkhd1vyYt62B9 + 7U3g== +X-Gm-Message-State: + ALyK8tJBY1Sw3g4etTRh38vozqKWfgm3aTy6YYXVvCG0HVL8Kf5jXMso0quIuFcfXm4QGA== +X-Received: by 10.28.209.13 with SMTP id i13mr1102929wmg.93.1465599785639; + Fri, 10 Jun 2016 16:03:05 -0700 (PDT) +Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162]) + by smtp.gmail.com with ESMTPSA id b207sm1299698wmb.0.2016.06.10.16.03.04 + (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); + Fri, 10 Jun 2016 16:03:05 -0700 (PDT) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [PATCH 3/6] emacs: maildir import message-do-fcc +Date: Sat, 11 Jun 2016 00:02:49 +0100 +Message-Id: <1465599772-10297-4-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:20 -0000 + +We will need our own local copy of message-do-fcc so this commit just +copies the code straight from message.el so that it is easier to see +our local changes coming in the next commit. +--- + emacs/notmuch-maildir-fcc.el | 64 ++++++++++++++++++++++++++++++++++++++++++++ + emacs/notmuch-mua.el | 7 +++-- + 2 files changed, 69 insertions(+), 2 deletions(-) + +diff --git a/emacs/notmuch-maildir-fcc.el b/emacs/notmuch-maildir-fcc.el +index 835258f..6fed11f 100644 +--- a/emacs/notmuch-maildir-fcc.el ++++ b/emacs/notmuch-maildir-fcc.el +@@ -120,6 +120,70 @@ by notmuch-mua-mail" + subdir + (concat (notmuch-database-path) "/" subdir)))))) + ++;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ++;; Functions for saving a message either using notmuch insert or file ++;; fcc. First functions common to the two cases. ++ ++(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)) ++ (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)) ++ (if (string-match "^[ \t]*|[ \t]*\\(.*\\)[ \t]*$" file) ++ ;; Pipe the article to the program in question. ++ (call-process-region (point-min) (point-max) shell-file-name ++ nil nil nil shell-command-switch ++ (match-string 1 file)) ++ ;; Save the article. ++ (setq file (expand-file-name file)) ++ (unless (file-exists-p (file-name-directory file)) ++ (make-directory (file-name-directory file) t)) ++ (if (and message-fcc-handler-function ++ (not (eq message-fcc-handler-function 'rmail-output))) ++ (funcall message-fcc-handler-function file) ++ ;; FIXME this option, rmail-output (also used if ++ ;; message-fcc-handler-function is nil) is not ++ ;; documented anywhere AFAICS. It should work in Emacs ++ ;; 23; I suspect it does not work in Emacs 22. ++ ;; FIXME I don't see the need for the two different cases here. ++ ;; mail-use-rfc822 makes no difference (in Emacs 23),and ++ ;; the third argument just controls \"Wrote file\" message. ++ (if (and (file-readable-p file) (mail-file-babyl-p file)) ++ (rmail-output file 1 nil t) ++ (let ((mail-use-rfc822 t)) ++ (rmail-output file 1 t t)))))) ++ (kill-buffer (current-buffer)))))) ++ + (defun notmuch-fcc-handler (fcc-header) + "Store message with file fcc." + (notmuch-maildir-fcc-file-fcc fcc-header)) +diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el +index 1ca8056..3c1c046 100644 +--- a/emacs/notmuch-mua.el ++++ b/emacs/notmuch-mua.el +@@ -33,6 +33,7 @@ + (declare-function notmuch-show-insert-body "notmuch-show" (msg body depth)) + (declare-function notmuch-fcc-header-setup "notmuch-maildir-fcc" ()) + (declare-function notmuch-fcc-handler "notmuch-maildir-fcc" (destdir)) ++(declare-function notmuch-maildir-message-do-fcc "notmuch-maildir-fcc" ()) + + ;; + +@@ -491,12 +492,14 @@ will be addressed to all recipients of the source message." + (defun notmuch-mua-send-and-exit (&optional arg) + (interactive "P") + (let ((message-fcc-handler-function #'notmuch-fcc-handler)) +- (message-send-and-exit arg))) ++ (letf (((symbol-function 'message-do-fcc) #'notmuch-maildir-message-do-fcc)) ++ (message-send-and-exit arg)))) + + (defun notmuch-mua-send (&optional arg) + (interactive "P") + (let ((message-fcc-handler-function #'notmuch-fcc-handler)) +- (message-send arg))) ++ (letf (((symbol-function 'message-do-fcc) #'notmuch-maildir-message-do-fcc)) ++ (message-send arg)))) + + (defun notmuch-mua-kill-buffer () + (interactive) +-- +2.1.4 + -- 2.26.2