]> git.notmuchmail.org Git - notmuch/commitdiff
emacs: Change FCC to be relative to notmuch mail store, not message-directory
authorCarl Worth <cworth@cworth.org>
Wed, 27 Oct 2010 23:27:43 +0000 (16:27 -0700)
committerCarl Worth <cworth@cworth.org>
Wed, 27 Oct 2010 23:27:43 +0000 (16:27 -0700)
Otherwise, FCC is too hard to use, (user must set it and also set message-
directory variable to match notmuch mail datbase path). As a rule, I'd like
for users of notmuch to not be required to muck around with non-notmuch
mail settings in emacs.

The above is only really possible now thanks to the recent addition of the
"notmuch config get" command which allows emacs to query the currently
configured notmuch database path.

This also now allows an absolute-path FCC to be set if desired.

emacs/notmuch-lib.el
emacs/notmuch-maildir-fcc.el

index f30bcb429cc2a775a98b0242b3f3f63b5a0c8ecf..91132b504169510556d0e3f90a21e202f9582c75 100644 (file)
@@ -68,6 +68,13 @@ the user hasn't set this variable with the old or new value."
        (match-string 2 long-string)
       "unknown")))
 
+(defun notmuch-database-path ()
+  "Return the database.path value from the notmuch configuration."
+  ;; Trim off the trailing newline
+  (substring (shell-command-to-string
+             (concat notmuch-command " config get database.path"))
+             0 -1))
+
 ;;
 
 ;; XXX: This should be a generic function in emacs somewhere, not
index 8bb41a89a848a598d3adee37e059dd55e49cdd5d..ba22981c20af59f58d814e0b1d1f7f2fd9f650fc 100644 (file)
@@ -18,6 +18,8 @@
 
 (require 'message)
 
+(require 'notmuch-lib)
+
 (defvar notmuch-maildir-fcc-count 0)
 
 (defcustom notmuch-fcc-dirs nil
  used. The first entry is used as a default fallback when nothing
  else matches.
 
- In all cases, the complete FCC directory will be constructed by 
- concatenating the content  of the variable 'message-directory' 
- ('~/Mail/' by default and customizable via M-x
- customize-variable<RET>message-directory<RET>) and this value.
+ In all cases, a relative FCC directory will be understood to
+ specify a directory within the notmuch mail store, (as set by
+ the database.path option in the notmuch configuration file).
 
  You will be prompted to create the directory if it does not exist yet when 
  sending a mail.
@@ -90,8 +91,9 @@
   ;; if there is no fcc header yet, add ours
   (unless (message-fetch-field "fcc")
     (message-add-header (concat "Fcc: "
-                                (file-name-as-directory message-directory)
-                                subdir)))
+                               (if (= (elt subdir 0) ?/)
+                                   subdir
+                                 (concat (notmuch-database-path) "/" subdir)))))
 
   ;; finally test if fcc points to a valid maildir
   (let ((fcc-header (message-fetch-field "fcc")))