unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: david@tethera.net
To: notmuch@notmuchmail.org
Cc: David Bremner <bremner@unb.ca>
Subject: [PATCH 2/2] notmuch-show: add optional argument for query context instead of using global binding notmuch-search-query-string
Date: Fri,  4 Dec 2009 22:26:37 -0400	[thread overview]
Message-ID: <1259979997-31544-3-git-send-email-david@tethera.net> (raw)
In-Reply-To: <1259979997-31544-2-git-send-email-david@tethera.net>

From: David Bremner <bremner@unb.ca>

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

  reply	other threads:[~2009-12-05  2:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-05  2:26 Patches in support of linking from org-mode david
2009-12-05  2:26 ` [PATCH 1/2] notmuch-search-process-filter: add text properties for authors and subject to each line david
2009-12-05  2:26   ` david [this message]
2009-12-10 15:14     ` [PATCH] notmuch.el: patch notmuch-show to call notmuch show without query-context (i.e. without tag:inbox) if the first query returns nothing david
2009-12-10 18:43       ` Fix viewing of thread after accidentally archiving Carl Worth
2009-12-05 14:05 ` [PATCH] notmuch-show-get-header: new function; return alist of parsed header fields David Bremner
2010-03-09 18:20 ` Patches in support of linking from org-mode Carl Worth
2010-03-09 20:08   ` David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1259979997-31544-3-git-send-email-david@tethera.net \
    --to=david@tethera.net \
    --cc=bremner@unb.ca \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).