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 9313D431FAE for ; Fri, 4 Dec 2009 18:26:59 -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 jK+er6KzC7TV for ; Fri, 4 Dec 2009 18:26:58 -0800 (PST) Received: from pivot.cs.unb.ca (pivot.cs.unb.ca [131.202.240.57]) by olra.theworths.org (Postfix) with ESMTP id 430DA431FC7 for ; Fri, 4 Dec 2009 18:26:57 -0800 (PST) Received: from fctnnbsc30w-142167182194.pppoe-dynamic.high-speed.nb.bellaliant.net ([142.167.182.194] helo=localhost) by pivot.cs.unb.ca with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1NGkMK-0000bN-Q5; Fri, 04 Dec 2009 22:26:56 -0400 Received: from bremner by localhost with local (Exim 4.69) (envelope-from ) id 1NGkMF-0008FI-3A; Fri, 04 Dec 2009 22:26:51 -0400 From: david@tethera.net To: notmuch@notmuchmail.org Date: Fri, 4 Dec 2009 22:26:37 -0400 Message-Id: <1259979997-31544-3-git-send-email-david@tethera.net> X-Mailer: git-send-email 1.6.5.3 In-Reply-To: <1259979997-31544-2-git-send-email-david@tethera.net> References: <1259979997-31544-1-git-send-email-david@tethera.net> <1259979997-31544-2-git-send-email-david@tethera.net> X-Sender-Verified: bremner@pivot.cs.unb.ca Cc: David Bremner Subject: [notmuch] [PATCH 2/2] notmuch-show: add optional argument for query context instead of using global binding notmuch-search-query-string 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: Sat, 05 Dec 2009 02:26:59 -0000 From: David Bremner Also modify the one call to notmuch-show in notmuch.el. This makes the call (notmuch-show thread-id) will work when there is no binding for notmuch-search-query-string; e.g. when called from user code outside notmuch. --- notmuch.el | 16 ++++++++++------ 1 files changed, 10 insertions(+), 6 deletions(-) diff --git a/notmuch.el b/notmuch.el index 5925907..f7048d5 100644 --- a/notmuch.el +++ b/notmuch.el @@ -949,15 +949,17 @@ All currently available key bindings: (lambda() (hl-line-mode 1) )) -(defun notmuch-show (thread-id &optional parent-buffer) +(defun notmuch-show (thread-id &optional parent-buffer query-context) "Run \"notmuch show\" with the given thread ID and display results. The optional PARENT-BUFFER is the notmuch-search buffer from which this notmuch-show command was executed, (so that the next -thread from that buffer can be show when done with this one)." +thread from that buffer can be show when done with this one). + +The optional QUERY-CONTEXT is a notmuch search term. Only messages from the thread +matching this search term are shown if non-nil. " (interactive "sNotmuch show: ") - (let ((query notmuch-search-query-string) - (buffer (get-buffer-create (concat "*notmuch-show-" thread-id "*")))) + (let ((buffer (get-buffer-create (concat "*notmuch-show-" thread-id "*")))) (switch-to-buffer buffer) (notmuch-show-mode) (set (make-local-variable 'notmuch-show-parent-buffer) parent-buffer) @@ -969,7 +971,9 @@ thread from that buffer can be show when done with this one)." (erase-buffer) (goto-char (point-min)) (save-excursion - (call-process notmuch-command nil t nil "show" "--entire-thread" thread-id "and (" query ")") + (let* ((basic-args (list notmuch-command nil t nil "show" "--entire-thread" thread-id)) + (args (if query-context (append basic-args (list "and (" query-context ")")) basic-args))) + (apply 'call-process args)) (notmuch-show-markup-messages) ) (run-hooks 'notmuch-show-hook) @@ -1146,7 +1150,7 @@ Complete list of currently available key bindings: (interactive) (let ((thread-id (notmuch-search-find-thread-id))) (if (> (length thread-id) 0) - (notmuch-show thread-id (current-buffer)) + (notmuch-show thread-id (current-buffer) notmuch-search-query-string) (error "End of search results")))) (defun notmuch-search-reply-to-thread () -- 1.6.5.3