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 765CF431FD7 for ; Thu, 6 Sep 2012 08:32:50 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" 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 lplGmwXME-gn for ; Thu, 6 Sep 2012 08:32:50 -0700 (PDT) Received: from mail-lpp01m010-f53.google.com (mail-lpp01m010-f53.google.com [209.85.215.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id BE3AE431FAE for ; Thu, 6 Sep 2012 08:32:49 -0700 (PDT) Received: by mail-lpp01m010-f53.google.com with SMTP id c1so1301010lah.26 for ; Thu, 06 Sep 2012 08:32:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :in-reply-to:references:x-gm-message-state; bh=P+V2XjotYGUTABCSAd57sHvTUV1y04qGir8aa4yLu0o=; b=YkMP7nRK7mzJi+IYvYQj/1KQpIlkPS38PIFikiLUESTfETShuCN7S82xC0pxwWlh5Q MqUbcJPCVizvUCK+7YqKvRGIiFgJoXgcRWK9Zjh52eRSjO+tC5E65PgsqgX1nSlS+ybz ZYsFQfJFZKPs6NQtNA5vF5VQlF0fBJ0McofV4Mh5uJEyHRswiAdG+FbkWfw+/IjT2X5B ypIoaX1dJj8pm/nnCPHOWB6fM30ap6i3A/GL8qUjK3etrxGDYkSkev+qfdGyDVmieHku nxgujF2tZKrsmrhvjAUz0vhkKnPSk5+CpIG4D0Mn4MudZDCJ5oSMQKlF2aZ9+v6dsEZb J3fQ== Received: by 10.152.46.209 with SMTP id x17mr2306990lam.38.1346945569312; Thu, 06 Sep 2012 08:32:49 -0700 (PDT) Received: from localhost (dsl-hkibrasgw4-fe51df00-27.dhcp.inet.fi. [80.223.81.27]) by mx.google.com with ESMTPS id lr17sm2416863lab.12.2012.09.06.08.32.47 (version=SSLv3 cipher=OTHER); Thu, 06 Sep 2012 08:32:48 -0700 (PDT) From: Jani Nikula To: notmuch@notmuchmail.org Subject: [PATCH v2 1/6] emacs: add helper for tag change list manipulation Date: Thu, 6 Sep 2012 18:32:37 +0300 Message-Id: <507c09a1872c15b3febeb215542a81fc8dce6938.1346945257.git.jani@nikula.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: X-Gm-Message-State: ALoCoQnP6RINp1+tUKpom1ZwUf6qAF8AUoy+KS2YCriFz79hg+MeZJwtuLdwCKwULMjrn78qCFnc Cc: Tomi Ollila 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, 06 Sep 2012 15:32:50 -0000 Add a helper to create (and optionally reverse) a list of tag changes. --- emacs/notmuch-tag.el | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el index 0c0fc87..4fce3a9 100644 --- a/emacs/notmuch-tag.el +++ b/emacs/notmuch-tag.el @@ -140,6 +140,21 @@ notmuch-after-tag-hook will be run." ;; in all cases we return tag-changes as a list tag-changes) +(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 (string-match "^[+-]" str) str (concat "+" str)))) + (if reverse + (concat (if (= (string-to-char s) ?-) "+" "-") + (substring s 1)) + s))) + tags)) + + ;; (provide 'notmuch-tag) -- 1.7.9.5