[PATCH 1/2] emacs: maildir fcc make insert more flexible

Mark Walters markwalters1009 at gmail.com
Mon Aug 28 00:32:21 PDT 2017


This changeset makes the function
notmuch-maildir-fcc-with-notmuch-insert slightly more flexible by
allowing some of the prompts to be controlled by the caller.
---
 emacs/notmuch-maildir-fcc.el | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/emacs/notmuch-maildir-fcc.el b/emacs/notmuch-maildir-fcc.el
index 1551e8b..acff24d 100644
--- a/emacs/notmuch-maildir-fcc.el
+++ b/emacs/notmuch-maildir-fcc.el
@@ -227,7 +227,7 @@ should be a list of tag changes to apply to the inserted message."
     (apply 'notmuch-call-notmuch-process
 	   :stdin-string (buffer-string) "insert" args)))
 
-(defun notmuch-maildir-fcc-with-notmuch-insert (fcc-header &optional create)
+(defun notmuch-maildir-fcc-with-notmuch-insert (fcc-header &optional create header-name)
   "Store message with notmuch insert.
 
 The fcc-header should be of the form \"folder +tag1 -tag2\" where
@@ -239,7 +239,8 @@ quoting each space with an immediately preceding backslash
 or surrounding the entire folder name in double quotes.
 
 If CREATE is non-nil then create the folder if necessary."
-  (let* ((args (split-string-and-unquote fcc-header))
+  (let* ((header-name (or header-name "Fcc header"))
+	 (args (split-string-and-unquote fcc-header))
 	 (folder (car args))
 	 (tags (cdr args)))
     (condition-case nil
@@ -250,14 +251,17 @@ If CREATE is non-nil then create the folder if necessary."
       ;; how to deal with it.
       (error
        (let ((response (notmuch-read-char-choice
-			"Insert failed: (r)etry, (c)reate folder, (i)gnore, or (e)dit the header? "
+			(concat
+			 "Insert failed: (r)etry, (c)reate folder, (i)gnore, or (e)dit the "
+			 header-name "? ")
 			'(?r ?c ?i ?e))))
 	 (case response
-	       (?r (notmuch-maildir-fcc-with-notmuch-insert fcc-header))
-	       (?c (notmuch-maildir-fcc-with-notmuch-insert fcc-header 't))
+	       (?r (notmuch-maildir-fcc-with-notmuch-insert fcc-header nil header-name))
+	       (?c (notmuch-maildir-fcc-with-notmuch-insert fcc-header 't header-name))
 	       (?i 't)
 	       (?e (notmuch-maildir-fcc-with-notmuch-insert
-		    (read-from-minibuffer "Fcc header: " fcc-header)))))))))
+		    (read-from-minibuffer (concat header-name ": ") fcc-header)
+		    nil header-name))))))))
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-- 
2.1.4



More information about the notmuch mailing list