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 036AF431FB6 for ; Mon, 3 Sep 2012 05:06:34 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[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 2GGhXhd+jGJZ for ; Mon, 3 Sep 2012 05:06:33 -0700 (PDT) Received: from mail-vb0-f53.google.com (mail-vb0-f53.google.com [209.85.212.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 6DF11431FAF for ; Mon, 3 Sep 2012 05:06:33 -0700 (PDT) Received: by vbbfc26 with SMTP id fc26so5548794vbb.26 for ; Mon, 03 Sep 2012 05:06:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:subject:in-reply-to:references:user-agent:date:message-id :mime-version:content-type:content-transfer-encoding :x-gm-message-state; bh=iAJbF1g6ElUTeHRe9UujWaUb1GWb8wdN13MCbpKuMd8=; b=Uo1Lo2+EzSH2uYN2+1oWIgYp9R7OA1CcFHtoMC00QAZlZLT8SCpm34kymAiG2TsKpA IBUnhX49xXKvbCseH1iz9oIHiZy9VjPz6QzHf8fzFTVwezsTR9oXxOzIyfQTkFyjuQso Gpt9klPKGGQ2ZpFMvklFuORw//Vyj6g++hV0dJ5p0mngwGyqUPd31ojTiXj+j/0x2uEe V3fZ5hNIwfCLSZe1+thoHo3+a45LIxR694QfIdtAAWCCp5ipCWsX2gYOTfze9zIygaV+ rUUnTFbFJ3O0R5EbRNQF4RXdGkXlPGGtMUNU4aXbJ5sP16WecKU3paaaQR3WZSxcff4u kL2w== Received: by 10.220.228.131 with SMTP id je3mr12086371vcb.73.1346673992674; Mon, 03 Sep 2012 05:06:32 -0700 (PDT) Received: from localhost ([2001:4b98:dc0:43:216:3eff:fe1b:25f3]) by mx.google.com with ESMTPS id n19sm5381305vde.5.2012.09.03.05.06.31 (version=SSLv3 cipher=OTHER); Mon, 03 Sep 2012 05:06:32 -0700 (PDT) From: Jani Nikula To: Michal Nazarewicz , notmuch@notmuchmail.org Subject: Re: [PATCH 1/6] emacs: add helper for tag change list manipulation In-Reply-To: References: <9dbf16fb95f40812ad246f95b954681bc895ceb2.1346614915.git.jani@nikula.org> User-Agent: Notmuch/0.14+42~g397e223 (http://notmuchmail.org) Emacs/23.2.1 (x86_64-pc-linux-gnu) Date: Mon, 03 Sep 2012 14:06:24 +0200 Message-ID: <87txvf8g5b.fsf@nikula.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQlTybitowxnKiyA9wCDr+4z7r35veHn9Wh9BZKL3QGtuJUYduJWAdjEZCzZlAK0135N2o77 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: Mon, 03 Sep 2012 12:06:34 -0000 On Mon, 03 Sep 2012, Michal Nazarewicz wrote: > Jani Nikula writes: >> Add a helper to create (and optionally reverse) a list of tag changes. >> --- >> emacs/notmuch-tag.el | 17 +++++++++++++++++ >> 1 file changed, 17 insertions(+) >> >> diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el >> index 0c0fc87..c1aeb99 100644 >> --- a/emacs/notmuch-tag.el >> +++ b/emacs/notmuch-tag.el >> @@ -140,6 +140,23 @@ notmuch-after-tag-hook will be run." >> ;; in all cases we return tag-changes as a list >> tag-changes) >>=20=20 >> +(defun notmuch-tag-change-list (tags &optional reverse) >> + "Convert TAGS into a list of tag changes. >> + >> +Add a \"+\" prefix to any tag in TAGS list that doesn't already >> +begin with a \"+\" or a \"-\". If REVERSE is non-nil, replace all >> +\"+\" prefixes with \"-\" and vice versa in the result." >> + (mapcar (lambda (str) >> + (let ((s (if (not (string-match "^[+-]" str)) >> + (concat "+" str) >> + str))) > > (if (string-match "^[-+]" str) str (concat "+" str)) > > Negation only makes things less readable IMO. Agreed. Jani. > >> + (if reverse >> + (concat (if (=3D (string-to-char s) ?-) "+" "-") >> + (substring s 1)) >> + s))) >> + tags)) >> + >> + >> ;; >>=20=20 >> (provide 'notmuch-tag) > > --=20 > Best regards, _ _ > .o. | Liege of Serenely Enlightened Majesty of o' \,=3D./ `o > ..o | Computer Science, Micha=C5=82 =E2=80=9Cmina86=E2=80=9D Nazarewicz = (o o) > ooo +------------------ooO--(_)--Ooo--