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 150C0431FB6 for ; Thu, 10 Jan 2013 03:15:01 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0.201 X-Spam-Level: X-Spam-Status: No, score=0.201 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled 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 lJ3ZWrm7k-vU for ; Thu, 10 Jan 2013 03:15:00 -0800 (PST) Received: from mail-wi0-f180.google.com (mail-wi0-f180.google.com [209.85.212.180]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 45BFA431FAF for ; Thu, 10 Jan 2013 03:15:00 -0800 (PST) Received: by mail-wi0-f180.google.com with SMTP id hj13so223281wib.1 for ; Thu, 10 Jan 2013 03:14:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=JKF7yvFI/xmIdMXQyPe1C42OHjgeCGnx58ddkz2vuEM=; b=nCGbg+Hh/E/GmezMo9asUrKNoZo2dDswymVl2Fnx5rOJIciSl6NpGXznmk0T3YDZLk O8KYsvSCpBDPV1ZGgmG8HWXiWpRQJyWHiVAxvYG8RJf33cxDCOtWruvGNBVznnL2KNJG rmDDj9EsANHBbPAdvDhgv76XUnHXMtWSslavw97dcyE+ILqtrLGWfUL6tybRSbDCx69S 5b7QRb+ZMt9HviEmRbt9XrAEvRU5SUqe36eq6QKhV6j/Napz0SqQjxh5EnK0kL6VdUCo obEdyk3PeVppr/vC77O7gdIWEulCSBknpCSLFrgLEevAD4RhT86sABjs58B4g1myAX6U rv8Q== X-Received: by 10.180.79.37 with SMTP id g5mr8511121wix.8.1357816499127; Thu, 10 Jan 2013 03:14:59 -0800 (PST) Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) by mx.google.com with ESMTPS id hu8sm7893443wib.6.2013.01.10.03.14.57 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 10 Jan 2013 03:14:58 -0800 (PST) From: Mark Walters To: notmuch@notmuchmail.org Subject: [PATCH (corrected)] contrib: pick: add a target message for pick Date: Thu, 10 Jan 2013 11:14:58 +0000 Message-Id: <1357816498-25085-1-git-send-email-markwalters1009@gmail.com> X-Mailer: git-send-email 1.7.9.1 In-Reply-To: <1357814477-1348-3-git-send-email-markwalters1009@gmail.com> References: <1357814477-1348-3-git-send-email-markwalters1009@gmail.com> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 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: Thu, 10 Jan 2013 11:15:01 -0000 This adds a target message for pick which it will jump to when (if) it appears. It adds the target to notmuch-pick-from-show-current-query so that pick goes straight to the message that was current in the show view and it adds target to notmuch-pick-refresh-view so that the current message is preserved. --- The previous version had an extra ). The version I was testing had the fix but git didn't; oh well. Best wishes Mark contrib/notmuch-pick/notmuch-pick.el | 30 +++++++++++++++++++++++------- 1 files changed, 23 insertions(+), 7 deletions(-) diff --git a/contrib/notmuch-pick/notmuch-pick.el b/contrib/notmuch-pick/notmuch-pick.el index d597126..128fabf 100644 --- a/contrib/notmuch-pick/notmuch-pick.el +++ b/contrib/notmuch-pick/notmuch-pick.el @@ -155,6 +155,8 @@ ;; The context of the search: i.e., useful but can be dropped. (defvar notmuch-pick-query-context nil) (make-variable-buffer-local 'notmuch-pick-query-context) +(defvar notmuch-pick-target-msg nil) +(make-variable-buffer-local 'notmuch-pick-target-msg) (defvar notmuch-pick-buffer-name nil) (make-variable-buffer-local 'notmuch-pick-buffer-name) ;; This variable is the window used for the message pane. It is set @@ -328,7 +330,9 @@ Does NOT change the database." (defun notmuch-pick-from-show-current-query () "Call notmuch pick with the current query" (interactive) - (notmuch-pick notmuch-show-thread-id notmuch-show-query-context)) + (notmuch-pick notmuch-show-thread-id + notmuch-show-query-context + (notmuch-show-get-message-id))) ;; This function should be in notmuch.el but be we trying to minimise ;; impact on the rest of the codebase. @@ -344,6 +348,7 @@ Does NOT change the database." (interactive) (notmuch-pick (notmuch-search-find-thread-id) notmuch-search-query-string + nil (notmuch-prettify-subject (notmuch-search-find-subject))) (notmuch-pick-show-match-message-with-wait)) @@ -506,9 +511,13 @@ will be reversed." (let ((inhibit-read-only t) (basic-query notmuch-pick-basic-query) (query-context notmuch-pick-query-context) + (target (notmuch-pick-get-message-id)) (buffer-name notmuch-pick-buffer-name)) (erase-buffer) - (notmuch-pick-worker basic-query query-context (get-buffer buffer-name)))) + (notmuch-pick-worker basic-query + query-context + target + (get-buffer buffer-name)))) (defmacro with-current-notmuch-pick-message (&rest body) "Evaluate body with current buffer set to the text of current message" @@ -639,10 +648,16 @@ unchanged ADDRESS if parsing fails." (insert "\n")) (defun notmuch-pick-goto-and-insert-msg (msg) - "Insert msg at the end of the buffer." + "Insert msg at the end of the buffer. Move point to msg if it is the target" (save-excursion (goto-char (point-max)) - (notmuch-pick-insert-msg msg))) + (notmuch-pick-insert-msg msg)) + (let ((msg-id (notmuch-id-to-query (plist-get msg :id)))) + (when (string= msg-id notmuch-pick-target-msg) + (setq notmuch-pick-target-msg "found") + (goto-char (point-max)) + (forward-line -1)))) + (defun notmuch-pick-insert-tree (tree depth tree-status first last) "Insert the message tree TREE at depth DEPTH in the current thread." (let ((msg (car tree)) @@ -762,12 +777,13 @@ Complete list of currently available key bindings: 'notmuch-pick-show-error results-buf))))) -(defun notmuch-pick-worker (basic-query &optional query-context buffer) +(defun notmuch-pick-worker (basic-query &optional query-context target buffer) (interactive) (notmuch-pick-mode) (setq notmuch-pick-basic-query basic-query) (setq notmuch-pick-query-context query-context) (setq notmuch-pick-buffer-name (buffer-name buffer)) + (setq notmuch-pick-target-msg target) (erase-buffer) (goto-char (point-min)) @@ -799,7 +815,7 @@ Complete list of currently available key bindings: (insert "End of search results.\n")))))) -(defun notmuch-pick (&optional query query-context buffer-name show-first-match) +(defun notmuch-pick (&optional query query-context target buffer-name show-first-match) "Run notmuch pick with the given `query' and display the results" (interactive "sNotmuch pick: ") (if (null query) @@ -813,7 +829,7 @@ Complete list of currently available key bindings: ;; Don't track undo information for this buffer (set 'buffer-undo-list t) - (notmuch-pick-worker query query-context buffer) + (notmuch-pick-worker query query-context target buffer) (setq truncate-lines t) (when show-first-match -- 1.7.9.1