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 B333F431FD7 for ; Sat, 22 Mar 2014 04:52:09 -0700 (PDT) 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 V9476dGSHHkQ for ; Sat, 22 Mar 2014 04:52:04 -0700 (PDT) Received: from mail-wg0-f51.google.com (mail-wg0-f51.google.com [74.125.82.51]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id E9CBB431FD8 for ; Sat, 22 Mar 2014 04:51:35 -0700 (PDT) Received: by mail-wg0-f51.google.com with SMTP id k14so2302343wgh.10 for ; Sat, 22 Mar 2014 04:51:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8StI0WOLbsgAijJUdvY/LEjjbXU6v9XURzfz6y9gmpw=; b=GRrDn0tDUkGHLKAQ4qReGCZOk5rhjvBozOSTDDHyavA1QyFlHHaopDjmPsZ3I/6r/k LnmeyYtc9n+SAWw3AzBJsaKOIIyFufFcBglr0IpKPToD2v7rh9nHpGhRYNPjZJ7eAHH9 8c8meq3PZuWDGOam3tQ9wdeEKfRN5GPEFvHDgD/t+6mM3M1xQwV4Ns+pgDbggD+lLcIl O6BIh9TelmcBS4dWD/tMHi9YsBH06u/wkozQ3bSDrN315wIgVDiCKlMC/aJ0iqNc9agY Jwgt6bb+DX/K2Dypd+FO2Q7QOmvo9x+NAYwa7ScTdrzqX8aISF5mNR/IpKO8iHfKP2m4 1P+Q== X-Received: by 10.180.87.9 with SMTP id t9mr3291717wiz.36.1395489094863; Sat, 22 Mar 2014 04:51:34 -0700 (PDT) Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) by mx.google.com with ESMTPSA id 12sm16873659wjm.10.2014.03.22.04.51.33 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 22 Mar 2014 04:51:34 -0700 (PDT) From: Mark Walters To: notmuch@notmuchmail.org, amdragon@mit.edu Subject: [Patch v4 7/8] emacs: search: use orig-tags in search Date: Sat, 22 Mar 2014 11:51:11 +0000 Message-Id: <1395489072-19001-8-git-send-email-markwalters1009@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1395489072-19001-1-git-send-email-markwalters1009@gmail.com> References: <1395489072-19001-1-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: Sat, 22 Mar 2014 11:52:09 -0000 This uses the recent functionality to show the tag changes in the search buffer. Currently this is only used to show changes the search buffer makes itself: i.e., it does not make display any changes reflecting tagging done by other notmuch-buffers. --- emacs/notmuch.el | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/emacs/notmuch.el b/emacs/notmuch.el index 609f408..cb71381 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -753,24 +753,33 @@ (defun notmuch-search-insert-field (field format-string result) format-string (notmuch-sanitize (plist-get result :authors)))) ((string-equal field "tags") - (let ((tags (plist-get result :tags))) - (insert (format format-string (notmuch-tag-format-tags tags tags))))))) + (let ((tags (plist-get result :tags)) + (orig-tags (plist-get result :orig-tags))) + (insert (format format-string (notmuch-tag-format-tags tags orig-tags))))))) -(defun notmuch-search-show-result (result &optional pos) - "Insert RESULT at POS or the end of the buffer if POS is null." +(defun notmuch-search-show-result (result pos) + "Insert RESULT at POS." ;; Ignore excluded matches (unless (= (plist-get result :matched) 0) - (let ((beg (or pos (point-max)))) - (save-excursion - (goto-char beg) - (dolist (spec notmuch-search-result-format) - (notmuch-search-insert-field (car spec) (cdr spec) result)) - (insert "\n") - (notmuch-search-color-line beg (point) (plist-get result :tags)) - (put-text-property beg (point) 'notmuch-search-result result)) - (when (string= (plist-get result :thread) notmuch-search-target-thread) - (setq notmuch-search-target-thread "found") - (goto-char beg))))) + (save-excursion + (goto-char pos) + (dolist (spec notmuch-search-result-format) + (notmuch-search-insert-field (car spec) (cdr spec) result)) + (insert "\n") + (notmuch-search-color-line pos (point) (plist-get result :tags)) + (put-text-property pos (point) 'notmuch-search-result result)))) + +(defun notmuch-search-append-result (result) + "Insert RESULT at the end of the buffer. + +This is only called when a result is first inserted so it also +sets the :orig-tag property." + (let ((new-result (plist-put result :orig-tags (plist-get result :tags))) + (pos (point-max))) + (notmuch-search-show-result new-result pos) + (when (string= (plist-get result :thread) notmuch-search-target-thread) + (setq notmuch-search-target-thread "found") + (goto-char pos)))) (defun notmuch-search-process-filter (proc string) "Process and filter the output of \"notmuch search\"" @@ -784,7 +793,7 @@ (defun notmuch-search-process-filter (proc string) (save-excursion (goto-char (point-max)) (insert string)) - (notmuch-sexp-parse-partial-list 'notmuch-search-show-result + (notmuch-sexp-parse-partial-list 'notmuch-search-append-result results-buf))))) (defun notmuch-search-tag-all (tag-changes) -- 1.7.10.4