From: Mark Walters Date: Sat, 22 Feb 2014 11:25:05 +0000 (+0000) Subject: [PATCH v2.1 6/7] emacs: search: use orig-tags in search X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=6b40d10eb72ebad51f87eba3a265629b471b64d8;p=notmuch-archives.git [PATCH v2.1 6/7] emacs: search: use orig-tags in search --- diff --git a/ee/e4481ad78983524efe008f60c3cc77dfb6fbfa b/ee/e4481ad78983524efe008f60c3cc77dfb6fbfa new file mode 100644 index 000000000..a8ea610ed --- /dev/null +++ b/ee/e4481ad78983524efe008f60c3cc77dfb6fbfa @@ -0,0 +1,153 @@ +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 C95C6431FBF + for ; Sat, 22 Feb 2014 03:25:21 -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 KFdT5IXWynHc for ; + Sat, 22 Feb 2014 03:25:16 -0800 (PST) +Received: from mail-wg0-f53.google.com (mail-wg0-f53.google.com + [74.125.82.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client + certificate requested) by olra.theworths.org (Postfix) with ESMTPS id + 20DD6431FBD for ; Sat, 22 Feb 2014 03:25:16 -0800 + (PST) +Received: by mail-wg0-f53.google.com with SMTP id x12so3317506wgg.20 + for ; Sat, 22 Feb 2014 03:25:13 -0800 (PST) +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=w3T2e1yG6IDIUzmBD/4U5ebMSeYBTdQs9hy1fpFmwcE=; + b=vf6TYMHo0+c8F7JeK1LFKDbiOKYLAdd6p6mQaVsTDYBcG+jiUVMtAEn7BVFjlrxDvW + MZ8lCAvG0ccPc2SDTuPOp8g4vNpYWV1sjDKRgGkp7xf9ZfAODK3ke7Y94ruFvmnRkEpH + AkuumjEsO4LIZoySOby9mazZN2JnpcQTxPP+4wTWQCbnRPoyv78sR4ZgA/cUbKOqVdAo + yg7mBP1cSlUr7LrabX9UUV5nocGuI4WMM13Y4EFGPnFX+WQkDPzGf5TCdxbULjRsC+AD + Wf+96cNE6dq1ihcVx6l/fsGSPVjeijsWpp91UeTob3YAB3AFpB6AefS2JffWq4mUJod3 + xxvg== +X-Received: by 10.180.106.40 with SMTP id gr8mr6603601wib.31.1393068312121; + Sat, 22 Feb 2014 03:25:12 -0800 (PST) +Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) + by mx.google.com with ESMTPSA id ga20sm4020022wic.0.2014.02.22.03.25.11 + for + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Sat, 22 Feb 2014 03:25:11 -0800 (PST) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [PATCH v2.1 6/7] emacs: search: use orig-tags in search +Date: Sat, 22 Feb 2014 11:25:05 +0000 +Message-Id: <1393068305-1587-1-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 1.7.9.1 +In-Reply-To: <1392841212-8494-7-git-send-email-markwalters1009@gmail.com> +References: <1392841212-8494-7-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 Feb 2014 11:25:21 -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. +--- +This is a rewrite of this single patch. When trying to rebase my +unread stuff on top of this series I realised that the previous +version split the notmuch-search-show-result in a a strange place. In +particular the code for "is this the target thread" so should only be +called when building the buffer not when redisplaying a thread. Of +course it works either way but I think this is cleaner. + +Best wishes + +Mark + + + + + + + + emacs/notmuch.el | 41 +++++++++++++++++++++++++---------------- + 1 files changed, 25 insertions(+), 16 deletions(-) + +diff --git a/emacs/notmuch.el b/emacs/notmuch.el +index 04587c0..d1f1f0a 100644 +--- a/emacs/notmuch.el ++++ b/emacs/notmuch.el +@@ -753,24 +753,33 @@ non-authors is found, assume that all of the authors match." + 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 @@ non-authors is found, assume that all of the authors match." + (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.9.1 +