Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 106064196F2 for ; Mon, 26 Apr 2010 01:23:26 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -1.9 X-Spam-Level: X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5 tests=[BAYES_00=-1.9] autolearn=ham Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7VzZQIAoeLkH for ; Mon, 26 Apr 2010 01:23:24 -0700 (PDT) Received: from homiemail-a15.g.dreamhost.com (caiajhbdcbbj.dreamhost.com [208.97.132.119]) by olra.theworths.org (Postfix) with ESMTP id A1F8A4196F0 for ; Mon, 26 Apr 2010 01:23:24 -0700 (PDT) Received: from localhost.localdomain (mtec-hg-docking-1-dhcp-204.ethz.ch [129.132.133.204]) (Authenticated sender: sebastian@sspaeth.de) by homiemail-a15.g.dreamhost.com (Postfix) with ESMTPA id 7FDF776C065; Mon, 26 Apr 2010 01:23:23 -0700 (PDT) From: Sebastian Spaeth To: Notmuch developer list Subject: [PATCH v3 2/4] Integrate notmuch-maildir-fcc into notmuch Date: Mon, 26 Apr 2010 10:23:16 +0200 Message-Id: <1272270198-28357-2-git-send-email-Sebastian@SSpaeth.de> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: References: X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 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: Mon, 26 Apr 2010 08:23:26 -0000 Require notmuch-maildir-fcc and also install it. Rename all jkr/* functions to notmuch-maildir-fcc-* Signed-off-by: Sebastian Spaeth --- emacs/Makefile.local | 1 + emacs/notmuch-maildir-fcc.el | 42 ++++++++++++++++++++++-------------------- emacs/notmuch.el | 1 + 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/emacs/Makefile.local b/emacs/Makefile.local index 7537c3d..e446f97 100644 --- a/emacs/Makefile.local +++ b/emacs/Makefile.local @@ -9,6 +9,7 @@ emacs_sources := \ $(dir)/notmuch-wash.el \ $(dir)/notmuch-hello.el \ $(dir)/notmuch-mua.el \ + $(dir)/notmuch-maildir-fcc.el \ $(dir)/notmuch-address.el emacs_images := \ diff --git a/emacs/notmuch-maildir-fcc.el b/emacs/notmuch-maildir-fcc.el index 979428e..2117f54 100644 --- a/emacs/notmuch-maildir-fcc.el +++ b/emacs/notmuch-maildir-fcc.el @@ -28,18 +28,18 @@ ;; ;; (setq message-fcc-handler-function ;; '(lambda (destdir) -;; (jkr/maildir-write-buffer-to-maildir destdir t))) +;; (notmuch-maildir-fcc-write-buffer-to-maildir destdir t))) ;; ;; if you want Fcc'd messages to be marked as new: ;; ;; (setq message-fcc-handler-function ;; '(lambda (destdir) -;; (jkr/maildir-write-buffer-to-maildir destdir nil))) +;; (notmuch-maildir-fcc-write-buffer-to-maildir destdir nil))) -(defvar jkr/maildir-count 0) +(defvar notmuch-maildir-fcc-count 0) -(defun jkr/maildir-host-fixer (hostname) +(defun notmuch-maildir-fcc-host-fixer (hostname) (replace-regexp-in-string "/\\|:" '(lambda (s) (cond ((string-equal s "/") "\\057") @@ -49,31 +49,31 @@ t t)) -(defun jkr/maildir-make-uniq-maildir-id () +(defun notmuch-maildir-fcc-make-uniq-maildir-id () (let* ((ct (current-time)) (timeid (+ (* (car ct) 65536) (cadr ct))) (microseconds (caddr ct)) - (hostname (jkr/maildir-host-fixer system-name))) - (setq jkr/maildir-count (+ jkr/maildir-count 1)) + (hostname (notmuch-maildir-fcc-host-fixer system-name))) + (setq notmuch-maildir-fcc-count (+ notmuch-maildir-fcc-count 1)) (format "%d.%d_%d_%d.%s" timeid (emacs-pid) microseconds - jkr/maildir-count + notmuch-maildir-fcc-count hostname))) -(defun jkr/maildir-dir-is-maildir-p (dir) +(defun notmuch-maildir-fcc-dir-is-maildir-p (dir) (and (file-exists-p (concat dir "/cur/")) (file-exists-p (concat dir "/new/")) (file-exists-p (concat dir "/tmp/")))) -(defun jkr/maildir-save-buffer-to-tmp (destdir) +(defun notmuch-maildir-fcc-save-buffer-to-tmp (destdir) "Returns the msg id of the message written to the temp directory if successful, nil if not." - (let ((msg-id (jkr/maildir-make-uniq-maildir-id))) + (let ((msg-id (notmuch-maildir-fcc-make-uniq-maildir-id))) (while (file-exists-p (concat destdir "/tmp/" msg-id)) - (setq msg-id (jkr/maildir-make-uniq-maildir-id))) - (cond ((jkr/maildir-dir-is-maildir-p destdir) + (setq msg-id (notmuch-maildir-fcc-make-uniq-maildir-id))) + (cond ((notmuch-maildir-fcc-dir-is-maildir-p destdir) (write-file (concat destdir "/tmp/" msg-id)) msg-id) (t @@ -81,17 +81,17 @@ if successful, nil if not." destdir)) nil)))) -(defun jkr/maildir-move-tmp-to-new (destdir msg-id) +(defun notmuch-maildir-fcc-move-tmp-to-new (destdir msg-id) (add-name-to-file (concat destdir "/tmp/" msg-id) (concat destdir "/new/" msg-id ":2,"))) -(defun jkr/maildir-move-tmp-to-cur (destdir msg-id &optional mark-seen) +(defun notmuch-maildir-fcc-move-tmp-to-cur (destdir msg-id &optional mark-seen) (add-name-to-file (concat destdir "/tmp/" msg-id) (concat destdir "/cur/" msg-id ":2," (when mark-seen "S")))) -(defun jkr/maildir-write-buffer-to-maildir (destdir &optional mark-seen) +(defun notmuch-maildir-fcc-write-buffer-to-maildir (destdir &optional mark-seen) "Writes the current buffer to maildir destdir. If mark-seen is non-nil, it will write it to cur/, and mark it as read. It should return t if successful, and nil otherwise." @@ -99,17 +99,19 @@ return t if successful, and nil otherwise." (with-temp-buffer (insert-buffer orig-buffer) (catch 'link-error - (let ((msg-id (jkr/maildir-save-buffer-to-tmp destdir))) + (let ((msg-id (notmuch-maildir-fcc-save-buffer-to-tmp destdir))) (when msg-id (cond (mark-seen (condition-case err - (jkr/maildir-move-tmp-to-cur destdir msg-id t) + (notmuch-maildir-fcc-move-tmp-to-cur destdir msg-id t) (file-already-exists (throw 'link-error nil)))) (t (condition-case err - (jkr/maildir-move-tmp-to-new destdir msg-id) + (notmuch-maildir-fcc-move-tmp-to-new destdir msg-id) (file-already-exists (throw 'link-error nil)))))) (delete-file (concat destdir "/tmp/" msg-id)))) - t))) \ No newline at end of file + t))) + +(provide 'notmuch-maildir-fcc) diff --git a/emacs/notmuch.el b/emacs/notmuch.el index 378c004..127af2c 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -54,6 +54,7 @@ (require 'notmuch-lib) (require 'notmuch-show) (require 'notmuch-mua) +(require 'notmuch-maildir-fcc) (defcustom notmuch-search-result-format `(("date" . "%s ") -- 1.7.0.4