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 4DAF8431FC4 for ; Sun, 2 Sep 2012 12:58:22 -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 LvZuDkdKEYXC for ; Sun, 2 Sep 2012 12:58:20 -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 E0A2E431FC2 for ; Sun, 2 Sep 2012 12:58:14 -0700 (PDT) Received: by lahc1 with SMTP id c1so3430631lah.26 for ; Sun, 02 Sep 2012 12:58:13 -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=GFmrz+2vzZpdJHZluDIQkuM7tZ+QToNsrJcsOpgb3os=; b=apS5U7iOuf0mck0R5Zs5blVGXMHzJxg6kfTzftYJ9DXVdeHuzW7OX3Y3uP6JGH27TN nabjpBgMCGYEzECpN+YrXQVt+M4xnoav7zeiQkOCr+hMef6LWjCWGqIlaXLK9MkmSB+0 s3UA2HnYunyFORHTEQZkv3eu8cgQTgO3kfuy8LGw3NDQ4UhkuX2T7yFASHC0onEqZcD0 Zoeo5ddpTg0Y5hxQmMK+2LRwySd6/8Co6ZtogrFLLwWdpnBsClj1d1qoLW/fCJdyOYyx 8Qd6N22jtpvFeCNH0e83xXOOC3UfhT++aWtMCnu5OWxjAVc5kbb/PG2mxCh6EiPfh3R2 yAmw== Received: by 10.112.17.161 with SMTP id p1mr2927015lbd.64.1346615893216; Sun, 02 Sep 2012 12:58:13 -0700 (PDT) Received: from localhost (dsl-hkibrasgw4-fe51df00-27.dhcp.inet.fi. [80.223.81.27]) by mx.google.com with ESMTPS id n7sm2750552lbk.10.2012.09.02.12.58.11 (version=SSLv3 cipher=OTHER); Sun, 02 Sep 2012 12:58:12 -0700 (PDT) From: Jani Nikula To: notmuch@notmuchmail.org Subject: [PATCH 1/6] emacs: add helper for tag change list manipulation Date: Sun, 2 Sep 2012 22:58:00 +0300 Message-Id: <9dbf16fb95f40812ad246f95b954681bc895ceb2.1346614915.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: ALoCoQlhKpRqZd852T0c+HnfZ/UrLB2bWFw3vxyQ8wgwQ1XGsvl8aJMRntlORTM8Zz5rIasPKBYg 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: Sun, 02 Sep 2012 19:58:23 -0000 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) +(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 reverse + (concat (if (= (string-to-char s) ?-) "+" "-") + (substring s 1)) + s))) + tags)) + + ;; (provide 'notmuch-tag) -- 1.7.9.5