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

diff --git a/b5/538d1d0c1a7cf09f8bca0764d04fa6f8eb9eca b/b5/538d1d0c1a7cf09f8bca0764d04fa6f8eb9eca
new file mode 100644 (file)
index 0000000..3477c15
--- /dev/null
@@ -0,0 +1,182 @@
+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 150C0431FB6\r
+       for <notmuch@notmuchmail.org>; Thu, 10 Jan 2013 03:15:01 -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 lJ3ZWrm7k-vU for <notmuch@notmuchmail.org>;\r
+       Thu, 10 Jan 2013 03:15:00 -0800 (PST)\r
+Received: from mail-wi0-f180.google.com (mail-wi0-f180.google.com\r
+       [209.85.212.180]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 45BFA431FAF\r
+       for <notmuch@notmuchmail.org>; Thu, 10 Jan 2013 03:15:00 -0800 (PST)\r
+Received: by mail-wi0-f180.google.com with SMTP id hj13so223281wib.1\r
+       for <notmuch@notmuchmail.org>; Thu, 10 Jan 2013 03:14:59 -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=JKF7yvFI/xmIdMXQyPe1C42OHjgeCGnx58ddkz2vuEM=;\r
+       b=nCGbg+Hh/E/GmezMo9asUrKNoZo2dDswymVl2Fnx5rOJIciSl6NpGXznmk0T3YDZLk\r
+       O8KYsvSCpBDPV1ZGgmG8HWXiWpRQJyWHiVAxvYG8RJf33cxDCOtWruvGNBVznnL2KNJG\r
+       rmDDj9EsANHBbPAdvDhgv76XUnHXMtWSslavw97dcyE+ILqtrLGWfUL6tybRSbDCx69S\r
+       5b7QRb+ZMt9HviEmRbt9XrAEvRU5SUqe36eq6QKhV6j/Napz0SqQjxh5EnK0kL6VdUCo\r
+       obEdyk3PeVppr/vC77O7gdIWEulCSBknpCSLFrgLEevAD4RhT86sABjs58B4g1myAX6U\r
+       rv8Q==\r
+X-Received: by 10.180.79.37 with SMTP id g5mr8511121wix.8.1357816499127;\r
+       Thu, 10 Jan 2013 03:14:59 -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 hu8sm7893443wib.6.2013.01.10.03.14.57\r
+       (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+       Thu, 10 Jan 2013 03:14:58 -0800 (PST)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH (corrected)] contrib: pick: add a target message for pick\r
+Date: Thu, 10 Jan 2013 11:14:58 +0000\r
+Message-Id: <1357816498-25085-1-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <1357814477-1348-3-git-send-email-markwalters1009@gmail.com>\r
+References: <1357814477-1348-3-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 11:15:01 -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
+The previous version had an extra ). The version I was testing had the\r
+fix but git didn't; oh well.\r
+\r
+Best wishes\r
+\r
+Mark\r
+\r
+\r
+\r
+ contrib/notmuch-pick/notmuch-pick.el |   30 +++++++++++++++++++++++-------\r
+ 1 files changed, 23 insertions(+), 7 deletions(-)\r
+\r
+diff --git a/contrib/notmuch-pick/notmuch-pick.el b/contrib/notmuch-pick/notmuch-pick.el\r
+index d597126..128fabf 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
++    (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