[PATCH 2/2] contrib: pick: add a target message for pick
authorMark Walters <markwalters1009@gmail.com>
Thu, 10 Jan 2013 10:41:17 +0000 (10:41 +0000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:53:04 +0000 (09:53 -0800)
40/1795297baabf09e2326d73f2ea5fb7ecb848c7 [new file with mode: 0644]

diff --git a/40/1795297baabf09e2326d73f2ea5fb7ecb848c7 b/40/1795297baabf09e2326d73f2ea5fb7ecb848c7
new file mode 100644 (file)
index 0000000..93dd87c
--- /dev/null
@@ -0,0 +1,172 @@
+Return-Path: <markwalters1009@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 78FB9431FBD\r
+       for <notmuch@notmuchmail.org>; Thu, 10 Jan 2013 02:41:25 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.201\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
+       RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id 8cLoO3CNwTzH for <notmuch@notmuchmail.org>;\r
+       Thu, 10 Jan 2013 02:41:24 -0800 (PST)\r
+Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com\r
+       [209.85.212.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 97A02431FAF\r
+       for <notmuch@notmuchmail.org>; Thu, 10 Jan 2013 02:41:24 -0800 (PST)\r
+Received: by mail-wi0-f181.google.com with SMTP id hq4so203671wib.14\r
+       for <notmuch@notmuchmail.org>; Thu, 10 Jan 2013 02:41:23 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+       h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to\r
+       :references; bh=LvrvUEip4q1O9HWoLdPQQOOVuyHWqOaZic2nM/V6Ft4=;\r
+       b=LVHceU7heCm4P+lwHNkhGeBfHuTjcKq2mdZHKcBALEXOYFMF/j8ESJYwVQH7A416AK\r
+       3oW9iRkoYmNzEoQ5ckzt3oFYhwuwk0o5vJnD3R66Y4SZl7rmv+LmCdyr/KxZYNPCd3ts\r
+       HOAtgbdvYVw5KFK4NOn5U9kwgp9g46Buji+lIkZ7ekivJcHvXxRLnnyBe2O8t2PL5BmS\r
+       Wks/mnJnepa2A2jFCL/kIClLDyhK4PZaO+Z7PGs9fbhidJSaaXFEwTIpDdNq49E65VnW\r
+       tkD4Zg6boOhl/l4pG8v3zWXlAwujMAqm+IItNvxMVtDX02KvDzuH+zagrXo1B3jgPANJ\r
+       8/WA==\r
+X-Received: by 10.180.97.68 with SMTP id dy4mr8333027wib.7.1357814483490;\r
+       Thu, 10 Jan 2013 02:41:23 -0800 (PST)\r
+Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
+       by mx.google.com with ESMTPS id eo10sm1672945wib.9.2013.01.10.02.41.22\r
+       (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+       Thu, 10 Jan 2013 02:41:23 -0800 (PST)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 2/2] contrib: pick: add a target message for pick\r
+Date: Thu, 10 Jan 2013 10:41:17 +0000\r
+Message-Id: <1357814477-1348-3-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <1357814477-1348-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1357814477-1348-1-git-send-email-markwalters1009@gmail.com>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Thu, 10 Jan 2013 10:41:25 -0000\r
+\r
+This adds a target message for pick which it will jump to when (if) it\r
+appears. It adds the target to notmuch-pick-from-show-current-query so\r
+that pick goes straight to the message that was current in the show\r
+view and it adds target to notmuch-pick-refresh-view so that the\r
+current message is preserved.\r
+---\r
+ contrib/notmuch-pick/notmuch-pick.el |   28 ++++++++++++++++++++++------\r
+ 1 files changed, 22 insertions(+), 6 deletions(-)\r
+\r
+diff --git a/contrib/notmuch-pick/notmuch-pick.el b/contrib/notmuch-pick/notmuch-pick.el\r
+index d597126..974223d 100644\r
+--- a/contrib/notmuch-pick/notmuch-pick.el\r
++++ b/contrib/notmuch-pick/notmuch-pick.el\r
+@@ -155,6 +155,8 @@\r
+ ;; The context of the search: i.e., useful but can be dropped.\r
+ (defvar notmuch-pick-query-context nil)\r
+ (make-variable-buffer-local 'notmuch-pick-query-context)\r
++(defvar notmuch-pick-target-msg nil)\r
++(make-variable-buffer-local 'notmuch-pick-target-msg)\r
+ (defvar notmuch-pick-buffer-name nil)\r
+ (make-variable-buffer-local 'notmuch-pick-buffer-name)\r
+ ;; This variable is the window used for the message pane. It is set\r
+@@ -328,7 +330,9 @@ Does NOT change the database."\r
+ (defun notmuch-pick-from-show-current-query ()\r
+   "Call notmuch pick with the current query"\r
+   (interactive)\r
+-  (notmuch-pick notmuch-show-thread-id notmuch-show-query-context))\r
++  (notmuch-pick notmuch-show-thread-id\r
++              notmuch-show-query-context\r
++              (notmuch-show-get-message-id)))\r
\r
+ ;; This function should be in notmuch.el but be we trying to minimise\r
+ ;; impact on the rest of the codebase.\r
+@@ -344,6 +348,7 @@ Does NOT change the database."\r
+   (interactive)\r
+   (notmuch-pick (notmuch-search-find-thread-id)\r
+                 notmuch-search-query-string\r
++              nil\r
+                 (notmuch-prettify-subject (notmuch-search-find-subject)))\r
+   (notmuch-pick-show-match-message-with-wait))\r
\r
+@@ -506,9 +511,13 @@ will be reversed."\r
+   (let ((inhibit-read-only t)\r
+       (basic-query notmuch-pick-basic-query)\r
+       (query-context notmuch-pick-query-context)\r
++      (target (notmuch-pick-get-message-id))\r
+       (buffer-name notmuch-pick-buffer-name))\r
+     (erase-buffer)\r
+-    (notmuch-pick-worker basic-query query-context (get-buffer buffer-name))))\r
++    (notmuch-pick-worker basic-query\r
++                       query-context\r
++                       target\r
++                       (get-buffer buffer-name))))\r
\r
+ (defmacro with-current-notmuch-pick-message (&rest body)\r
+   "Evaluate body with current buffer set to the text of current message"\r
+@@ -639,10 +648,16 @@ unchanged ADDRESS if parsing fails."\r
+   (insert "\n"))\r
\r
+ (defun notmuch-pick-goto-and-insert-msg (msg)\r
+-  "Insert msg at the end of the buffer."\r
++  "Insert msg at the end of the buffer. Move point to msg if it is the target"\r
+   (save-excursion\r
+     (goto-char (point-max))\r
+     (notmuch-pick-insert-msg msg)))\r
++  (let ((msg-id (notmuch-id-to-query (plist-get msg :id))))\r
++    (when (string= msg-id notmuch-pick-target-msg)\r
++      (setq notmuch-pick-target-msg "found")\r
++      (goto-char (point-max))\r
++      (forward-line -1))))\r
++\r
+ (defun notmuch-pick-insert-tree (tree depth tree-status first last)\r
+   "Insert the message tree TREE at depth DEPTH in the current thread."\r
+   (let ((msg (car tree))\r
+@@ -762,12 +777,13 @@ Complete list of currently available key bindings:\r
+                                        'notmuch-pick-show-error\r
+                                        results-buf)))))\r
\r
+-(defun notmuch-pick-worker (basic-query &optional query-context buffer)\r
++(defun notmuch-pick-worker (basic-query &optional query-context target buffer)\r
+   (interactive)\r
+   (notmuch-pick-mode)\r
+   (setq notmuch-pick-basic-query basic-query)\r
+   (setq notmuch-pick-query-context query-context)\r
+   (setq notmuch-pick-buffer-name (buffer-name buffer))\r
++  (setq notmuch-pick-target-msg target)\r
\r
+   (erase-buffer)\r
+   (goto-char (point-min))\r
+@@ -799,7 +815,7 @@ Complete list of currently available key bindings:\r
+         (insert "End of search results.\n"))))))\r
\r
\r
+-(defun notmuch-pick (&optional query query-context buffer-name show-first-match)\r
++(defun notmuch-pick (&optional query query-context target buffer-name show-first-match)\r
+   "Run notmuch pick with the given `query' and display the results"\r
+   (interactive "sNotmuch pick: ")\r
+   (if (null query)\r
+@@ -813,7 +829,7 @@ Complete list of currently available key bindings:\r
+     ;; Don't track undo information for this buffer\r
+     (set 'buffer-undo-list t)\r
\r
+-    (notmuch-pick-worker query query-context buffer)\r
++    (notmuch-pick-worker query query-context target buffer)\r
\r
+     (setq truncate-lines t)\r
+     (when show-first-match\r
+-- \r
+1.7.9.1\r
+\r