From b07c76ac3c78fda4e3581965a8b2a9e57cdb29e4 Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Tue, 22 Apr 2014 21:11:49 +0100 Subject: [PATCH] [WIP PATCH 3/4] emacs: search: split foreach-result into list and region variants --- 64/332feb2f6933d64683c3fab0a89ebaaa467fe1 | 109 ++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 64/332feb2f6933d64683c3fab0a89ebaaa467fe1 diff --git a/64/332feb2f6933d64683c3fab0a89ebaaa467fe1 b/64/332feb2f6933d64683c3fab0a89ebaaa467fe1 new file mode 100644 index 000000000..f73353f34 --- /dev/null +++ b/64/332feb2f6933d64683c3fab0a89ebaaa467fe1 @@ -0,0 +1,109 @@ +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 28D8B431FCB + for ; Tue, 22 Apr 2014 13:12:14 -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 448xH2R6yVh3 for ; + Tue, 22 Apr 2014 13:12:12 -0700 (PDT) +Received: from mail-wi0-f173.google.com (mail-wi0-f173.google.com + [209.85.212.173]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 95338431FC2 + for ; Tue, 22 Apr 2014 13:12:10 -0700 (PDT) +Received: by mail-wi0-f173.google.com with SMTP id z2so3903894wiv.0 + for ; Tue, 22 Apr 2014 13:12:09 -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=tcWOUiPa0t2iWTfMBp54srjI2fxmmQmzNUsJzEJmKmw=; + b=FueXz3sSMvipKnaK9NLMoYOPFNXqXsyD6oL4ToLRo8BzXDSSXy4asfNXlZLNgzf9nu + TwiyGh3XIjlvixZSrhPIS3LEuHuWyGIY5kpoHVw1uvoUEmRQSsLitxWo4ijzzRNNPEhR + 333i0sE1c1DwK73BilBDV/WTfIvrDujExXABHo4736qc/Ad3ysN3iTYz1AelVk7D3RGJ + or2ofANyq4r4T4bC1UXo8ZmdwpdI1OS4XMOZlsxHK0ZuKtSDVCGdXLfQo8ReVcn2aZo3 + wDj6vijFekZ52wOAWpueXXWDGivvizEd+LkRx+jC8AppGPd85LrNOemy9SthSwQU+ciu + sSBA== +X-Received: by 10.194.59.43 with SMTP id w11mr4049809wjq.65.1398197529549; + Tue, 22 Apr 2014 13:12:09 -0700 (PDT) +Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162]) + by mx.google.com with ESMTPSA id jd2sm24558632wic.9.2014.04.22.13.12.08 + for + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Tue, 22 Apr 2014 13:12:09 -0700 (PDT) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [WIP PATCH 3/4] emacs: search: split foreach-result into list and + region variants +Date: Tue, 22 Apr 2014 21:11:49 +0100 +Message-Id: <1398197510-28224-4-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 1.7.10.4 +In-Reply-To: <1398197510-28224-1-git-send-email-markwalters1009@gmail.com> +References: <1398197510-28224-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: Tue, 22 Apr 2014 20:12:14 -0000 + +--- + emacs/notmuch.el | 20 +++++++++++++++++++- + 1 file changed, 19 insertions(+), 1 deletion(-) + +diff --git a/emacs/notmuch.el b/emacs/notmuch.el +index 7b06458..e1ece47 100644 +--- a/emacs/notmuch.el ++++ b/emacs/notmuch.el +@@ -380,7 +380,20 @@ (defun notmuch-search-result-end (&optional pos) + (next-single-property-change (or pos (point)) 'notmuch-search-result + nil (point-max)))) + +-(defun notmuch-search-foreach-result (beg end thread-list function) ++(defun notmuch-search-foreach-result-in-list (thread-list function) ++ "Invoke function for each thread in list." ++ (lexical-let ((thread-list (copy-sequence thread-list))) ++ (save-excursion ++ (goto-char (point-min)) ++ (while (and (notmuch-search-get-result) ++ thread-list) ++ (let ((thread (notmuch-search-find-thread-id))) ++ (when (member thread thread-list) ++ (funcall function) ++ (setq thread-list (delete thread thread-list)))) ++ (notmuch-search-next-thread))))) ++ ++(defun notmuch-search-foreach-result-in-region (beg end function) + "Invoke FUNCTION for each result between BEG and END. + + FUNCTION should take no arguments. It will be applied at the +@@ -401,6 +414,11 @@ (defun notmuch-search-foreach-result (beg end thread-list function) + (funcall function) + (notmuch-search-next-thread)))))) + ++(defun notmuch-search-foreach-result (beg end thread-list function) ++ (if thread-list ++ (notmuch-search-foreach-result-in-list thread-list function) ++ (notmuch-search-foreach-result-in-region beg end function))) ++ + ;; Unindent the function argument of notmuch-search-foreach-result so + ;; the indentation of callers doesn't get out of hand. + (put 'notmuch-search-foreach-result 'lisp-indent-function 2) +-- +1.7.10.4 + -- 2.26.2