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 4E15C431FBC for ; Sun, 13 Dec 2009 03:53:44 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org 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 7WhH498xE4P2 for ; Sun, 13 Dec 2009 03:53:43 -0800 (PST) Received: from smtp5-g21.free.fr (smtp5-g21.free.fr [212.27.42.5]) by olra.theworths.org (Postfix) with ESMTP id 644C4431FAE for ; Sun, 13 Dec 2009 03:53:41 -0800 (PST) Received: from smtp5-g21.free.fr (localhost [127.0.0.1]) by smtp5-g21.free.fr (Postfix) with ESMTP id 50674D4801C for ; Sun, 13 Dec 2009 12:53:35 +0100 (CET) Received: from racin (vbo91-2-82-239-207-166.fbx.proxad.net [82.239.207.166]) by smtp5-g21.free.fr (Postfix) with ESMTP id 4BE58D480CD for ; Sun, 13 Dec 2009 12:53:33 +0100 (CET) From: Matthieu Lemerre To: notmuch@notmuchmail.org Date: Sun, 13 Dec 2009 12:54:09 +0100 Message-ID: <87y6l7144e.fsf@free.fr> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Mailman-Approved-At: Sun, 13 Dec 2009 14:31:49 -0800 Subject: [notmuch] [PATCH] Support for deletion (patch included) X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.12 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: Sun, 13 Dec 2009 11:53:44 -0000 --=-=-= I forgot the attachment.. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=notmuch-deletion.patch diff --git a/notmuch.el b/notmuch.el index 97914f2..f770dd0 100644 --- a/notmuch.el +++ b/notmuch.el @@ -991,6 +991,7 @@ matching this search term are shown if non-nil. " (define-key map [mouse-1] 'notmuch-search-show-thread) (define-key map "*" 'notmuch-search-operate-all) (define-key map "a" 'notmuch-search-archive-thread) + (define-key map "d" 'notmuch-search-mark-as-deleted) (define-key map "-" 'notmuch-search-remove-tag) (define-key map "+" 'notmuch-search-add-tag) (define-key map (kbd "RET") 'notmuch-search-show-thread) @@ -999,6 +1000,7 @@ matching this search term are shown if non-nil. " (fset 'notmuch-search-mode-map notmuch-search-mode-map) (defvar notmuch-search-query-string) +(defvar notmuch-search-history nil) (defvar notmuch-search-oldest-first t "Show the oldest mail first in the search-mode") @@ -1210,6 +1212,15 @@ This function advances the next thread when finished." (notmuch-search-remove-tag "inbox") (forward-line)) + +(defun notmuch-search-mark-as-deleted () + "Mark the currently selected thread as deleted (set its \"deleted\" tag). +This function advances the next thread when finished." + (interactive) + (notmuch-search-add-tag "deleted") + (forward-line)) + + (defun notmuch-search-process-sentinel (proc msg) "Add a message to let user know when \"notmuch search\" exits" (let ((buffer (process-buffer proc)) @@ -1284,10 +1295,22 @@ characters as well as `_.+-'. (append action-split (list notmuch-search-query-string) nil)))) ;;;###autoload -(defun notmuch-search (query &optional oldest-first) - "Run \"notmuch search\" with the given query string and display results." - (interactive "sNotmuch search: ") - (let ((buffer (get-buffer-create (concat "*notmuch-search-" query "*")))) +(defun notmuch-search (query &optional oldest-first include-deleted) + "Run \"notmuch search\" with the given query string and display results. + +With prefix argument, include deleted items. +" + (interactive (let* ((prefix current-prefix-arg) + (query (if prefix + (read-string "Notmuch search (including deleted): " + notmuch-search-query-string + 'notmuch-search-history) + (read-string "Notmuch search: " nil + 'notmuch-search-history)))) + (list query nil prefix))) + (let ((real-query (if include-deleted query + (concat "not tag:deleted and (" query ")"))) + (buffer (get-buffer-create (concat "*notmuch-search-" query "*")))) (switch-to-buffer buffer) (notmuch-search-mode) (set 'notmuch-search-query-string query) @@ -1303,7 +1326,7 @@ characters as well as `_.+-'. (let ((proc (start-process-shell-command "notmuch-search" buffer notmuch-command "search" (if oldest-first "--sort=oldest-first" "--sort=newest-first") - (shell-quote-argument query)))) + (shell-quote-argument real-query)))) (set-process-sentinel proc 'notmuch-search-process-sentinel) (set-process-filter proc 'notmuch-search-process-filter)))) (run-hooks 'notmuch-search-hook))) @@ -1351,7 +1374,6 @@ search." Runs a new search matching only messages that match both the current search results AND the additional query string provided." - (interactive "sFilter search: ") (let ((grouped-query (if (string-match-p notmuch-search-disjunctive-regexp query) (concat "( " query " )") query))) (notmuch-search (concat notmuch-search-query-string " and " grouped-query) notmuch-search-oldest-first))) @@ -1391,7 +1413,9 @@ current search results AND that are tagged with the given tag." (fset 'notmuch-folder-mode-map notmuch-folder-mode-map) -(defcustom notmuch-folders (quote (("inbox" . "tag:inbox") ("unread" . "tag:unread"))) +(defcustom notmuch-folders (quote (("inbox" . "tag:inbox") + ("unread" . "tag:unread") + ("deleted" . "tag:deleted"))) "List of searches for the notmuch folder view" :type '(alist :key-type (string) :value-type (string)) :group 'notmuch) --=-=-=--