]> git.notmuchmail.org Git - notmuch/blobdiff - emacs/notmuch-maildir-fcc.el
emacs: Use `cl-lib' instead of deprecated `cl'
[notmuch] / emacs / notmuch-maildir-fcc.el
index 95e565033c050d9e436cbcaaf3cccb6038506219..b9cca5431f741cdbc1cb182192a0a36820a81366 100644 (file)
@@ -22,7 +22,8 @@
 
 ;;; Code:
 
-(eval-when-compile (require 'cl))
+(eval-when-compile (require 'cl-lib))
+
 (require 'message)
 
 (require 'notmuch-lib)
@@ -54,7 +55,10 @@ If `notmuch-maildir-use-notmuch-insert' is set (the default) then
 the header should be of the form \"folder +tag1 -tag2\" where
 folder is the folder (relative to the notmuch mailstore) to store
 the message in, and tag1 and tag2 are tag changes to apply to the
-stored message.
+stored message. This string is split using `split-string-and-unquote',
+so a folder name containing spaces can be specified by
+quoting each space with an immediately preceding backslash
+or surrounding the entire folder name in double quotes.
 
 If `notmuch-maildir-use-notmuch-insert' is nil then the Fcc
 header should be the directory where the message should be
@@ -166,8 +170,7 @@ 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))
-      (mail-encode-encoded-word-buffer)))
+    (mail-encode-encoded-word-buffer))
   (goto-char (point-min))
   (when (re-search-forward
         (concat "^" (regexp-quote mail-header-separator) "$")
@@ -230,8 +233,12 @@ should be a list of tag changes to apply to the inserted message."
 The fcc-header should be of the form \"folder +tag1 -tag2\" where
 folder is the folder (relative to the notmuch mailstore) to store
 the message in, and tag1 and tag2 are tag changes to apply to the
-stored message. If CREATE is non-nil then create the folder if
-necessary."
+stored message. This string is split using `split-string-and-unquote',
+so a folder name containing spaces can be specified by
+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))
         (folder (car args))
         (tags (cdr args)))
@@ -242,15 +249,15 @@ necessary."
       ;; typo, or just the user want a new folder, let the user decide
       ;; how to deal with it.
       (error
-       (let ((response (read-char-choice
-                       "Insert failed: (r)etry, (c)reate folder, (i)gnore, or  (e)dit the header? "
+       (let ((response (notmuch-read-char-choice
+                       "Insert failed: (r)etry, (c)reate folder, (i)gnore, or (e)dit the header? "
                        '(?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))
-              (?i 't)
-              (?e (notmuch-maildir-fcc-with-notmuch-insert
-                   (read-from-minibuffer "Fcc header: " fcc-header)))))))))
+        (cl-case response
+          (?r (notmuch-maildir-fcc-with-notmuch-insert fcc-header))
+          (?c (notmuch-maildir-fcc-with-notmuch-insert fcc-header 't))
+          (?i 't)
+          (?e (notmuch-maildir-fcc-with-notmuch-insert
+               (read-from-minibuffer "Fcc header: " fcc-header)))))))))
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -269,7 +276,7 @@ necessary."
 (defun notmuch-maildir-fcc-make-uniq-maildir-id ()
    (let* ((ftime (float-time))
          (microseconds (mod (* 1000000 ftime) 1000000))
-         (hostname (notmuch-maildir-fcc-host-fixer system-name)))
+         (hostname (notmuch-maildir-fcc-host-fixer (system-name))))
      (setq notmuch-maildir-fcc-count (+ notmuch-maildir-fcc-count 1))
      (format "%d.%d_%d_%d.%s"
             ftime
@@ -328,17 +335,17 @@ if needed."
     ;; fix it in some way.
     (let* ((prompt (format "Fcc %s is not a maildir: (r)etry, (c)reate folder, (i)gnore, or  (e)dit the header? "
                           fcc-header))
-           (response (read-char-choice prompt '(?r ?c ?i ?e))))
-        (case response
-              (?r (notmuch-maildir-fcc-file-fcc fcc-header))
-              (?c (if (file-writable-p fcc-header)
-                      (notmuch-maildir-fcc-create-maildir fcc-header)
-                    (message "No permission to create %s." fcc-header)
-                    (sit-for 2))
-                  (notmuch-maildir-fcc-file-fcc fcc-header))
-              (?i 't)
-              (?e (notmuch-maildir-fcc-file-fcc
-                   (read-from-minibuffer "Fcc header: " fcc-header)))))))
+           (response (notmuch-read-char-choice prompt '(?r ?c ?i ?e))))
+        (cl-case response
+          (?r (notmuch-maildir-fcc-file-fcc fcc-header))
+          (?c (if (file-writable-p fcc-header)
+                  (notmuch-maildir-fcc-create-maildir fcc-header)
+                (message "No permission to create %s." fcc-header)
+                (sit-for 2))
+              (notmuch-maildir-fcc-file-fcc fcc-header))
+          (?i 't)
+          (?e (notmuch-maildir-fcc-file-fcc
+               (read-from-minibuffer "Fcc header: " fcc-header)))))))
 
 (defun notmuch-maildir-fcc-write-buffer-to-maildir (destdir &optional mark-seen)
   "Writes the current buffer to maildir destdir. If mark-seen is